Speech recognition not working in chrome
10,203
I just tried on my computer and it works:
$(function () {
try {
var recognition = new webkitSpeechRecognition();
} catch (e) {
var recognition = Object;
}
recognition.continuous = true;
recognition.interimResults = true;
recognition.onresult = function (event) {
var txtRec = '';
for (var i = event.resultIndex; i < event.results.length; ++i) {
txtRec += event.results[i][0].transcript;
}
$('#txtArea').val(txtRec);
};
$('#startRecognition').click(function () {
$('#txtArea').focus();
recognition.start();
});
$('#stopRecognition').click(function () {
recognition.stop();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<button id="startRecognition">Start Recognition</button>
<button id="stopRecognition">Stop Recognition</button>
<textarea id="txtArea"></textarea>
Author by
Faisal Sajjad
Updated on June 04, 2022Comments
-
Faisal Sajjad almost 2 years
I am trying to access the audio from chrome browser using javascript code below, but when I click the the button the
recognition.onresult
event is not firing in chrome browser, however when I access the online webpage that contains live demo of speech to text, its working fine in chrome browser please help.<script type="text/javascript"> var recognition = new SpeechRecognition(); recognition.onresult = function(event) { if (event.results.length > 0) { alert("Working"); } } </script> <form> <input type="button" value="Click to Speak"onclick="recognition.start()"> </form>
-
Faisal Sajjad over 8 yearsNo its not working on my chrome browser, its not firing recognition.start();
-
Faisal Sajjad over 8 yearsThe chrome version installed on my PC is " Version 46.0.2490.86 m" with windows 10
-
gaetanoM over 8 years@FaisalSajjad my computer runs Windows 8.1 and Chrome is version 47.0.2526.73 m
-
Faisal Sajjad over 8 years@gaemaf its giving me error "not-allowed", why its giving error not-allowed?
-
gaetanoM over 8 yearsyou need to give authorization whenever the browser ask you. This happened for me the first time I executed my script.
-
Faisal Sajjad over 8 yearsThanks @gaemaf, its working now, actually I was running locally as file://, so that's why it was not working, I run it on localhost now its working.