JamesBrill / react-speech-recognition

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

How can I resetTranscripts from command's cb? #53

Closed EggTronic closed 4 years ago

EggTronic commented 4 years ago

I want to clear the transcripts once the certain commands have been executed.

JamesBrill commented 4 years ago

Aha I see the chicken-and-egg problem here. You cannot use resetTranscript from the command definition because this is only defined after calling useSpeechRecognition with the commands. I will create a solution for this, hopefully by the end of today.

JamesBrill commented 4 years ago

@EggTronic I have attempted to address this in v3.2.0. An object containing resetTranscript is passed to the command callbacks as the last argument. e.g.

    {
      command: 'clear',
      callback: ({ resetTranscript }) => resetTranscript()
    }

Let me know how you get on with that.

EggTronic commented 4 years ago

@JamesBrill wow thanks!!! Your problem-solving speed is amazing!