androidthings / sample-googleassistant

Google Assistant API sample for Android Things
Apache License 2.0
467 stars 147 forks source link

assistant response shouldn't be allowed to play concurrently #47

Open proppy opened 7 years ago

proppy commented 7 years ago

Currently if pressing the button while the assistant response is playing, a new request will be recorded and there is a possibility that the response audio will play on top of each other.

We should either interrupt the assistant response playback or queue them.

@Fleker what do you think?

Fleker commented 7 years ago

I think if we interrupt the Assistant mid-playback, it should remove audio from the previous response. That's the behavior Google Home and other devices use.

We could put each audio sample into a queue perhaps and then wipe it. Right now we call mAudioTrack.write. Is there a way to stop the audio track or clear its internal queue?

proppy commented 7 years ago

Sound fesable https://developer.android.com/reference/android/media/AudioTrack.html#stop():

For an immediate stop, use pause(), followed by flush() to discard audio data that hasn't been played back yet.