简体   繁体   English

支持Opera中的webkitSpeechRecognition API

[英]Support for the webkitSpeechRecognition API in Opera

We're using the webkitSpeechRecognition API in Chrome. 我们在Chrome中使用了webkitSpeechRecognition API。 Since this is a prototype application, we're quite happy to support only Chrome, so we detect support for the API by doing a window.hasOwnProperty('webkitSpeechRecognition') check (as suggested by Google ). 由于这是一个原型应用程序,我们非常乐意仅支持Chrome,因此我们通过执行window.hasOwnProperty('webkitSpeechRecognition')检查来检测对API的支持(如Google建议 )。 This happily fails in Firefox, but the new Opera (being webkit-based) reports it does have the property. 这在Firefox中很快失败,但是新的Opera(基于webkit)报告它确实拥有该属性。 And, indeed, all code runs as intended, except... none of the events are ever fired, no voice is ever recorded. 事实上,所有代码都按预期运行,除了......没有任何事件被触发,也没有记录任何语音。

So, my question is: can I make it work somehow? 所以,我的问题是:我可以以某种方式使它工作吗? Does it require some special permissions or settings? 它需要一些特殊权限或设置吗?

Alternatively, is there a way (aside good old browser-sniffing) to detect proper, working support for the webkitSpeechRecognition? 或者,是否有一种方法(除了良好的旧浏览器嗅探)来检测webkitSpeechRecognition的正确,工作支持?

Right now only google chrome have API to speech recognition by stream (they have google sppeech API). 现在只有谷歌浏览器有流媒体识别API(他们有谷歌sppeech API)。

If you will use https://www.google.com/intl/en/chrome/demos/speech.html on Opera it will tell you that you need Chrome25+ to do this. 如果您在Opera上使用https://www.google.com/intl/zh-CN/chrome/demos/speech.html ,它会告诉您需要Chrome25 +才能执行此操作。

Acording to http://caniuse.com/#feat=speech-recognition Opera webkit have support for this functionality but right now it is not working. 根据http://caniuse.com/#feat=speech-recognition,Opera webkit支持此功能,但现在它无法正常工作。 Opera does not have any API service that would translate it on the fly. Opera没有任何可以即时翻译的API服务。 Right now there have only placeholders function in their browser, maybe in the future they will make it, right no it is not working. 现在只有占位符功能在他们的浏览器中,也许将来他们会成功,不管它不起作用。

* EDITED * *已编辑*

Example by google how to determinte if it working or not. 谷歌示例如何确定它是否正常工作。

 // checking by google if (!('webkitSpeechRecognition' in window)) { console.log('GOOGLE: not working on this browser'); } else { console.log('GOOGLE: working'); } //your way if (window.hasOwnProperty('webkitSpeechRecognition')) { console.log('YOUR: working'); } else { console.log('YOUR: not working on this browser'); } 

以下Google示例使用时间戳来检测Opera未触发启动事件: https//www.google.com/intl/en/chrome/demos/speech.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM