Cheetah Speech-to-Text
Rust API
API Reference for the Cheetah Rust SDK (crates.io).
cheetah::Cheetah
Struct for the Cheetah Speech-to-Text engine.
cheetah::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 .frame_length
. The incoming audio needs to have a sample rate equal to .sample_rate
and be 16-bit linearly-encoded. Furthermore, Cheetah operates on single-channel audio.
Parameters
pcm
&[i16] : Audio data.
Returns
Result<CheetahTranscript, CheetahError>
: IfOk
, returns the inferred transcription as aCheetahTranscript
object. IfErr
, aCheetahError
object describing the error that was encountered.
cheetah::Cheetah.flush()
Marks the end of the audio stream, flushes internal state of the object, and returns any remaining transcribed text.
Returns
Result<CheetahTranscript, CheetahError>
: IfOk
, returns the remaining inferred transcription as aCheetahTranscript
object. IfErr
, aCheetahError
object describing the error that was encountered.
cheetah::Cheetah.frame_length()
Gets the frame length.
Returns
u32
: Audio frame length accepted by Cheetah.
cheetah::Cheetah.sample_rate()
Gets the sample rate.
Returns
u32
: Audio sample rate accepted by Cheetah.
cheetah::Cheetah.version()
Gets the Cheetah version.
Returns
&str
: Cheetah version string.
cheetah::CheetahBuilder
Builder struct for creating an instance of Cheetah
.
cheetah::CheetahBuilder.new()
Creates a new CheetahBuilder
.
Returns
CheetahBuilder
: A new Builder object.
cheetah::CheetahBuilder.access_key()
Modifies the access_key
of a CheetahBuilder
object.
Parameters
access_key
S : AccessKey obtained from Picovoice Console.
Returns
CheetahBuilder
: The modified Builder object.
cheetah::CheetahBuilder.model_path()
Modifies the model_path
of a CheetahBuilder
object.
Parameters
model_path
P : Path to the file containing model parameters (.pv
).
Returns
CheetahBuilder
: The modified Builder object.
cheetah::CheetahBuilder.library_path()
Modifies the library_path
of a CheetahBuilder
object.
Parameters
library_path
P : Path to the Cheetah library file.
Returns
CheetahBuilder
: The modified Builder object.
cheetah::CheetahBuilder.endpoint_duration_sec()
Modifies the endpoint_duration_sec
of a CheetahBuilder
object.
Parameters
endpoint_duration_sec
f32 : Duration of endpoint in seconds. A speech endpoint is detected when there is a segment of audio (with a duration specified herein) after an utterance without any speech in it. Set to0
to disable endpoint detection.
Returns
CheetahBuilder
: The modified Builder object.
cheetah::CheetahBuilder.enable_automatic_punctuation()
Modifies the enable_automatic_punctuation
of a CheetahBuilder
object.
Parameters
enable_automatic_punctuation
bool : Set totrue
to enable automatic punctuation insertion.
Returns
CheetahBuilder
: The modified Builder object.
cheetah::CheetahBuilder.init()
Creates an instance of Cheetah
from the CheetahBuilder
object.
Returns
Result<Cheetah, CheetahError>
: IfOk
, an initialized instance ofCheetah
. IfErr
, an instance ofCheetahError
detailing the error that was encountered.
cheetah::CheetahTranscript
Struct containing transcript information returned by the Cheetah Rust SDK.
Properties
transcript
String : Any transcribed speech (if none, then an empty string is returned).is_endpoint
bool : A flag indicating if an endpoint has been detected.
cheetah::CheetahError
An error type describing any errors encountered by the Cheetah SDK.
cheetah::CheetahError.new()
Creates a new instance of CheetahError
Parameters
status
CheetahErrorStatus
: Type of error encountered.message
impl Into<String> : Message detailing the cause of the error.
cheetah::CheetahErrorStatus
Enum describing possible error types returned from the Cheetah Rust SDK.
cheetah::PvStatus
Error codes returned from the Cheetah library.