Cheetah Speech-to-Text
C API
API Reference for the Cheetah C SDK.
pv_cheetah_t
Container representing the Cheetah Speech-to-Text engine.
pv_cheetah_init()
Creates a Cheetah instance. Resources should be cleaned when you are done using the pv_cheetah_delete() function.
Parameters
access_keyconst char * : AccessKey obtained from Picovoice Console.model_pathconst char * : Absolute path to the file containing model parameters (.pv).deviceconst char * : String representation of the device (e.g., CPU or GPU) to use. If set tobest, the most suitable device is selected automatically. If set togpu, the engine uses the first available GPU device. To select a specific GPU device, set this argument togpu:${GPU_INDEX}, where${GPU_INDEX}is the index of the target GPU. If set tocpu, the engine will run on the CPU with the default number of threads. To specify the number of threads, set this argument tocpu:${NUM_THREADS}, where${NUM_THREADS}is the desired number of threads.endpoint_duration_secfloat : 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 to0to disable endpoint detection.enable_automatic_punctuationbool : Set totrueto enable automatic punctuation insertion.enable_text_normalizationbool : Set totrueto enable text normalization. Enabling this feature improves the readability and formatting of Cheetah's transcriptions (e.g. converts number words to digits) at the cost of some additional latency.objectpv_cheetah_t * * : Constructed instance of Cheetah.
Returns
- pv_status_t : Status code.
pv_cheetah_delete()
Releases resources acquired by Cheetah.
Parameters
objectpv_cheetah_t * : Picovoice object.
pv_cheetah_process()
Processes a frame of audio and returns newly-transcribed text, word-level metadata and a flag indicating if an endpoint has been detected. Upon detection of an endpoint, the client may invoke pv_cheetah_flush() to retrieve any remaining transcription. The caller is responsible for freeing
the transcript and words buffers using pv_cheetah_transcript_delete()
and pv_cheetah_words_delete(), respectively.
The number of samples per frame can be attained by calling pv_cheetah_frame_length(). The incoming audio needs to have a sample rate equal to pv_sample_rate() and be 16-bit linearly-encoded. Cheetah operates on single-channel audio.
Parameters
objectpv_cheetah_t * : Cheetah object.pcmconst int16_t * : A frame of audio samples.transcriptchar * * : Inferred transcription.num_wordsint32_t * : Number of transcribed words.wordspv_word_t * * : Transcribed words and their associated metadata.is_endpointbool * : Flag indicating if an endpoint has been detected. If endpoint is disabled then set toNULL.
Returns
- pv_status_t : Status code.
pv_cheetah_flush()
Marks the end of the audio stream, flushes internal state of the object, and returns any remaining transcript and word-level metadata. The caller is responsible for freeing
the transcript and words buffers using pv_cheetah_transcript_delete()
and pv_cheetah_words_delete(), respectively.
Parameters
objectpv_cheetah_t * : Cheetah object.transcriptchar * * : Inferred transcription.num_wordsint32_t * : Number of transcribed words.wordspv_word_t * * : Transcribed words and their associated metadata.
Returns
- pv_status_t : Status code.
pv_cheetah_transcript_delete()
Deletes transcript returned from pv_cheetah_process or pv_cheetah_flush.
Parameters
transcriptchar * : Transcript returned by Cheetah.
pv_cheetah_words_delete()
Deletes words returned from pv_cheetah_process or pv_cheetah_flush.
Parameters
num_wordsint32_t : Number of elements inwords.wordspv_word_t * : Transcribed words returned by Cheetah.
pv_cheetah_version()
Getter for version.
Returns
- const char * : Cheetah version.
pv_cheetah_frame_length()
Getter for number of audio samples per frame.
Returns
- int32_t : Frame length.
pv_sample_rate()
Audio sample rate accepted by Cheetah.
Returns
- int32_t : Sample rate.
pv_cheetah_list_hardware_devices()
Gets a list of hardware devices that can be specified when calling pv_cheetah_init().
Parameters
hardware_deviceschar * * * : Array of available hardware devices. Devices are NULL terminated strings. The array must be freed usingpv_cheetah_free_hardware_devices().num_hardware_devicesint32_t * : The number of devices in thehardware_devicesarray.
Returns
- pv_status_t : Returned status code.
pv_cheetah_free_hardware_devices()
This function frees the memory allocated by pv_cheetah_list_hardware_devices().
Parameters
hardware_deviceschar * * : Array of available hardware devices allocated bypv_cheetah_list_hardware_devices().num_hardware_devicesint32_t : The number of devices in thehardware_devicesarray.
pv_word_t
Struct for a transcribed word and its associated metadata.
pv_status_t
Status code enum.
pv_status_to_string()
Parameters
statuspv_status_t : Status code.
Returns
- const char * : String representation of status code.
pv_get_error_stack()
If a function returns a failure (any pv_status_t other than PV_STATUS_SUCCESS), this function can be
called to get a series of error messages related to the failure. This function can only be called only once per
failure status on another function. The memory for message_stack must be freed using pv_free_error_stack.
Regardless of the return status of this function, if message_stack is not NULL, then message_stack
contains valid memory. However, a failure status on this function indicates that future error messages
may not be reported.
Parameters
message_stackchar * * * : Array of messages relating to the failure. Messages are NULL terminated strings. The array and messages must be freed usingpv_free_error_stack().message_stack_depthint32_t * : The number of messages in themessage_stackarray.
Returns
- pv_status_t : Returned status code.
pv_free_error_stack()
This function frees the memory used by error messages allocated by pv_get_error_stack().
Parameters
message_stackchar * * : Array of messages relating to the failure.