gotev / android-speech

Android speech recognition and text to speech made easy
http://gotev.github.io/android-speech/
Apache License 2.0
473 stars 156 forks source link

Muting the underlying API #29

Closed EdwinVanRooij closed 4 years ago

EdwinVanRooij commented 5 years ago

Would it be possible to mute the sounds which the underlying API makes? E.g. when we start listening for voice input, this would be the flow that the API goes through"

  1. Play beep, start listening
  2. Speech input
  3. Convert to text
  4. End of input
  5. Play beep, stop listening

I do not like the 1 and 5 sounds, I've searched a bit and found this https://stackoverflow.com/a/37882934/5273299 and this https://android.stackexchange.com/a/129713 link. Would it be possible to integrate some solution into this library, and then setting the sound on/off based on a boolean?

Great library, thanks!

gotev commented 5 years ago

Of course yes, the library is based solely on stock Android APIs, so if you found a way go ahead and send a PR 😎

EdwinVanRooij commented 5 years ago

I implemented functionality to mute the entire phone's audio output starting right before receiving speech input, until right receiving the results. This only happens when the user executes the next line: Speech.getInstance().setMuteSpeechRecognizerSounds(true);

It's not precisely how I wanted to implement it. The ending 'beep' is still there. This still plays because the ending 'beep' is played after we receive the results. Google only provides onEndOfSpeech() and onResults(...), not a desired afterBeepsoundPlayed() or something. Source: https://developer.android.com/reference/android/speech/RecognitionListener

Ps: The way I'm going to implement this in my app, is by muting the phone's audio before starting to listen for speech input, and unmuting it ~200ms after receiving my results. I did not want to include that solution into this codebase, because the 200ms is a guessed number as to when the sound would have been played, this may vary by device based on phone specs.

Ps2: Any ideas as to how to detect the end of the 'beep' sound played by the RecognitionListener would be appreciated, then it'd be possible to fully integrate this functionality into the library.

gotev commented 4 years ago

Closing this because it's not a sustainable feature to have