我在API:https://wicg.github.io/speech-api/之后创建了一个语音识别站点。该网站在Chrome中工作,但在Safari中不起作用。
这是有意义的:基于浏览器支持的细节:https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API/Using_the_Web_Speech_API#browser_support,(目前针对桌面和安卓系统的语音到文本仅限于Chrome )。
但没有意义的是:https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition#browser_compatibility 是最后一个链接,声称它是支持的。3.
我很困惑,Safari是否提供支持?
我从Safari获得的错误是:检测到语音识别错误:服务不允许的语音识别错误。
这个错误意味着什么?
service-not-allowed
用户代理不允许请求的语音识别服务,原因要么是用户代理不支持它,要么是出于安全、隐私或用户偏好的原因。在这种情况下,它将允许使用另一种更合适的语音识别服务。
https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognitionErrorEvent/error
我尝试为麦克风、Safari设置和我的计算机设置提供明确的权限。没起作用。我不知道如何明确允许safari进行语音识别。它应该请求许可,但它没有。
有没有人对如何让语音识别在Safari上工作有任何建议?
这是代码:
var recognition = new speechRecognition()
var textBox = $("#textbox")
var instructions = $("#instructions")
var cont = ''
recognition.continuous = true
// Recognition started
recognition.onstart = function () {
instructions.text("Voice recognition is on")
}
recognition.onspeechend = function () {
instructions.text("No speech detected")
}
recognition.onerror = function (event) {
instructions.text('Speech recognition error detected: ' + event.error)
}
recognition.onresult = function (event) {
var current = event.resultIndex;
var transcript = event.results[current][0].transcript;
cont += transcript
textBox.val(cont)
}
$("#start-btn").click(function (event) {
if(cont.length){
cont += ''
}
recognition.start()
})```
I created this based on this tutorial: https://www.youtube.com/watch?v=rwB6RqqCmXc 发布于 2021-09-08 15:46:15
我想出来了。对于Safari,用户需要启用听写,以便语音到文本工作。详细信息可以在这里找到:https://bugs.webkit.org/show_bug.cgi?id=225298
发布于 2021-09-07 07:48:52
您是否确保在站点上设置了SSL证书?有时,如果麦克风不在安全连接上,浏览器可能会阻止对它的访问。
现在,如果这是一个本地站点,您可以使用自签名的SSL证书作为解决办法,如果没有发布该证书。
https://stackoverflow.com/questions/69082404
复制相似问题