Reputation: 824
I wrote a HTML5 webpage consisting only of:
<input type="text" style="font-size: 40px;" name="speech" size="50" x-webkit-speech/>
What I'm trying to do is to get the x-webkit-speech to start automatically as soon as I enter the page and continously put out the speech recognition results into the text. How would I do that ? I've seen various javascripts relating to that and I tested a lot of them but they don't work for me.
Thanks to anyone who answers ! ;)
Upvotes: 4
Views: 4067
Reputation: 27765
You can try to use Web Speech API, for example:
if ('webkitSpeechRecognition' in window) {
var recognition = new webkitSpeechRecognition();
var final_transcript = '';
recognition.continuous = true;
recognition.interimResults = true;
recognition.onresult = function( event ) {
var final_transcript = '';
for (var i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
final_transcript += event.results[i][0].transcript;
}
}
document.getElementById( 'speech' ).value = final_transcript;
};
recognition.start();
}
The only one thing is that you will need to allow page to use microphone at page load
Upvotes: 5