I have a web app and I want to use speech recognition Web API. The idea that I'm planning to do is using speech recognition for input and also for some commands.
I have created two speech recognition one for input and one for commands. Sometimes it works but it has many errors and issues due to both speech recognition running at the same time even when using the .stop()
function before the other start then back listening to the commands.
Does web speech API in javascript support two running speech recognition in one web app? if not, what is the best solution for that idea? because on page loading the web should listening for commands and on press button also need to speech recognition to fill the input.
Here is an example of the code to explain the idea, each speech recognition will have it is own features as lang, grammar and so on.
var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition
var SpeechGrammarList = SpeechGrammarList || webkitSpeechGrammarList
var SpeechRecognitionEvent = SpeechRecognitionEvent || webkitSpeechRecognitionEvent
speechRecognitionList.addFromString('#JSGF V1.0;', 1);
var ForInput = new SpeechRecognition();
ForInput.grammars = speechRecognitionList;
ForInput.continuous = true;
ForInput.lang = 'en-US';
ForInput.interimResults = true;
ForInput.maxAlternatives = 1;
var ForCommand = new SpeechRecognition();
ForCommand.grammars = speechRecognitionList;
ForCommand.continuous = false;
ForCommand.lang = 'en-US';
ForCommand.interimResults = false;
ForCommand.maxAlternatives = 1;
Thanks