+ 5
How to use Speech recognition in JavaScript.
how to recognise the speech of the user.
3 Antworten
+ 5
For as advanced of a concept speech recognition is, the API to use it is fairly simple:
var recognition = new (window .SpeechRecog
recognition.lang = 'en -US ' ;
recognition.interimResults = false ;
recognition.maxAlternatives = 5;
recognition.start () ;
recognition.onresult = function ( event ) {
console .log ( 'You said : ' , event . resul
};
The first match is at the
event.results[0][0].transcript path; you can also set the number of alternatives in the case that what you're listening for could be ambiguous.
You can even add your own terms using the
SpeechGrammarList object:
var grammar = '# JSGF V1 .0; grammar colors
var recognition = new SpeechRecognition( )
var speechRecognitionList = new SpeechGra
speechRecognitionList . addFromString (gramma
recognition.grammars = speechRecognitionLi
</color >
There are several events emitted during the speech recognition process, so you can use the following snippet to follow the event timeline:
[
'onaudiostart ',
'onaudioend ' ,
'onend ' ,
'onerror ',
'onnomatch ',
'onresult ' ,
'onsoundstart ',
'onsoundend ' ,
'onspeechend' ,
'onstart '
].forEach (function ( eventName ) {
recognition[ eventName ] = function (e)
console. log (eventName , e );
} ;
});
+ 1
No you need a different environment
0
will it work in SoloLearn