Question · Speech recognition
Why does speech recognition show a network or not-allowed error?
A **network** error means the network communication that speech recognition needs failed, so the request never finished. A **not-allowed** error means the browser blocked speech input for security, privacy or user preference reasons, and a refused microphone permission is one common cause. MDN lists Firefox's support for speech recognition only as preview, so a page there cannot rely on the feature.
Updated October 17, 20264 min read9 cited facts, each traced to its source
The two errors name two different failures. A network error means the recognizer needed a connection to finish and did not get one. A not-allowed error means the browser refused to start speech input at all. The first is a connectivity problem and the second is a permission or policy problem. The error property of the error event tells you which one you have, so read it before you guess at a fix. The JavaScript guide to speech recognition on a website shows where that event fits in the code.
A network error means the recognizer could not reach its service
When speech recognition fails because a network connection it needs is missing, the page receives the network error code 1. The word "needs" matters. Whether a connection is needed depends on where the recognition runs. In Chrome, speech recognition on a web page uses a server-based engine, and the audio is sent to a web service 2. A device that is offline, or on a network that blocks that service, gets a network error.
The error code alone does not say which of those happened. A firewall, a VPN, a proxy and a dropped connection all look the same to the page. Test the page with the connection on and then off. If it works only online, the speech service is the dependency, and your page should show a text box for the offline case.
A not-allowed error means the browser refused speech input
The not-allowed code means the user agent disallowed any speech input for reasons of security, privacy or user preference 3. In practice a refused microphone permission is one common trigger. When a website wants the microphone, Chrome on a computer asks the visitor to choose Allow while visiting the site, Allow this time, or Never allow 4. A visitor who chose Never allow has told the browser to block the site, so attempts fail with this error until they change that choice.
The operating system can block the browser as well. On a Mac, Apple says you can decide which apps are allowed to use the microphone 5. If the error stays after you allow the site, check that the browser is allowed in the system microphone settings too.
Firefox lists speech recognition only as a preview
If the error appears in Firefox, the browser may lack the feature rather than your code having a fault. MDN's compatibility data lists Firefox's support for SpeechRecognition only as preview, not as a numbered stable release 6. A Mozilla wiki page revised in January 2022 says Chrome, Edge, Safari and Opera supported the speech-to-text form of the Web Speech API, but Firefox did not 7. The MDN data is the current reference for this.
Check for the constructor before you call it, and show a fallback, as the JavaScript guide does. If Firefox users matter to your product, plan for a different engine rather than the browser API. Which browsers support speech recognition lists the versions.
It depends: local files and browsers that block the service
Two cases change the answer.
Local files. Chrome's prefixed webkitSpeechRecognition name needs the code to be served through a web server for recognition to work 8. If you open the page from a folder on your disk, serve it from a local web server first, then test again.
Browsers that disable the service. In Brave the API can exist but return nothing. A developer's report in Brave's issue tracker says the Web Speech API is disabled in Brave from returning results, so an app cannot tell which speech service to use 9. That report is from 2019 and describes a Brave build from that period. Test the current release before you rely on either the report or a fix.
What to do
- Log
event.errorfirst. Anetworkerror and anot-allowederror need different fixes, and the event carries the name. - For a network error, test offline and online. If it fails only offline, show a text box and say that voice input needs a connection.
- For a not-allowed error, check two settings. Check the site's microphone setting in the browser, then the system microphone setting for the browser.
- Plan for Firefox and for blocked browsers. Check for the constructor, show the fallback, and do not leave the page waiting for a result that will not come.
- Test in each browser you support, including one with the microphone blocked on purpose, because that is the not-allowed path.
For the browser interface itself, read the Web Speech API guide and its glossary entry. Whether the audio goes to a server is covered in whether the Web Speech API sends audio to Google, and whether Chrome can do speech to text offline covers the offline case. This question sits inside our guide to speech recognition in Python and the speech recognition overview.
Evidence
Every number on this page, with where it comes from. Open a fact to see the exact words in its source.
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
Go deeper
Related questions
- How do you add speech recognition to a React or React Native app?
- How do you add speech recognition to a Unity or Unreal game?
- Can an ESP32 or microcontroller do speech recognition?
- Can large language models do speech recognition?
- Can Whisper AI do text to speech?
- Can Whisper identify different speakers?
- Can Whisper run without a GPU?
- Can Whisper transcribe in real time?