JamesBrill / react-speech-recognition

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

multiple instances for multiple language use-case #83

Closed melounek closed 3 years ago

melounek commented 3 years ago

I would like to simultaneously transcript the voice in more language at once so I can also detect the language this way.

That's why I am wondering why there are the global variables recognitionManager and SpeechRecognition because if they would be store as a state of the hook, it would be possible to create as many instances as I need.

so the questions are:

JamesBrill commented 3 years ago

Hi @melounek The default Web Speech API only supports the transcription of one language at a time - hence, this is a global property. It also does not provide any kind of language detection. For something like that, you will need to use a different Speech Recognition service, one with some more advanced machine learning features under the hood. Alternatively, you could require that users manually specify which languages they want transcription in and switch between them when they finish speaking, for example.

I recently made a release of this library that supports polyfills. One such polyfill supports Azure Cognitive Services, which looks like it has some kind of language detection functionality. It may be possible that you can combine all these together to get the result you want. I'm not sure that polyfill exposes the language detection feature yet, so you may need to raise an issue or PR with them.

Hope that helps!

melounek commented 3 years ago

Right, I didn't see it is the global property so I will have to figure out something else.

Thanks for the polyfill. And just FYI: I didn't really find out how to work with the authorizationToken to avoid exposing subscriptionKey In neither your's, compulim's or azure's docs.