Riley-Brown / react-speech-to-text

React Hooks for Speech to Text
MIT License
118 stars 31 forks source link

Cross-browser seems not work as expected #4

Closed ilhamwahabi closed 3 years ago

ilhamwahabi commented 3 years ago

If we enable crossBrowser and provide googleApiKey seems it's still not using Google Cloud for the transcription, so:

Reproduction (I'm just using example code): https://codesandbox.io/s/nifty-raman-thfsj?file=/src/App.js

Riley-Brown commented 3 years ago

@iwgx Are you testing on chrome? If so, chrome will still use the speech recognition API since it's available, the cross-browser is intended for other browsers such as Firefox, Edge, Brave, etc.

Riley-Brown commented 3 years ago

I also added a speechRecognitionProperties param you can pass to the hook the customize the settings for chrome speech recognition API such as language code https://github.com/Riley-Brown/react-speech-to-text#speechrecognitionproperties

ilhamwahabi commented 3 years ago

I see, thanks for the confirmation

Previously I think if we pass the crossBrowser params, it will override the SpeechRecognition so It will use GCP in all browser. Since I think GCP will more reliable

Riley-Brown commented 3 years ago

The reasoning for this is because Chrome is the most popular browser so more users would use the built-in Chrome speech recognition API which is free and provides faster speech-to-text than using the GCP method.

I can add a useOnlyGoogleCloud param to override this if you think it's needed

ilhamwahabi commented 3 years ago

I thinks that's needed, since we can control if we want:

BTW the reliability that I mean is in terms of transcription. I think since GCP process it in their server, it will have higher accuracy than processed the browser (although of course it will be faster)

Riley-Brown commented 3 years ago

Just published version 0.5.0 with useOnlyGoogleCloud param to force GCP on chrome browsers

Also, this is from the speech recognition docs

Note: On some browsers, like 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 I would think Chrome built in speech API would use the same engine that google cloud speech to text uses so the results should be the same

ilhamwahabi commented 3 years ago

Thanks for the update

And I just learn about that, will investigate further if there is different between them