JamesBrill / react-speech-recognition

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

Offline use #7

Closed CygnusBell closed 6 years ago

CygnusBell commented 6 years ago

Hi, I don't see any mention of this requiring a network connection, however when I attempt to use it offline it does not respond. (No error thrown, it just never updates the Transcript).

Is it possible to use it offline?

Any help would be very much appreciated as I'm somewhere I cannot access the internet but still would like to use the app I'm making.

JamesBrill commented 6 years ago

According to the Web Speech API docs: On Chrome, using Speech Recognition on a web page involves a server-based recognition engine. Your audio is sent to a web service for recognition processing, so it won't work offline.

So unfortunately, speech recognition will not function in Chrome when offline - it's probably too intensive to run in a browser directly.

There is a workaround for detecting online state: you can check the value of navigator.onLine. If it is true, you render the transcript. If it is false, you render whatever offline fallback you want when speech recognition is disabled. The online/offline API is pretty simple to use - you can read how to use it here.

I've updated the README to explain this.

CygnusBell commented 6 years ago

Oh, thank you for the response and the great module!

Sad I can't make it work offline, but it will be my goto when I get back to stable internet.