Leopard Speech-to-Text
React API
API Reference for the Leopard React SDK (npmjs).
useLeopard()
React Hook for Leopard speech-to-text engine.
Returns
resultLeopardTranscript | null : A state containing the transcript result value.isLoadedboolean : A state indicating whether the engine has initialized successfully.errorError | null : AnErrorobject containing details about the error.init(...) => Promise<void> : A method to initializeLeopardgiven the arguments. Seeinit.processFile(...) => Promise<void> : A method to process audio files. SeeprocessFile.startRecording(...) => Promise<void> : A method to start recording audio. SeestartRecording.stopRecording() => Promise<void> : A method to stop recording audio and begin processing. SeestopRecording.isRecordingboolean : A state indicating whetherwebVoiceProcessoris passing audio to the engine.recordingElapsedSecnumber : The amount of time (in seconds) elapsed while recording.release() => Promise<void> : Releases resources acquired byuseLeopard. Seerelease.
init()
Initializes useLeopard hook. Sets isLoaded to true.
Parameters
accessKeystring : AccessKey obtained from Picovoice Console.modelLeopardModel : Object containing Leopard model.optionsLeopardOptions : Optional configuration arguments.
processFile()
Processes an audio file, which should be provided as a File object with a MIME type of audio and encoded in linear PCM format.
Parameters
fileFile : File object with the MIME type = audio.
startRecording()
Start recording audio. If started, isRecording is set to true.
Parameters
maxRecordingSecnumber : Optional configuration argument to set the maximum time in seconds Leopard is able to record. If unspecified, a default value of 120 will be used. This is to prevent unbounded memory usage.
stopRecording()
Stop recording audio and begin processing the buffered audio. Sets isRecording to false.
release()
Releases resources acquired by the useLeopard. Sets isLoaded and isRecording to false, recordingElapsedSec to 0, and error to null.