jolly-eve-3916
08/26/2025, 7:04 PMtall-airline-16756
08/26/2025, 7:04 PMtall-airline-16756
08/26/2025, 7:04 PMSynthesizeStream method. The word_tokenizer parameter helps split the text into individual words or chunks you define. Each chunk is sent as a JSON message to Deepgram, and a Flush message makes sure the audio is fully synthesized before moving on to the next piece.
If you notice any sudden changes in speed or tone at the chunk boundaries, it might be related to how the text is chunked or tokenized. Tweaking the chunk size or adding prompts to guide speech features like filler words or natural pauses can really help smooth things out.
Feel free to reach out if you want more details or a hand with the setup—I’m here to help!
Sources: examples/other/text-to-speech/elevenlabs_tts.py | Deepgram TTS integration guide | LiveKit Docs | Deepgram TTS integration guide | LiveKit Docs | TTS | LiveKit Agentsjolly-eve-3916
08/26/2025, 7:06 PMjolly-eve-3916
08/26/2025, 7:06 PMtall-airline-16756
08/26/2025, 7:07 PMawait session.say("One moment please... um, let me check that for you.")
Deepgram's TTS models are pretty great at picking up informal speech patterns naturally, so adding filler words like "um" or "uh," or punctuation like ellipses "..." or commas, helps make the speech sound smoother and more natural.
If you're looking for more control, Deepgram also supports text-based prompts that let you influence things like vocal expressiveness, pauses, and intonation. You can check out their Text-to-Speech Prompting Guide for all the details on how to use these features.
Feel free to reach out if you want a hand setting this up or have any other questions!
Sources: Deepgram TTS integration guide | LiveKit Docs | Deepgram TTS integration guide | LiveKit Docs | Deepgram integration guide | LiveKit Docsjolly-eve-3916
08/26/2025, 7:08 PMtall-airline-16756
08/26/2025, 7:08 PMjolly-eve-3916
08/26/2025, 7:15 PMWordTokenizer groups text before sending it to the TTS engine.
Option 1: Use SentenceTokenizer Instead
The most effective approach is to replace the default WordTokenizer with a SentenceTokenizer, which will create much larger chunks based on sentences rather than individual words: basic.py:34-48
from livekit.agents import tokenize
from livekit.plugins import deepgram
# Use sentence-based chunking instead of word-based
sentence_tokenizer = tokenize.basic.SentenceTokenizer(min_sentence_len=50)
tts = deepgram.TTS(word_tokenizer=sentence_tokenizer)
Option 2: Modify WordTokenizer Settings
You can adjust the WordTokenizer parameters to create larger word groups: basic.py:72-76
# Create larger word chunks by ignoring punctuation
custom_tokenizer = tokenize.basic.WordTokenizer(
ignore_punctuation=True, # This prevents breaking on punctuation
split_character=False # This prevents character-level splitting
)
tts = deepgram.TTS(word_tokenizer=custom_tokenizer)
Option 3: Custom Chunking Implementation
For maximum control, you could implement a custom tokenizer that groups multiple sentences or paragraphs together, similar to how the RAG example handles text chunking: rag_db_builder.py:112-131
The key insight is that in the Deepgram TTS streaming implementation, each WordStream object becomes a separate speech segment: tts.py:231-244
By using a SentenceTokenizer or modifying the WordTokenizer settings, you'll reduce the number of separate segments sent to Deepgram, which should minimize the abrupt speed/tonality changes you're experiencing at chunk boundaries.
Notes
The default Deepgram TTS configuration uses WordTokenizer(ignore_punctuation=False), which creates very small chunks (individual words). tts.py:81-82 Switching to sentence-based chunking or adjusting punctuation handling will create significantly larger, more natural-sounding speech segments.jolly-eve-3916
08/26/2025, 7:41 PM