busy-monitor-72069
09/04/2025, 10:29 PMtall-airline-16756
09/04/2025, 10:30 PMtall-airline-16756
09/04/2025, 10:31 PMvoice_cloning_key parameter in the Google TTS plugin. This means you can create speech with a custom voice model made through Google's Chirp 3 service—pretty cool, right?
Here’s a simple way to get started:
1. First, install the Google plugin by running: pip install "livekit-agents[google]~=1.2"
2. Create your custom voice with Google Cloud’s Chirp 3 service and grab your voice_cloning_key.
3. Authenticate with Google Cloud by either setting the GOOGLE_APPLICATION_CREDENTIALS environment variable or by passing credentials directly when you create the TTS instance.
4. Set up your TTS instance using your voice_cloning_key and any other settings you want, like sample rate.
5. Finally, use this TTS setup in your LiveKit AgentSession, and you’re good to go!
If you want to dive deeper into Chirp 3 and how voice cloning works, check out Google's documentation here: Chirp 3: Instant custom voice. It’s a great resource to help you along.
Sources: tests/test_stt.py | Google Cloud TTS integration guide | LiveKit Docs | Google Cloud TTS integration guide | LiveKit Docsbusy-monitor-72069
09/04/2025, 10:34 PMtall-airline-16756
09/04/2025, 10:34 PMen-US-Chirp3-HD-Charon, which belongs to the Chirp family—known for its high-quality, natural-sounding speech.
If you want to use the standard Chirp 3 model, here’s a quick way to set up your TTS instance:
from livekit.plugins import google
tts = google.TTS(
language="en-US",
gender="neutral",
voice_name="en-US-Chirp3-HD-Charon"
)
Just a heads up—the voice_cloning_key parameter is totally optional and only comes into play if you’re using custom cloned voices. If you leave it out, it’ll simply use standard voices like Chirp 3 by default.
Sources: livekit-plugins/livekit-plugins-lmnt/livekit/plugins/lmnt/tts.py | Google Cloud TTS integration guide | LiveKit Docsbusy-monitor-72069
09/04/2025, 10:37 PMtall-airline-16756
09/04/2025, 10:38 PMBackgroundAudioPlayer class to play some ambient noise (like static or poor connection sounds) alongside your TTS output. This way, it feels like the audio quality is a bit degraded, without actually changing the TTS stream itself.
Here’s a quick example:
from livekit.agents import BackgroundAudioPlayer, AudioConfig
import os
background_audio = BackgroundAudioPlayer(
ambient_sound=AudioConfig(
str(os.path.join(os.path.dirname(os.path.abspath(__file__)), "bg_noise.mp3")),
volume=0.8,
),
)
await background_audio.start(room=ctx.room, agent_session=session)
2. Customize the TTS Node: If you want to get a bit more hands-on, you can override the tts_node in a VoicePipelineAgent to add your own audio processing—like injecting synthetic noise or distortion right into the TTS audio frames.
Here’s how that might look:
async def tts_node(self, text: AsyncIterable[str], model_settings: ModelSettings) -> AsyncIterable[rtc.AudioFrame]:
async for frame in Agent.default.tts_node(self, text, model_settings):
noisy_frame = apply_noise_effect(frame) # Your custom function
yield noisy_frame
If you'd like, I can walk you through a detailed example of how to set up noise injection using either of these methods—just let me know!
Sources: Agent speech and audio | LiveKit Docs | Agent speech and audio | LiveKit Docs | tests/fake_tts.py | Docs::Agents | Noise & echo cancellation | LiveKit Docs