I am creating a basic speech-to-text website. It only needs to work in Google Chrome, so I'm using the simple chrome speech-to-text API. It activates for a second and then disables. My code is simple:
var recognition = new webkitSpeechRecognition();
recognition.continuous = true;
recognition.interimResults = true;
final_transcript = '';
recognition.onresult = function (event) {
var interim_transcript = '';
for (var i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
final_transcript += event.results[i][0].transcript;
} else {
interim_transcript += event.results[i][0].transcript;
}
}
document.getElementById("write").value = final_transcript;
recognition.start();
};
recognition.start();
For some reason, a problem occurs. It worked perfectly a day ago. All answers are appreciated!
我做了一个类似的任务,并通过调用来实现它recognition.stop()
在onresult
处理器和recognition.start()
在onend
处理程序。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.