Decrease the stream volume and Increase TTS volume at the same time
I had this Android application that talk with TTS every time and uses streaming music (spotify). So, I need to decrease the volume and increase the TTS
I use this code but this decrease the tts as well.
AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,[int value],[if desired a flag]);
Any way to decrease only spotify like stream music .
in Java/android.
What you want to do is know as 'audio ducking'
Here's some sample code:
You'll have to delete my custom logging.
Call
duckAudioMedia
as the TTS starts andabandonAudioMedia
when the utterance is complete.