添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I was using Web Speech API for speech to text. But when calling recognition.start() it is showing me SpeechRecognitionErrorEvent

recognition = new webkitSpeechRecognition()
recognition.continuous = false
recognition.interimResults = false
recognition.onend = () => console.log("ended")
recognition.onerror = () => console.log("errored")
recognition.start()

Its logging,

errored
ended
SpeechRecognitionErrorEvent {isTrusted: true, error: "not-allowed", message: "", type: "error", target: SpeechRecognition, …}

I tried it in my react project. Trying to trigger the recognizer from chrome console also results in the same error. Someone else, as I am using it for the first time I cannot quite grasp the reason for this error. Another question with the same issue was raised in stackoverflow from where I couldn't got an clear answer. Is it that I must request the speech api start method with a ssl certificate. Otherwise, I cannot use the feature.

UPDATE:
I had to enable microphone permission manually in the browser to get rid of this error.

Just for the record, another reason this error can occur is if you are sending a Permissions-Policy header (W3C Working Draft) in your HTTP responses and include the string microphone=() to disable access to the microphone. This header is typically used to prevent malicious third-party scripts from asking for the microphone.

Try this :

  const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
  const recognition = new SpeechRecognition();
  recognition.start()
                Everything is working on my system, maybe there is some problem with your system settings. Try on some other device
– Gayatri Dipali
                Jan 5, 2021 at 5:29
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.