Riley-Brown/react-speech-to-text

Expose Google Cloud Speech-to-text config

ilhamwahabi opened this issue · 3 comments

Hi! Great library, really appreciate your work.

I want to create an app that's not based on US, so I need a way to configure the GCP config especially the language.
I think It's also good consideration if we expose another config so it will be customizable. What do you think?

I'm available if you would like for me to do pull request for this one.

Thank you.

This is a good idea, the google config can be found in the Hooks/index.tsx file on line 215, we can add an optional googleConfig param to the hook in order to overwrite the default values
ex:

  const config = {
        encoding: 'LINEAR16',
        languageCode: 'en-US',
        sampleRateHertz: sampleRate,
        ...googleConfig
      };

These are the types for the google config, I can create the PR for this or if you want to feel free as well https://cloud.google.com/speech-to-text/docs/reference/rest/v1/RecognitionConfig

Just pushed version 0.4.0 with support for a custom googleCloudRecognitionConfig and speechRecognitionProperties params, added both to readme https://github.com/Riley-Brown/react-speech-to-text#googlecloudrecognitionconfig

Let me know if you run into any issues with new changes