react-speech-recognition
react-speech-recognition copied to clipboard
regeneratorRuntime is not defined
This error is reported when I use the library on my project:
Uncaught ReferenceError: regeneratorRuntime is not defined
I have the same issue when I use in my typescript
project
Hi @LeXuanNguyen @amirzenoozi Check out this. Let me know if that helps.
@JamesBrill I Check That Link and It's Work But Only In Chrome Browser. You Didn't Support Other Browsers ?
and the other issue is we don't have browserSupportsSpeechRecognition
in useSpeechRecognition()
What Should I Do About This? ( I think It's Related To @types
Package)
@amirzenoozi Do you mean that after installing and importing regenerator-runtime
, you still see regeneratorRuntime is not defined
in browsers other than Chrome? Or do you mean that speech recognition functionality does not work outside of Chrome? The latter is largely true due to the limited support for the Web Speech API in many browsers (see supported browsers). Your options are to either use browserSupportsSpeechRecognition to turn off your voice-driven feature on unsupported browsers, or to use a polyfill.
Regarding browserSupportsSpeechRecognition
, perhaps you can share some code or a link to your repo in a separate GitHub issue so I can better understand the problem. This boolean property is returned as state from the useSpeechRecognition
hook and should reflect the support for speech recognition in the browser.
i had this issue in all of the browsers. app.js:1304 Uncaught ReferenceError: regeneratorRuntime is not defined at eval (RecognitionManager.js:219) at eval (RecognitionManager.js:290) at eval (RecognitionManager.js:385) at Object.../node_modules/react-speech-recognition/lib/RecognitionManager.js (app.js:793) at webpack_require (app.js:1301) at fn (app.js:1512) at eval (SpeechRecognition.js:16) at Object.../node_modules/react-speech-recognition/lib/SpeechRecognition.js (app.js:804) at webpack_require (app.js:1301) at fn (app.js:1512)
Same here
Hi @rafaelsouzagomes @mariuszbeltowski have you tried this?
I am getting this error running jest but browser is running fine, is fixed by adding import 'regenerator-runtime'
at the top of files importing SpeechRecognition
Thankyou so much , it works fine now !!
Hi @rafaelsouzagomes @mariuszbeltowski have you tried this?
This solved my problem
I also have a problem. But not able to solve.
I am getting this error running jest but browser is running fine, is fixed by adding
import 'regenerator-runtime'
at the top of files importingSpeechRecognition
Still not working
Hi @LeXuanNguyen @amirzenoozi Check out this. Let me know if that helps.
Yes this works thanks a lot.
FYI! You need to include the import 'regenerator-runtime/runtime'
at the top of the page.tsx file/s where you are using the library. In my case, it was at the top of the page.tsx of a nested tree. It did not work for me when I added it at the top of the root layout or at the root page.tsx. I'm using NextJS 13 App Dir
import 'regenerator-runtime/runtime'
in my case i've already installed and importing regenerator-runtime, but still i can see regeneratorRuntime is not defined in every browsers including Chrome.
Can anyone let me know the reason behind the error, and what additions including this library to our environment is doing?
import "regenerator-runtime/runtime";
installing regenerator-runtime
and adding this line at the top of the file solved my issue.
Remember to add the import statement at the very first line of your file
If you are using React make sure to add this [ import "regenerator-runtime/runtime"; ] at line 1 of " main.jsx" file OR If using Javascript add the above import statement at line 1 of " index.js" file OR If using Typescript add the above import statement at line 1 of " index.tsx" file