I created a custom TTS node and overwrote it. Howe...
# ask-ai
m
I created a custom TTS node and overwrote it. However now .say does not work for me- it reports in the speech handler that it completes instantly when I try to use session.say. .generate_reply works fine. Thoughts?
t
Thanks for reaching out, Alexander. 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
.say
completing instantly while
.generate_reply
works as expected. This usually points to something with how your custom TTS node is set up or implemented. Let's walk through some steps together to troubleshoot this: 1. Verify TTS Node Integration: Please double-check that your custom TTS node is correctly configured to return an
AsyncIterable[rtc.AudioFrame]
. If your TTS doesn’t support streaming, try wrapping it with a
StreamAdapter
and a sentence tokenizer to help manage that. 2. Check Agent Initialization: Make sure your agent session is initialized with a valid TTS plugin. For example:
session = AgentSession(llm=llm_instance, tts=YourTTSPlugin())
This ensures the TTS is properly linked. 3. Monitor Events: Keep an eye on the
agent_state_changed
event — it should switch to "speaking" after you call
.say
. Also, listen for the
speech_created
event with
source="say"
to confirm the TTS task has started. 4. Test with Pre-Synthesized Audio: To isolate the issue, try using the
audio
parameter in
session.say()
to supply some pre-synthesized audio. This can help determine if the problem is with audio generation or elsewhere. 5. Inspect Custom Overrides: If you’ve overridden the
tts_node
, please ensure it correctly forwards the audio output. A proper override might look like this:
Copy code
def tts_node(self, text: AsyncIterable[str], model_settings: ModelSettings):
    return Agent.default.tts_node(self, text, model_settings)
I hope these steps help you pinpoint and fix the issue. If you run into any roadblocks or have more questions, please don’t hesitate to reach out—I’m here to help! Sources: Pipeline nodes and hooks | LiveKit Docs | agents/src/voice/agent.ts | Agent speech and audio | LiveKit Docs | Events and error handling | LiveKit Docs | Realtime model plugins | LiveKit Docs