Leopard Speech-to-Text
Flutter API
API Reference for the Flutter Leopard SDK (pub.dev)
Leopard
Class for the Leopard Speech-to-Text engine. Leopard must be initialized using create()
.
Resources should be cleaned when you are done using the delete()
function.
Leopard.create()
Static creator for initializing Leopard.
Parameters
accessKey
String : AccessKey obtained from Picovoice Console.modelPath
String : Path to the file containing model parameters (.pv
). Can be either a path that is relative to the project'sassets
folder or an absolute path to the file on device.enableAutomaticPunctuation
bool? : (Optional) Set totrue
to enable automatic punctuation insertion.enableDiarization
bool? : (Optional) Set totrue
to enable speaker diarization, which allows Leopard to differentiate speakers as part of the transcription process. Word metadata will include aspeaker_tag
to identify unique speakers.
Returns
Future<Leopard>
an instance of the speech-to-text engine.
Throws
LeopardException
: If not initialized correctly.
Leopard.process()
Process a frame of pcm audio with the speech-to-text engine.
Parameters
frame
List<int> : a frame of audio samples to be assessed by Leopard. The required audio format is found by calling.sampleRate
to get the required sample rate. Audio must be single-channel and 16-bit linearly-encoded.
Returns
Future<LeopardTranscript>
:LeopardTranscript
object which contains the transcription results of the engine.
Throws
LeopardException
: If process fails.
Leopard.processFile()
Processes a given audio file with the speech-to-text-engine.
Parameters
path
String : Absolute path to the audio file. The supported formats are:3gp (AMR)
,FLAC
,MP3
,MP4/m4a (AAC)
,Ogg
,WAV
andWebM
.
Returns
Future<LeopardTranscript>
:LeopardTranscript
object which contains the transcription results of the engine.
Throws
LeopardException
: If process fails.
Leopard.delete()
Frees memory that was allocated for Leopard
Leopard.sampleRate
Getter for the audio sample rate required by Leopard.
Leopard.version
Getter for Leopard version string.
LeopardException
Exception thrown if an error occurs within Leopard:
LeopardTranscript
Class that contains results from Leopard's process functions.
LeopardTranscript.transcript
Getter for transcript data.
Returns
String
: Inferred transcript.
LeopardTranscript.words
Getter for word metadata in the form of LeopardWords
.
LeopardWord
Class that contains word metadata.
LeopardWord.word
Getter for the transcribed word.
LeopardWord.startSec
Start time of word in seconds.
LeopardWord.endSec
End time of word in seconds.
LeopardWord.confidence
Transcription confidence. It is a number within [0, 1].
LeopardWord.speakerTag
The speaker tag is -1
if diarization is not enabled during initialization;
otherwise, it's a non-negative integer identifying unique speakers, with 0
reserved for unknown speakers.