Leopard Speech-to-Text
React Native API
API Reference for the React Native Leopard SDK (npm)
Leopard
Class for the Leopard Speech-to-Text engine.
Leopard.create()
Leopard constructor.
Parameters
accessKeystring : AccessKey obtained from Picovoice Console.modelPathstring : Path to the file containing model parameters (.pv). Can be either a path that is relative to the assets/resource folder or an absolute path to the file on device.optionsLeopardOptions : Optional configuration arguments:enableAutomaticPunctuationboolean : Whether to enable automatic punctuation.enableDiarizationboolean : Whether to enable diarization. Set totrueto enable speaker diarization, which allows Leopard to differentiate speakers as part of the transcription process. Word metadata will include aspeakerTagto identify unique speakers.
Returns
Promise<Leopard>: An instance of Leopard platform.
Leopard.delete()
Releases resources acquired by Leopard.
Leopard.sampleRate
Getter for audio sample rate accepted by Leopard.
Returns
number: Audio sample rate accepted by Leopard.
Leopard.version
Getter for version.
Returns
string: CurrentLeopardversion.
Leopard.process()
Processes given audio data with the speech-to-text engine. The incoming audio needs to have a sample rate equal to .sampleRate and be 16-bit linearly-encoded. Leopard operates on single-channel audio.
Parameters
framenumber[] : A frame of audio samples.
Returns
Promise<LeopardTranscript>:LeopardTranscriptobject which contains the transcription results of the engine.
Leopard.processFile()
Processes an audio file with the speech-to-text engine.
Parameters
audioPathstring : Absolute path to the audio file. The supported formats are:3gp (AMR),FLAC,MP3,MP4/m4a (AAC),Ogg,WAVandWebM.
Returns
Promise<LeopardTranscript>:LeopardTranscriptobject which contains the transcription results of the engine.
LeopardError
Exception thrown if an error occurs within Leopard Speech-to-Text engine.
Exceptions:
LeopardOptions
Class containing optional configuration parameters for Leopard.
enableAutomaticPunctuationboolean : Flag to enable automatic punctuation insertion.enableDiarizationboolean : Flag to enable diarization.
LeopardTranscript
Class containing results from a Leopard process function.
transcriptstring : Inferred transcription.wordsLeopardWord[]: Transcribed words and their associated metadata.
LeopardWord
Class containing results word transcribed by Leopard and their associated metadata.
wordstring : Transcribed word.startSecnumber : Start of word in seconds.endSecnumber : End of word in seconds.confidencenumber : Transcription confidence. It is a number within [0, 1].speakerTagnumber : Speaker tag is-1if diarization is not enabled during initialization; otherwise, it's a non-negative integer identifying unique speakers, with0reserved for unknown speakers.