Cobalt enables voice search through either:
Only one or the other can be used, and we recommend that the MediaRecorder API is followed, as we are considering deprecating the Speech Recognition API.
In both approaches, in order to check whether to enable voice control or not, web apps will call the MediaDevices.enumerateDevices() Web API function within which Cobalt will in turn call a subset of the Starboard SbMicrophone API. In both approaches,
SB_HAS_MICROPHONE must be defined to 1.
To enable the MediaRecorder API in Cobalt, the complete SbMicrophone API must be implemented, and the
SB_HAS_SPEECH_RECOGNIZER must be defined to 0.
SB_HAS_SPEECH_RECOGNIZER flag to have the value 1 in your platform's
configuration_public.h file, and implement the SbSpeechRecognizer API.
Implement the following subset of the SbMicrophone API:
In particular, SbMicrophoneCreate() must return a valid microphone. It is okay to stub out the other functions, e.g. have
The YouTube app will display the mic icon on the search page when it detects valid microphone input devices using
SB_HAS_SPEECH_RECOGNIZER defined to 1, Cobalt will use the platform's Starboard SbSpeechRecognizer API implementation, and it will not actually read directly from the microphone via the Starboard SbMicrophone API.
In previous versions of Cobalt, there was no way to dynamically disable speech support besides modifying common Cobalt code to dynamically stub out the Speech Recognition API when the platform does not support microphone input. This is no longer necessary, web apps should now rely on
MediaDevices.enumerateDevices() to determine whether voice support is enabled or not.