My agent voice is breaking up during speech time t...
# ask-ai
f
My agent voice is breaking up during speech time to time. I use google.TTS Chirp3-HD. What are the ways to rectify that?
t
Thanks for reaching out, Taras. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I understand how frustrating voice breaking issues with Google TTS Chirp3-HD can be, but don’t worry—we’re here to help you through it! Here are some friendly steps you can try: 1. Adjust Audio Encoding and Sample Rate: Try switching the
audio_encoding
parameter to
PCM
or
LINEAR16
to improve audio quality. Playing around with sample rates like 16000 Hz or 48000 Hz might also make a difference. 2. Tune Speech Parameters: It’s a good idea to check that your
pitch
,
speaking_rate
, and
volume_gain_db
are within recommended ranges. For example, keeping
volume_gain_db
below +10 dB usually helps avoid distortion. 3. Enable SSML: Using SSML tags like
<break time="500ms"/>
can give you better control over pauses and intonation. Just a heads-up—SSML works best when
use_streaming
is turned off. 4. Segment Input Text: If you’re working with longer texts, try breaking them into smaller sentences with a sentence tokenizer. This often leads to smoother speech output. 5. Verify Voice and Language Settings: Double-check that your
voice_name
is set to
en-US-Chirp3-HD-Charon
and that the language and gender settings align with what you want. 6. Check Network Stability: If you’re using streaming synthesis, a stable network connection is key. If problems persist, consider disabling
use_streaming
and switching to batch synthesis instead. If you’re still experiencing issues after trying these tips, it might help to confirm that the Chirp3-HD model is properly set up in your Google Cloud project. Testing with a simple example outside of LiveKit can also help identify where the problem might be. Sources: examples/other/text-to-speech/rime_tts.py | Troubleshooting & Common Issues | livekit/livekit_composite | DeepWiki | Live Conversations with AI using ChatGPT and WebRTC | Google Cloud TTS integration guide | LiveKit Docs
f
Provide more details on 4. Segment Input Text
t
To help you avoid any voice breaking, it’s really important to segment your input text properly. Let me walk you through the details: Default Sentence Tokenizer The Google TTS plugin uses a sentence tokenizer to split long text into smaller, natural-sounding segments. By default, it uses the
blingfire
sentence tokenizer. This approach helps the speech synthesis process handle manageable chunks, keeping the intonation and pacing feeling natural. Basic Usage Here’s a simple way to use the
StreamAdapter
wrapper to manage streaming input with proper segmentation:
Copy code
from livekit.agents.tokenize import blingfire
from livekit.plugins import google

tokenizer = blingfire.SentenceTokenizer()
tts = google.TTS()
tts_stream = tts.stream()  # Enables streaming synthesis
Then, you can push text in chunks and call
end_input()
when you’re done:
Copy code
for sentence in text.split('. '):
    tts_stream.push_text(sentence + '.')
    await asyncio.sleep(0.1)  # Simulate incremental input

tts_stream.end_input()
Custom Sentence Tokenizer If you want more control, you can create a custom tokenizer. For example:
Copy code
from livekit.agents import tokenize
import nltk

class CustomSentenceTokenizer(tokenize.SentenceTokenizer):
    def tokenize(self, text: str) -> list[str]:
        sentences = nltk.tokenize.sent_tokenize(text, 'english')
        return sentences
Then, simply pass this tokenizer to your TTS instance:
Copy code
tts = google.TTS(tokenizer=CustomSentenceTokenizer())
Best Practices • Segment by sentences to allow for natural pauses. • Combine very short sentences to prevent choppy output. • Use language-specific rules for identifying sentence boundaries. • Maintain context between chunks to ensure coherent pronunciation. By following these steps, you’ll enjoy smooth and natural speech synthesis without any voice breaking. If you have any questions or need further help, feel free to ask—I’m here to support you! Sources: livekit-plugins/livekit-plugins-upliftai/livekit/plugins/upliftai/tts.py | Live Conversations with AI using ChatGPT and WebRTC