Add iOS speech recognition support for web app?

谁都会走 提交于 2019-12-21 03:51:12

问题


Currently, the HTML5 web speech api works great on google chrome for all devices except mobile iOS. Text-to-speech works, but speech-to-text is not supported. webkitSpeechRecognition is not supported. See: Chrome iOS webkit speech-recognition

I am unable to find a workaround. I would like to add speech recognition support for iOS to my current web app that uses speech recognition and speech synthesis. Any suggestions? Thank you.


回答1:


Try something like this

recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition || window.mozSpeechRecognition || window.msSpeechRecognition)();
recognition.lang = "en-US";
recognition.interimResults = false;
recognition.maxAlternatives = 5;
recognition.onresult = function(event) {
  speechResults = event.results[0][0].transcript;
};
recognition.start();

The way the recognition variable is setup allows support for a variety of browsers. I made a Weave at LiveWeave.



来源:https://stackoverflow.com/questions/28592170/add-ios-speech-recognition-support-for-web-app

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