I have the following issue with my livekit app. I'...
# ask-ai
r
I have the following issue with my livekit app. I'm using the Google TTS plugin to generate the audio of my pipeline Agent, but I want to use the streaming mode. this is my object definition: google.TTS( language=tts_data['language'], voice_name=f"{tts_data['language']}-{tts_data['voice']}", audio_encoding=texttospeech.AudioEncoding.OGG_OPUS, use_streaming=True ) But when the agent starts I get this TTS metric values with the streamed=False flag: 2025-10-29T153013.141472527Z Job AJ_hoH6dq2pAMGd - CALLID c425b983-2f7e-123f-8ca8-fea681b75b24 - Metric entry - TTSMetrics(type='tts_metrics', label='livekit.plugins.google.tts.TTS', request_id='bfcb63efce63', timestamp=1761751813.1408274, ttfb=1.2212748359888792, duration=1.3188572339713573, audio_duration=7.640000000000004, cancelled=False, characters_count=113, streamed=False, segment_id=None, speech_id='speech_c0e557b8a623') 2025-10-29T153013.141768222Z Job AJ_hoH6dq2pAMGd - CALLID c425b983-2f7e-123f-8ca8-fea681b75b24 - TTFB 1.2212748359888792 2025-10-29T153014.540633424Z Job AJ_hoH6dq2pAMGd - CALLID c425b983-2f7e-123f-8ca8-fea681b75b24 - Discarded metric entry - TTSMetrics(type='tts_metrics', label='livekit.plugins.google.tts.TTS', request_id='090059a1557c', timestamp=1761751814.5400617, ttfb=1.2733118049800396, duration=1.389344573020935, audio_duration=8.240000000000002, cancelled=False, characters_count=130, streamed=False, segment_id=None, speech_id='speech_c0e557b8a623') 2025-10-29T153014.919730494Z Job AJ_hoH6dq2pAMGd - CALLID c425b983-2f7e-123f-8ca8-fea681b75b24 - Metric entry - LLMMetrics(type='llm_metrics', label='livekit.agents.llm.fallback_adapter.FallbackAdapter', request_id='chatcmpl-CW2PivbRRO0hDREOz2P6KPSzIIJ58', timestamp=1761751814.9193091, duration=4.09461035951972, ttft=0.6062219720333815, cancelled=False, completion_tokens=119, prompt_tokens=606, prompt_cached_tokens=0, total_tokens=725, tokens_per_second=29.062594374415195, speech_id='speech_c0e557b8a623') 2025-10-29T153014.919831975Z Job AJ_hoH6dq2pAMGd - CALLID c425b983-2f7e-123f-8ca8-fea681b75b24 - TTFT 0.6062219720333815 2025-10-29T153015.908967789Z Job AJ_hoH6dq2pAMGd - CALLID c425b983-2f7e-123f-8ca8-fea681b75b24 - Discarded metric entry - TTSMetrics(type='tts_metrics', label='livekit.plugins.google.tts.TTS', request_id='f34f20e521b5', timestamp=1761751815.908428, ttfb=1.2520854119211435, duration=1.3581376168876886, audio_duration=8.200000000000003, cancelled=False, characters_count=112, streamed=False, segment_id=None, speech_id='speech_c0e557b8a623') 2025-10-29T153017.054921837Z Job AJ_hoH6dq2pAMGd - CALLID c425b983-2f7e-123f-8ca8-fea681b75b24 - Discarded metric entry - TTSMetrics(type='tts_metrics', label='livekit.plugins.google.tts.TTS', request_id='cfb79d955a71', timestamp=1761751817.0542965, ttfb=1.0519493408501148, duration=1.1343131605535746, audio_duration=6.480000000000003, cancelled=False, characters_count=110, streamed=False, segment_id=None, speech_id='speech_c0e557b8a623') 2025-10-29T153018.121687907Z Job AJ_hoH6dq2pAMGd - CALLID c425b983-2f7e-123f-8ca8-fea681b75b24 - Discarded metric entry - TTSMetrics(type='tts_metrics', label='livekit.plugins.google.tts.TTS', request_id='ffb595d08149', timestamp=1761751818.1211848, ttfb=0.9845251198858023, duration=1.0563703756779432, audio_duration=5.920000000000003, cancelled=False, characters_count=98, streamed=False, segment_id=None, speech_id='speech_c0e557b8a623') 2025-10-29T153049.535599860Z Job AJ_hoH6dq2pAMGd - CALLID c425b983-2f7e-123f-8ca8-fea681b75b24 - Conversation Item Added: Role=assistant, ID=item_dd70358d00e0 - Item Content: ['Claro, Alejandro. TCP/IP es un conjunto de protocolos que facilita la comunicación entre dispositivos en una red. TCP se encarga de asegurar la entrega correcta de datos, mientras que IP se encarga de dirigir esos datos a la dirección correcta. TCP divide los datos en paquetes, los envía, y los vuelve a ensamblar en el destino, garantizando su integridad. IP se ocupa de enrutar esos paquetes a través de diferentes caminos en la red para llegar al destino correcto. Es como una oficina de correos que asegura que tus mensajes lleguen completos y al lugar indicado.'] - Latency data: EOU 0 TTFB 1.2212748359888792 TTFT 0.6062219720333815 Latency 1.8274968080222607 Why is the TTS not streaming the audio?
t
Thanks for reaching out, Alejandro. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm sorry to hear you're having trouble with the Google TTS plugin not streaming audio even after setting
use_streaming=True
. Let's work through this together! Here are some helpful steps you can try to get things back on track: 1. SSML Compatibility: Make sure
enable_ssml=False
when using
use_streaming=True
, since Google's streaming API doesn’t support SSML input. This little detail can make a big difference! 2. Audio Encoding: Double-check that your
audio_encoding
is set to either
OGG_OPUS
or
PCM
, as these are the formats required for streaming. 3. Authentication: It’s important to confirm your credentials are set up correctly and have the right permissions. Whether you’re using a credentials file, dictionary, or Application Default Credentials, this step ensures smooth access. 4. Location Parameter: Take a look at the
location
parameter. If it’s anything other than "global," remember the API endpoint changes to
{location}-texttospeech.googleapis.com
. 5. Input Validation: Try testing with simple plain text first and avoid SSML tags. Also, ensure your text is UTF-8 compatible and formatted properly to prevent hiccups. 6. Network Connectivity: Sometimes network issues or firewall restrictions can block the streaming API endpoint. It’s worth verifying that your connection allows this traffic. 7. Monitor Logs: Keep an eye on your logs for any warnings or errors, like encoding fallback warnings or API timeout messages. These clues can be really helpful in pinpointing the issue. Give these a try, and please don’t hesitate to reach out if the problem continues or if you’d like me to walk you through any of these steps. I’m here to help! Sources: examples/other/text-to-speech/rime_tts.py | Google Cloud TTS integration guide | LiveKit Docs
r
No, you missunderstood. The Google TTS plugin is sending audio back, no issues, but its not sending in streaming mode (check the streamed=False on the log TTSMetrics(type='tts_metrics', label='livekit.plugins.google.tts.TTS', request_id='bfcb63efce63', timestamp=1761751813.1408274, ttfb=1.2212748359888792, duration=1.3188572339713573, audio_duration=7.640000000000004, cancelled=False, characters_count=113, streamed=False, segment_id=None, speech_id='speech_c0e557b8a623'))
t
It looks like the
streamed=False
flag in the TTSMetrics is showing because the TTS plugin is switching to non-streaming mode, even though you have
use_streaming=True
set. This usually happens when some features that aren’t compatible with streaming are turned on: 1. SSML: Please make sure
enable_ssml=False
, since SSML isn’t supported in streaming mode. 2. Markup: Also, check that
use_markup=False
, because markup (which is used for HD voices) doesn’t work with streaming either. Once both
enable_ssml
and
use_markup
are turned off, the plugin should work in streaming mode, and you’ll see
streamed=True
in your TTSMetrics logs. Also, double-check that you’re using the
tts.stream()
method instead of
tts.synthesize()
, as the former is what enables streaming explicitly. Please feel free to reach out if this doesn’t solve the problem or if you need any more help—I’m here for you! Sources: livekit-agents/livekit/agents/tts/fallback_adapter.py | Logs, metrics, and telemetry | LiveKit Docs
r
both enable_ssml and use_markup are False by default and they are not activated on my code, so they should remain False, that is not the issue. I'm not using
tts.stream()
or
tts.synthesize()
methods. I'm just using an AgentSession with the TTS configuration google.TTS( language=tts_data['language'], voice_name=f"{tts_data['language']}-{tts_data['voice']}", audio_encoding=texttospeech.AudioEncoding.OGG_OPUS, use_streaming=True ) As you can see the audio encoding is properly set, the streaming is set to true and the voice I will be using is Chirp3-HD-Achernar.
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
r
The issue is with the fallback adapter tts.FallbackAdapter, it prevents the streaming mode from functioning
do you know why the FallbackAdapter prevents it?