Chrome iOS webkit speech-recognition

旧巷老猫 提交于 2019-12-08 16:03:39

问题


I'm trying to implement speech recognition on Chrome on the iPad without any luck. Just to cut to the chase and remove any dependencies on my implementation of the webkitSpeechRecognition api, Glenn Shire's excellent sample code does not run on Chrome v27 on an iPad 1 running iOS 5.1.1 or Chrome v31 on an iPad3 running iOS 7.0.4, at least as far as I can tell. It fails at this line:

 if (!('webkitSpeechRecognition' in window)) {
    r.onState('upgrade');
    return;
 }

I can't figure out a workaround, and I've not seen any online postings that say anything about speech recognition not working in the iOS version of Chrome. Anyone else run into this?


回答1:


Chrome on iOS doesn't support Speech Recognition at the moment.

Google have to use iOS UIWebView that mean there is no special web interpretation feature that are not supported on Safari.

You may have a look to this link.




回答2:


In case you want to recognize few simple commands you can look on Pocketsphinx.js

The code to recognize speech is simple:

var id = 0;
recognizer.postMessage({command: 'initialize', callbackId: id});
var keyphrase = "HELLO WORLD";
recognizer.postMessage({command: 'addKeyword', data: keyphrase, callbackId: id});
recognizer.postMessage({command: 'start', data: id});
recognizer.postMessage({command: 'process', data: array});
recognizer.postMessage({command: 'stop'});

recognizer.onmessage = function(e) {
     if (e.data.hasOwnProperty('hyp')) {
           alert(e.data.hyp);
     }
};

For more details see also the full example here



来源:https://stackoverflow.com/questions/20640081/chrome-ios-webkit-speech-recognition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!