Fix TTS audio routing for Android Auto
Set AudioAttributes (USAGE_ASSISTANT) on the TTS engine itself, not just on the AudioFocusRequest. Without this, TTS output goes to the phone speaker instead of routing through Android Auto's head unit.
This commit is contained in:
@@ -52,6 +52,8 @@ class TTSManager(
|
|||||||
tts = TextToSpeech(context) { status ->
|
tts = TextToSpeech(context) { status ->
|
||||||
if (status == TextToSpeech.SUCCESS) {
|
if (status == TextToSpeech.SUCCESS) {
|
||||||
tts?.language = Locale.US
|
tts?.language = Locale.US
|
||||||
|
// Route TTS audio through Android Auto head unit
|
||||||
|
tts?.setAudioAttributes(audioFocusRequest.audioAttributes)
|
||||||
tts?.setOnUtteranceProgressListener(object : UtteranceProgressListener() {
|
tts?.setOnUtteranceProgressListener(object : UtteranceProgressListener() {
|
||||||
override fun onStart(utteranceId: String?) {
|
override fun onStart(utteranceId: String?) {
|
||||||
LatencyTracker.markT5() // t5: First audio frame
|
LatencyTracker.markT5() // t5: First audio frame
|
||||||
|
|||||||
Reference in New Issue
Block a user