React speech recognition does not work in chrome for mobile
See original GitHub issueHi there, the code
import SpeechRecognition, {
useSpeechRecognition
} from "react-speech-recognition";
SpeechRecognition.startListening({ continuous: true });
works very well in chrome browser on my macOs but doesn’t works in mobile devices on chrome, have tried on various devices but it only listens for the first time and then after i hit the api with my finalTranscript it automatically stops listening. I wonder do i have to do something else in mobile devices to make it worse ?
Thanks
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Speech recognition is not working in Android Chrome
I have just implemented speech recognition in React.js application using JS vanilla code in the function. In desktop Chrom I tested it ...
Read more >react-speech-recognition - npm
Unfortunately, speech recognition will not function in Chrome when offline. According to the Web Speech API docs: On Chrome, using Speech ...
Read more >A Quick Look at the React Speech Recognition Hook
React Speech Recognition is a react hook that accesses the Web Speech API to convert speech from the machine's microphone to the app's...
Read more >Using the React Speech Recognition Hook for voice assistance
React Speech Recognition is a React Hook that works with the Web Speech API to translate speech from your device's mic into text....
Read more >Fix issues with “Hey Google” - Google Search Help
Troubleshoot Android phones & tablets · On your Android phone or tablet, go to Assistant settings, or open the Google Assistant app Assistant...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I was able to reproduce some weird behaviour on Android Chrome with a simple dictaphone component that enabled continuous listening. On desktop, it behaved as expected. But on Android Chrome, I observed the following:
continuous: false
(“discontinuous listening”)react-speech-recognition
trying to keep the microphone on when something other than the user tries to stop the microphone during continuous listeningIn other words, the
continuous
setting doesn’t seem to work any more on Android Chrome, which is disappointing. The constant restarting (and probably the annoying beeping noise that Android makes when it turns the microphone on) that you’re seeing is the browser misbehaving and the library trying to compensate for it.I probably added the logic for automatically restarting in that case to compensate for weird browsers like Android Chrome. And indeed, it does work to some degree - you get a continuous-ish experience. However, I don’t remember the delay between restarts being so severe - previously, they were so short they were invisible whenever I tested on Android Chrome. Now Android’s delay between restarts is long enough that speech can be missed completely. It’s hard to tell if this is due to a change in the browser or in Android itself (the OS ultimately controls the microphone). Others seem to have encountered this issue recently.
You said that the vanilla Speech Recognition API (i.e. the API without this library) works for your purpose. Do you mean that you were able to get continuous listening working on Android Chrome? I tried using the raw API myself in this way and could not get this behaviour on Android Chrome. However, with continuous turned off, I was able to get
react-speech-recognition
to behave sensibly, despite the annoying beep every time you tap.So I’m pretty sure there’s a limitation in Android that we’ll have to workaround here. I’ll be able to help you find alternatives more efficiently if I understand your use case better - a brief specification of what user experience you’re trying to create will be useful. Some thoughts on what you could do:
react-speech-recognition
.If Android Chrome really does not support continuous listening in a usable way, I will update the README to warn about this. Perhaps I can provide a better fallback behaviour or expose a
supportsContinuousListening
property.P.S. A tip for testing your locally-hosted web app on mobile and with HTTPS. Use ngrok. It allows you to proxy localhost to a public URL with HTTPS. You have to sign up, but it’s free. You can also use this to share your local build with people on other networks. I’ve been using this to test local builds on mobile and share with stakeholders for years.
Hi @JamesBrill , thanks for responding. Version of library used - 3.7.0 Version of chrome 89.0.4389.105 Android 10 Here is the link to my github repo https://github.com/ratnabh/React-Redux-with-new-hooks-api-multireducer-
To run the project
Then to run this project on mobile u could use your system ip address followed by your port like
http://192.xxx.x.222:3000
To run this on chrome in mobile you may need to do the following steps below as chrome doesnt allow for microphone on http
chrome://flags/#unsafely-treat-insecure-origin-as-secure
in ChromeInsecure origins treated as secure
http://192.xxx.x.xxx:3000
and then enable it and relaunch chromeNow you will see on presing button the mic turns on, try speaking something and then an mock apis hits up which after returning response from server again runs the code to turn on the mic, but the issue comes up when u wait for 1-2 second, the mic keeps on turning off and on again n again. I need to capture the transcript again spoken by user (will close mic after 5 second of inactivity)
Thanks for your time !