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.
|SbSpeechRecognizerCreate|, |SbSpeechRecognizerStart|, |SbSpeechRecognizerStop|, |SbSpeechRecognizerCancel| and |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.
Indicates what has gone wrong with the recognition.
Values
kSbNoSpeechError
- No speech was detected. Speech timed out.kSbAborted
- Speech input was aborted somehow.kSbAudioCaptureError
- Audio capture failed.kSbNetworkError
- Some network communication that was required to complete the recognitionfailed.kSbNotAllowed
- The implementation is not allowing any speech input to occur for reasons ofsecurity, privacy or user preference.kSbServiceNotAllowed
- The implementation is not allowing the application requested speechservice, but would allow some speech service, to be used either because theimplementation doesn't support the selected one or because of reasons ofsecurity, privacy or user preference.kSbBadGrammar
- There was an error in the speech recognition grammar or semantic tags, orthe grammar format or semantic tag format is supported.kSbLanguageNotSupported
- The language was not supported.Members
An opaque handle to an implementation-private structure that represents a speech recognizer.
The recognition response that is received from the recognizer.
Members
Description
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.
Declaration and definitions
#include "starboard/speech_recognizer.h" #if SB_HAS(SPEECH_RECOGNIZER) && SB_API_VERSION >= 5 void SbSpeechRecognizerCancel(SbSpeechRecognizer /*recognizer*/) {} #endif // SB_HAS(SPEECH_RECOGNIZER) && SB_API_VERSION >= 5
Parameters
Description
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 kSbSpeechRecognizerInvalid
.
SbSpeechRecognizerCreate
does not expect the passed SbSpeechRecognizerHandler structure to live after SbSpeechRecognizerCreate
is called, so the implementation must copy the contents if necessary.
Declaration and definitions
#include "starboard/speech_recognizer.h" #if SB_HAS(SPEECH_RECOGNIZER) && SB_API_VERSION >= 5 SbSpeechRecognizer SbSpeechRecognizerCreate( const SbSpeechRecognizerHandler* /*handler*/) { return kSbSpeechRecognizerInvalid; } #endif // SB_HAS(SPEECH_RECOGNIZER) && SB_API_VERSION >= 5
Parameters
Description
Destroys the given speech recognizer. If the speech recognizer is in the started state, it is first stopped and then destroyed.
Declaration and definitions
#include "starboard/speech_recognizer.h" #if SB_HAS(SPEECH_RECOGNIZER) && SB_API_VERSION >= 5 void SbSpeechRecognizerDestroy(SbSpeechRecognizer /*recognizer*/) {} #endif // SB_HAS(SPEECH_RECOGNIZER) && SB_API_VERSION >= 5
Parameters
Description
Indicates whether the given speech recognizer is valid.
Declaration
static SB_C_INLINE bool SbSpeechRecognizerIsValid( SbSpeechRecognizer recognizer) { return recognizer != kSbSpeechRecognizerInvalid; }
Parameters
Description
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.
Declaration and definitions
#include "starboard/speech_recognizer.h" #if SB_HAS(SPEECH_RECOGNIZER) && SB_API_VERSION >= 5 bool SbSpeechRecognizerStart(SbSpeechRecognizer /*recognizer*/, const SbSpeechConfiguration* /*configuration*/) { return false; } #endif // SB_HAS(SPEECH_RECOGNIZER) && SB_API_VERSION >= 5
Parameters
Description
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.
Declaration and definitions
#include "starboard/speech_recognizer.h" #if SB_HAS(SPEECH_RECOGNIZER) && SB_API_VERSION >= 5 void SbSpeechRecognizerStop(SbSpeechRecognizer /*recognizer*/) {} #endif // SB_HAS(SPEECH_RECOGNIZER) && SB_API_VERSION >= 5
Parameters