-
Notifications
You must be signed in to change notification settings - Fork 113
SpeechRecognizer
Use the SpeechRecognizer to incorporate voice input into HoloJs apps. Call SpeechRecognizer.isAvailable() to check if a speech recognizer is available for the script.
- start()
Starts recognizing the keywords enabled with setKeywords. If no keywords were specified, speech recognition runs in free dictation mode.
Note: On Windows, for free dictation to work, speech recognition must be enabled from Settings->Privacy->Speech. If speech recognition is not enabled this way, the script will receive a onerror callback after calling start() when no keywords are set.
- stop()
Stops speech recognition. The list of keywords is retained. Script must wait for the onstop event to fire before calling start again.
- setKeywords(keywords)
Sets which keywords to match during voice recognition. The keywords parameter is an array of strings. Must be called before start to have an effect. To clear keywords, call this method with an empty array.
var speechRecognizer= new SpeechRecognizer();
speechRecognizer.setKeywords(["start"]);
speechRecognizer.start();
- onresult
Triggered when a new mesh is added.
var speechRecognizer= new SpeechRecognizer();
speechRecognizer.onresult = function(result) {
if (result.text === "start" && result.confidence > 0.75) {
console.log("got a match");
}
};
speechRecognizer.setKeywords(["start"]);
speechRecognizer.start();
- onerror
Triggered when an error is encountered starting speech recognition. It can happen when no audio input is available, the user did not allow microphone input, the user did not enable speech recognition, etc.
- onstop
Triggered when recognition stops, either because of system internal reasons or the script calling stop().