Defines a streaming speech recognizer API. It provides access to the platform speech recognition service.
Note that there can be only one speech recognizer. Attempting to create a second speech recognizer without destroying the first one will result in undefined behavior.
SbSpeechRecognizerDestroy should be called from a single thread. Callbacks defined in
SbSpeechRecognizerHandler will happen on another thread, so calls back into the SbSpeechRecognizer from the callback thread are disallowed.
Well-defined value for an invalid speech recognizer handle.
Indicates what has gone wrong with the recognition.
No speech was detected. Speech timed out.
Speech input was aborted somehow.
Audio capture failed.
Some network communication that was required to complete the recognition failed.
The implementation is not allowing any speech input to occur for reasons of security, privacy or user preference.
The implementation is not allowing the application requested speech service, but would allow some speech service, to be used either because the implementation doesn't support the selected one or because of reasons of security, privacy or user preference.
There was an error in the speech recognition grammar or semantic tags, or the grammar format or semantic tag format is supported.
The language was not supported.
An opaque handle to an implementation-private structure that represents a speech recognizer.
typedef struct SbSpeechRecognizerPrivate* SbSpeechRecognizer
A function to notify that a speech recognition error occurred.
error: The occurred speech recognition error.
typedef void(* SbSpeechRecognizerErrorFunction) (void *context, SbSpeechRecognizerError error)
A function to notify that the recognition results are ready.
results: the list of recognition results.
results_size: the number of
is_final: indicates if the
results is final.
typedef void(* SbSpeechRecognizerResultsFunction) (void *context, SbSpeechResult *results, int results_size, bool is_final)
A function to notify that the user has started to speak or stops speaking.
detected: true if the user has started to speak, and false if the user stops speaking.
typedef void(* SbSpeechRecognizerSpeechDetectedFunction) (void *context, bool detected)
When the continuous value is set to false, the implementation MUST return no more than one final result in response to starting recognition. When the continuous attribute is set to true, the implementation MUST return zero or more final results representing multiple consecutive recognitions in response to starting recognition. This attribute setting does not affect interim results.
Controls whether interim results are returned. When set to true, interim results SHOULD be returned. When set to false, interim results MUST NOT be returned. This value setting does not affect final results.
This sets the maximum number of SbSpeechResult in
Allows receiving notifications from the device when recognition related events occur.
The void* context is passed to every function.
Function to notify the beginning/end of the speech.
Function to notify the speech error.
Function to notify that the recognition results are available.
void * context
This is passed to handler functions as first argument.
The recognition response that is received from the recognizer.
char * transcript
The raw words that the user spoke.
A numeric estimate between 0 and 1 of how confident the recognition system is that the recognition is correct. A higher number means the system is more confident. NaN represents an unavailable confidence score.
Cancels speech recognition. The speech recognizer stops listening to audio and does not return any information. When
SbSpeechRecognizerCancel is called, the implementation MUST NOT collect additional audio, MUST NOT continue to listen to the user, and MUST stop recognizing. This is important for privacy reasons. If
SbSpeechRecognizerCancel is called on a speech recognizer which is already stopped or cancelled, the implementation MUST ignore the call.
void SbSpeechRecognizerCancel(SbSpeechRecognizer recognizer)
Creates a speech recognizer with a speech recognizer handler.
If the system has a speech recognition service available, this function returns the newly created handle.
If no speech recognition service is available on the device, this function returns
SbSpeechRecognizerCreate does not expect the passed SbSpeechRecognizerHandler structure to live after
SbSpeechRecognizerCreate is called, so the implementation must copy the contents if necessary.
SbSpeechRecognizer SbSpeechRecognizerCreate(const SbSpeechRecognizerHandler *handler)
Destroys the given speech recognizer. If the speech recognizer is in the started state, it is first stopped and then destroyed.
void SbSpeechRecognizerDestroy(SbSpeechRecognizer recognizer)
Returns whether the platform supports SbSpeechRecognizer.
Indicates whether the given speech recognizer is valid.
static bool SbSpeechRecognizerIsValid(SbSpeechRecognizer recognizer)
Starts listening to audio and recognizing speech with the specified speech configuration. If
SbSpeechRecognizerStart is called on an already started speech recognizer, the implementation MUST ignore the call and return false.
Returns whether the speech recognizer is started successfully.
bool SbSpeechRecognizerStart(SbSpeechRecognizer recognizer, const SbSpeechConfiguration *configuration)
Stops listening to audio and returns a result using just the audio that it has already received. Once
SbSpeechRecognizerStop is called, the implementation MUST NOT collect additional audio and MUST NOT continue to listen to the user. This is important for privacy reasons. If
SbSpeechRecognizerStop is called on a speech recognizer which is already stopped or being stopped, the implementation MUST ignore the call.
void SbSpeechRecognizerStop(SbSpeechRecognizer recognizer)