有很多关于webkitSpeechRecognition的内容可以阅读,您获得该对象的原因如下:
这给出了一个需要以这种方式处理的对象:
recognition.onresult = function(event) {
for (var i = event.resultIndex; i < event.results.length; ++i) {
var identificated = event.results[i][0].transcript;//This is what recognizes
if (event.results[i].isFinal) {
console.log("Final sentence is : " + identificated );
}else{
console.log("I understood : " + identificated );
}
}
1) 在这里查看官方演示
Source Code Here
2) 或在此处快速阅读(以下是您需要的内容):
Example of what you need
您可以使用webkitSpeechRecognition测试我的语音控制库
Artyom Voice Recognition - Control