JamesBrill / react-speech-recognition

💬Speech recognition for your React app
https://webspeechrecognition.com/
MIT License
645 stars 116 forks source link

[Solved!] Removing Polyfill if the language is not supported #145

Closed YoussefZidan closed 1 year ago

YoussefZidan commented 1 year ago

To support more than just Chrome, I'm using "@speechly/speech-recognition-polyfill."

nonetheless, the Arabic language is not supported as a result.

So, my goal is to only apply the polyfill if the language is "en," otherwise, I want to delete it.

something like this:

  useEffect(() => {
    if (lang !== "ar") {
      const SpeechlySpeechRecognition = createSpeechlySpeechRecognition(speechlyId);
      SpeechRecognition.applyPolyfill(SpeechlySpeechRecognition);
    } else {
      SpeechRecognition.removePolyfill();  // <=== is there a function to stop or removes the polyfill ??
    }
  }, [lang]);
JamesBrill commented 1 year ago

@YoussefZidan Thanks for raising this - this seems like a legitimate use case to me. That feature now exists in 3.10.0 - let me know how it works for you.

YoussefZidan commented 1 year ago

@YoussefZidan Thanks for raising this - this seems like a legitimate use case to me. That feature now exists in 3.10.0 - let me know how it works for you.

Gerat!

Thanks alot!

It's working fine ^^