what is wordtokenizer in deepgram tts
# ask-ai
j
what is wordtokenizer in deepgram tts
t
Thanks for reaching out, Albert. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Think of the word tokenizer in Deepgram TTS as a helpful little tool that breaks your text into individual words or tokens. This step is super important because it helps organize the text before turning it into speech. Deepgram TTS uses a
WordTokenizer
from the
tokenize
module to create a word stream that processes text bit by bit, which is especially handy for streaming synthesis. This tokenizer comes with handy methods like
tokenize()
, which splits your text into words, and
stream()
, which sets up a
WordStream
to handle the text in manageable chunks. By default, it’s set with
ignore_punctuation=False
, so punctuation stays in place during tokenization. This little detail helps keep the speech sounding natural and supports smooth, real-time text-to-speech conversion. Sources: AgentTranscriptionOptions | LiveKit Agents | WordTokenizer | LiveKit Agents | tests/test_tts.py | WordTokenizer | LiveKit Agents | plugins/elevenlabs/src/tts.ts
j
do i need to use it?
t
Just so you know, using the
WordTokenizer
in Deepgram TTS isn’t something you have to do. If you don’t provide a custom tokenizer, no worries—the system will automatically use a default
WordTokenizer
that keeps punctuation intact. This way, your text gets processed properly for speech synthesis without you needing to do any extra setup. Sources: livekit-plugins/livekit-plugins-elevenlabs/livekit/plugins/elevenlabs/tts.p...
j
is this or not good for deepgram tts? _word_tokenizer_=tokenize.basic.SentenceTokenizer(_min_sentence_len_=1000), # Much larger chunks for even smoother audio
t
Just a heads-up: using
SentenceTokenizer
with
min_sentence_len=1000
doesn’t quite work with Deepgram TTS. That’s because Deepgram TTS uses a
WordTokenizer
to handle text word by word, which is super important for how it streams the speech. So, things like sentence-level tokenization or settings like
min_sentence_len
won’t really affect how Deepgram TTS works. Sources: tests/test_tokenizer.py
j
so should i just delete that? and let deepgram handle it naturally?
t
Absolutely! You can go ahead and remove the
SentenceTokenizer
configuration and let Deepgram take care of the text processing on its own. It’ll automatically use its built-in
WordTokenizer
, which is designed to work seamlessly with streaming synthesis and helps keep your audio generation nice and smooth—no extra setup needed.