colossal-manchester-31772
08/26/2025, 7:37 AMtall-airline-16756
08/26/2025, 7:37 AMtall-airline-16756
08/26/2025, 7:37 AMstream() method on that TTS instance to get a SynthesizeStream. This stream lets you send text in and get back the synthesized audio frames.
3. Then, push your text into the stream with push_text(), and when you’re done, call end_input() to finish up the synthesis.
4. Finally, you can grab the audio frames from the stream (they come as SynthesizedAudio) and choose to save them to a file or buffer instead of sending them straight to a participant.
Here’s a quick example to show you what I mean:
from livekit.agents.tts import SynthesizedAudio
from livekit.plugins import cartesia
from typing import AsyncIterable
tts = cartesia.TTS(model="sonic-english")
tts_stream = tts.stream()
# Collect audio frames without playing
audio_frames = []
async for text in ["Hello, this is a test message."]:
tts_stream.push_text(text)
tts_stream.end_input()
async for audio_data in tts_stream:
if isinstance(audio_data, SynthesizedAudio):
audio_frames.append(audio_data.audio.frame)
This way, you have complete control over the audio you generate—you can process it, save it, or play it however you like, instead of having it automatically play in the room.
Sources: plugins/cartesia/src/tts.tscolossal-manchester-31772
08/26/2025, 7:45 AMcolossal-manchester-31772
08/26/2025, 7:46 AMtall-airline-16756
08/26/2025, 7:46 AMsynthesize() method. It gives you a ChunkedStream object with the audio data, which you can gather into a complete audio frame to use later—no playback needed. Here’s a quick example:
audio_stream = tts.synthesize("Hello, world!")
audio_frame = await audio_stream.collect()
Once you have the audio_frame, you can save it or use it whenever you want, without triggering any sound.
1. You can also turn off audio output by setting audio_enabled=False in RoomOutputOptions. This way, the agent handles text-to-speech behind the scenes without playing it, but still keeps text-only output in sync.
Both of these options give you the flexibility to work with the audio exactly how you need. If you want to chat more about it or need help setting it up, just let me know!
Sources: examples/other/text-to-speech/README.md | Text-to-speech (TTS) integrations | LiveKit Docs | Text and transcriptions | LiveKit Docs | StreamAdapter | LiveKit Agents | TTS | LiveKit Agentstall-airline-16756
08/26/2025, 7:46 AMsession.say() function in LiveKit is mainly built to create speech and play it right away for the user. It doesn’t really support just generating the audio without playing it, since it’s designed to do both at the same time.
If you’re looking to generate audio without having it play immediately, no worries! You can use the standalone TTS feature instead. That means you’d create a TTS instance and use the stream() or synthesize() methods to generate the audio frames. From there, you can handle or save the audio however you like. This way, you get full control over the audio without it automatically playing.
If you want, I’m here to help you set this up or answer any questions you have about it!
Sources: Agent speech and audio | LiveKit Docs | Agent speech | LiveKit Docs | Text-to-speech (TTS) integrations | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_activity.pycolossal-manchester-31772
08/26/2025, 7:47 AMtall-airline-16756
08/26/2025, 7:47 AM