【问题标题】:Web Speech api not working on android chromeWeb Speech api不适用于android chrome
【发布时间】:2021-01-31 18:49:03
【问题描述】:

Web 语音 api (webkitSpeechRecognition) 在 Android 手机上返回“不允许”错误。

(我在 android 设置中授予 Microphone 权限以访问 chrome 应用和网站)

桌面版 Chrome 正在运行。 但是,在 android 上不是。

(测试手机为三星 Galaxy S9,Android 版本 10,Chrome 版本 86)

我在 Android 上测试了 MicrosoftEdge、SamsungInternet 以及 Chrome。 但全部返回'not-allowed'错误

测试页 https://www.google.com/intl/en/chrome/demos/speech.html

在 chrome 远程设备控制台上测试代码。

const a = new webkitSpeechRecognition()
a.onerror = (err) => {console.log("err:", err)}
a.start()
=> VM187:1 err: SpeechRecognitionErrorEvent {isTrusted: true, error: "not-allowed", message: "", type: "error", target: SpeechRecognition, …}

是安卓的问题吗? 我怎样才能让它工作?

【问题讨论】:

    标签: android google-chrome speech-recognition webspeech-api


    【解决方案1】:

    添加麦克风权限

    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    

    如果没有解决,请使用 webview

    然后确保在 webview 中启用了 javascript

    【讨论】:

    • 我已经在 Android 设置中授予了 Chrome 应用和网站的麦克风权限。
    • 为您的应用授予权限
    • 这是官方的 Google Chrome 浏览器。我没有使用 chrome webview。我正在开发网站。但它不适用于 android chrome 浏览器。嗯...无论如何,在使用 webview 的 android 应用程序上,网络语音 api 是否工作?好的,我去测试一下。
    • 在android中不需要webspeech api你可以使用语音转文本
    • 我已经使用 Web Speech API 开发了网站。但它不适用于 android 移动浏览器。我想让它工作。我负担不起开发另一个 Android 应用程序的费用。
    【解决方案2】:

    我知道这是一个非常古老的问题。

    在我的情况下,问题是由无效的 SSL 证书引起的。 Desktop Chrome (Linux) 很好,但 Android Chrome 抛出“不允许”错误。修复 SSL 证书解决了这个问题。

    【讨论】:

    • 谢谢。你只是为我节省了大量的时间和挫败感。 :)
    猜你喜欢
    • 2020-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多