Here's a question you can ask LiveKit's support ag...
# ask-ai
e
Here's a question you can ask LiveKit's support agent: --- Subject: Cartesia TTS receiving empty text despite proper text processing in tts_node override Hi LiveKit Support, I'm experiencing persistent Cartesia TTS errors with the message "transcript empty or contains only punctuation: first transcript for WS is empty or contains only punctuation" even though my text processing appears to be working correctly. What I'm seeing in the logs: 1. Text is being processed correctly in my
tts_node
override: -
:arrows_counterclockwise: TTS CHUNK: 'Of course. No problem. I totally understand. Thanks for your time today.' (length: 72)
-
:white_check_mark: BUFFER VALID: 'Of course. No problem. I totally understand. Thanks for your time today.' (length: 72) - SENDING TO CARTESIA
-
:arrows_counterclockwise: TTS NODE FINAL TEXT: 'Of course. No problem. I totally understand. Thanks for your time today.'
2. But then Cartesia receives empty text: -
:arrows_counterclockwise: TTS NODE FINAL TEXT: ''
(empty!) - Cartesia error: "transcript empty or contains only punctuation" My current setup: - Using LiveKit Cloud with Cartesia TTS - Implemented
tts_node
override with text buffering and validation - Text is being processed and validated correctly before reaching Cartesia Questions: 1. Why would Cartesia receive empty text when my
tts_node
override shows the text is being processed correctly? 2. Could there be multiple TTS calls happening, with the second one being empty? 3. Is there a timing issue where empty text is sent before the actual text arrives? 4. Should I be using a different approach for text streaming with Cartesia? Code snippet of my tts_node override:
Copy code
python
async def tts_node(self, text, model_settings):
    # ... text processing and buffering logic ...
    # Text is validated and collected correctly
    # But Cartesia still receives empty text
Any guidance on what might be causing this disconnect between my text processing and what Cartesia actually receives would be greatly appreciated. Thanks! --- This question provides all the context they need to understand the issue and should help them identify what's happening between your text processing and Cartesia receiving the text.
t
Thanks for reaching out, Jason. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm sorry to hear you're having trouble with Cartesia TTS receiving empty text, even though your
tts_node
override seems to be processing text correctly. Let's explore a few possibilities together that might help resolve this: • Improper Text Yielding: It’s important to double-check that your
tts_node
override is yielding the processed text properly. The default expects text segments to be yielded correctly. Here’s a gentle reminder of how that might look:
Copy code
async def tts_node(self, text: AsyncIterable[str], model_settings: ModelSettings):
    async for text_chunk in text:
        processed_text = your_text_processing(text_chunk)
        if processed_text.strip():  # Only yield non-empty text
            yield processed_text
• Text Pacing Interference: If you’re using text pacing, it’s worth ensuring it’s not unintentionally interfering with your custom node. Properly configuring the
SentenceStreamPacer
can really help manage the flow of text to the TTS engine smoothly. • Text Processing Logic: Sometimes, the text processing steps might accidentally strip out all content. It’s a good idea to verify that any replacements or modifications still leave you with meaningful, non-empty text. • Fallback to Default Implementation: If you’d like, you can always fall back on the default implementation to make sure everything behaves as expected. Here’s a helpful example:
Copy code
async def tts_node(self, text: AsyncIterable[str], model_settings: ModelSettings):
    async def process_text():
        async for text_chunk in text:
            processed = your_processing(text_chunk)
            if processed.strip():
                yield processed

    async for audio_frame in Agent.default.tts_node(self, process_text(), model_settings):
        yield audio_frame
To get to the bottom of this, adding some structured logging could be a great step. It’ll help you trace exactly where the text might be getting lost or turning empty. Please feel free to reach out if you’d like more guidance—I’m here to help! Sources: Modifying LLM output before TTS | LiveKit Docs | examples/voice_agents/tts_text_pacing.py | plugins/cartesia/src/tts.test.ts | pipeline-tts/tts_node.py | Pipeline nodes and hooks | LiveKit Docs