+ 5

How to use Speech recognition in JavaScript.

how to recognise the speech of the user.

30th May 2018, 4:37 AM
keev23i
keev23i - avatar
3 Respostas
+ 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 ); } ; });
30th May 2018, 4:42 AM
Andrew Watts
Andrew Watts - avatar
+ 1
No you need a different environment
30th May 2018, 12:53 PM
Andrew Watts
Andrew Watts - avatar
0
will it work in SoloLearn
30th May 2018, 11:24 AM
keev23i
keev23i - avatar