Cheetah Speech-to-Text
Android API
API Reference for the Android Cheetah SDK (cheetah-android)
package: ai.picovoice.cheetah
Cheetah
Class for the Cheetah Speech-to-Text engine.
Cheetah must be initialized using the Builder() Class. Resources should be cleaned when you are done using the delete()
function.
Cheetah.delete()
Releases resources acquired by Cheetah
.
Cheetah.getFrameLength()
Getter for number of audio samples per frame.
Returns
int
: Number of audio samples per frame.
Cheetah.getSampleRate()
Getter for required audio sample rate for PCM data.
Returns
int
: Required audio sample rate for PCM data.
Cheetah.getVersion()
Getter for version.
Returns
String
: CurrentCheetah
version.
Cheetah.process()
Processes a frame of audio and returns newly-transcribed text and a flag indicating if an endpoint has been detected. Upon detection of an endpoint, the client may invoke .flush()
to retrieve any remaining transcription.
The number of samples per frame can be attained by calling .getFrameLength()
. The incoming audio needs to have a sample rate equal to .getSampleRate()
and be 16-bit linearly-encoded. Furthermore, Cheetah
operates on single-channel audio.
Parameters
pcm
short[] : A frame of audio samples.
Returns
CheetahTranscript
: Inferred transcription object.
Throws
CheetahException
: If there is an error while processing the audio frame.
Cheetah.flush()
Processes any remaining audio data and returns its transcription.
Returns
CheetahTranscript
: Inferred transcription object.
Throws
CheetahException
: If there is an error while processing the audio frame.
Cheetah.Builder
Builder for creating an instance of Cheetah
with a mixture of default arguments.
Cheetah.Builder.build()
Creates an instance of Cheetah
Speech-to-Text engine.
Parameters
context
Context : The Android app context.
Returns
Cheetah
: An instance of Cheetah Speech-to-Text engine.
Throws
CheetahException
: If an error occurs while creating an instance of Cheetah Speech-to-Text engine.
Cheetah.Builder.setAccessKey()
Sets the AccessKey of the builder.
Parameters
accessKey
String : AccessKey obtained from Picovoice Console.
Returns
Cheetah.Builder
: Modified Cheetah.Builder object.
Cheetah.Builder.setEnableAutomaticPunctuation()
Setter for enabling automatic punctuation insertion.
Parameters
enableAutomaticPunctuation
boolean : Set totrue
to enable automatic punctuation insertion.
Returns
Cheetah.Builder
: Modified Cheetah.Builder object.
Cheetah.Builder.setModelPath()
Sets the model path of the builder.
Parameters
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.Returns
Cheetah.Builder
: Modified Cheetah.Builder object.
Cheetah.Builder.setEndpointDuration()
Sets the endpoint duration of the builder. A speech endpoint is detected when there is a chunk of audio (with a duration specified herein) after an utterance without any speech in it. Set duration to 0 to disable this. Default is 1 second.
Parameters
endpointDuration
float : Duration of endpoint in seconds.
Returns
Cheetah.Builder
: Modified Cheetah.Builder object.
CheetahTranscript
Class that contains Cheetah transcript data.
CheetahTranscript.getTranscript()
Getter for transcript data.
Returns
string
: Inferred transcription.
CheetahTranscript.getIsEndpoint()
Getter for isEndpoint
flag.
Returns
boolean
: Iftrue
,Cheetah
detected a speech endpoint.
CheetahException
Exception thrown if an error occurs within Cheetah
Speech-to-Text engine.
Exceptions: