Cheetah - Java API
API Reference for the Java Cheetah SDK (cheetah-java)
package: ai.picovoice.cheetah
Cheetah
public class Cheetah { }
Class for the Cheetah Speech-to-Text engine.
Cheetah can be initialized using the Builder() Class. Resources should be cleaned when
you are done using the delete()
function.
Cheetah.Cheetah()
public Cheetah(String accessKey,String libraryPath,String modelPath,float endpointDurationSec) throws CheetahException
Cheetah
constructor. See also the Cheetah.Builder
Class.
Parameters
accessKey
String : AccessKey obtained from Picovoice Console.libraryPath
String : Absolute path to the native Cheetah library.modelPath
String : Absolute path to the file containing model parameters.endpointDurationSec
float : Duration of endpoint in seconds. 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 in the Builder.
Returns
Cheetah
: An instance of Cheetah engine.
Throws
CheetahException
: if there is an error while initializing Cheetah.
Cheetah.delete()
public void delete()
Releases resources acquired by Cheetah
.
Cheetah.getFrameLength()
public int getFrameLength()
Getter for number of audio samples per frame.
Returns
int
: Number of audio samples per frame.
Cheetah.getSampleRate()
public int getSampleRate()
Getter for required audio sample rate for PCM data.
Returns
int
: Required audio sample rate for PCM data.
Cheetah.getVersion()
public String getVersion()
Getter for version.
Returns
String
: CurrentCheetah
version.
Cheetah.process()
public CheetahTranscript process(short[] pcm) throws CheetahException
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()
public CheetahTranscript flush() throws CheetahException
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
public static class Builder {public Builder(String accessKey) { }}
Builder for creating an instance of Cheetah
with a mixture of default arguments.
Parameters
accessKey
String : AccessKey obtained from Picovoice Console.
Cheetah.Builder.build()
public Cheetah build() throws CheetahException
Creates an instance of Cheetah
Speech-to-Text engine.
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()
public Cheetah.Builder setAccessKey(String accessKey)
Sets the AccessKey of the builder.
Parameters
accessKey
String : AccessKey obtained from Picovoice Console.
Returns
Cheetah.Builder
: Modified Cheetah.Builder object.
Cheetah.Builder.setModelPath()
public Cheetah.Builder setModelPath(String modelPath)
Sets the model path of the builder.
Parameters
modelPath
String : Absolute path to the file containing model parameters (.pv
).
Returns
Cheetah.Builder
: Modified Cheetah.Builder object.
Cheetah.Builder.setLibraryPath()
public Builder setLibraryPath(String libraryPath)
Sets the library path of the builder.
Parameters
libraryPath
String : Absolute path to the native Cheetah library.
Returns
Cheetah.Builder
: Modified Cheetah.Builder object.
Cheetah.Builder.setEndpointDuration()
public Cheetah.Builder setEndpointDuration(float endpointDuration)
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
public class CheetahTranscript { }
Class that contains Cheetah transcript data.
CheetahTranscript.getTranscript()
public string getTranscript() { }
Getter for transcript data.
Returns
string
: Inferred transcription.
CheetahTranscript.getIsEndpoint()
public boolean getIsEndpoint() { }
Getter for isEndpoint
flag.
Returns
boolean
: Iftrue
,Cheetah
detected a speech endpoint.
CheetahException
public class CheetahException extends Exception { }
Exception thrown if an error occurs within Cheetah
Speech-to-Text engine.
Exceptions:
public class CheetahActivationException extends CheetahException { }public class CheetahActivationLimitException extends CheetahException { }public class CheetahActivationRefusedException extends CheetahException { }public class CheetahActivationThrottledException extends CheetahException { }public class CheetahIOException extends CheetahException { }public class CheetahInvalidArgumentException extends CheetahException { }public class CheetahInvalidStateException extends CheetahException { }public class CheetahKeyException extends CheetahException { }public class CheetahMemoryException extends CheetahException { }public class CheetahRuntimeException extends CheetahException { }public class CheetahStopIterationException extends CheetahException { }