问题描述
google Chrome扩展程序是否支持Chrome的Web语音语音识别API?我已经包含了一些用于创建语音识别对象的JavaScript,但是当我启动扩展程序时,没有提示您访问麦克风.
Do google Chrome extensions support Chrome's Web Speech speech recognition API? I have included some javascript to create a speech recognition object, but when I launch my extension, I am not prompted for microphone access.
这不是我的代码的问题.我已经在Google上进行了搜索,但是找不到关于Chrome扩展程序是否支持Web Speech API的任何信息.我只想要一个是/否的答案.
This is not an issue with my code. I have searched on google, but I can't find any information on whether Chrome extensions support the Web Speech API. I just want a yes/no answer.
注意:我相信WebSpeech API不适用于本地文件.
Note: I believe the WebSpeech API won't work for local files.
推荐答案
更新:基于 RobW的答案,此答案已过期,并且Web Speech API现在可在扩展程序内部使用. (很遗憾,除非OP拒绝接受,否则我无法删除此答案.)
Update: Based on RobW's answer, this answer is now out of date, and the Web Speech API is now usable inside of extensions. (Unfortunately, I can't delete this answer unless the OP un-accepts it.)
答案是尚未.通过chrome-extension:
URL访问的页面不能访问任何媒体输入API,包括speechRecognition
和getUserMedia
.任何尝试使用API的尝试都会立即触发错误回调.
The answer is not yet. Pages accessed through chrome-extension:
URLs cannot access any media-input APIs, including speechRecognition
and getUserMedia
. Any attempt to the use APIs will immediately trigger an error callback.
我本来以为speechRecognition
可以像geolocation
API一样工作:扩展弹出窗口无法提示地理位置许可,但是作为完整浏览器页面加载的chrome-extension:
页面可以提示许可正常页面.但是,媒体API不会这样;无论页面是弹出页面还是整页,它们都会失败.
I originally thought speechRecognition
could work like the geolocation
API: extension popups cannot prompt for geolocation permission, but chrome-extension:
pages loaded as full browser pages can prompt for permission just like a normal page. However, media APIs do not behave this way; they fail regardless of whether the page is a popup or a full page.
有一个错误报告可以解决此问题,允许开发人员在清单中指定媒体访问权限.修复此错误后,扩展程序可以具有清单集权限,从而授予它们自动的麦克风/视频访问权限,因此,无法提示权限将不再是问题(因此具有相应清单权限的扩展程序将能够自由使用语音API).
There is a bug report to fix this and allow developers to specify media-access permissions in the manifest. When this bug is fixed, extensions can have a manifest-set permission that grants them automatic microphone/video access, so the inability to prompt for permission will become a non-issue (and therefore extensions with appropriate manifest permissions will be able to freely use the Speech API).
这篇关于Chrome扩展程序是否支持WebSpeech API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!