How to know if there is a TTS model inside a tool ...
# ask-ai
f
How to know if there is a TTS model inside a tool call ?
t
Thanks for reaching out, Dmitry. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I’d love to help clarify this for you! In LiveKit, tool calls don’t automatically use TTS (Text-to-Speech) models. Instead, TTS is set up at the agent or session level and comes into play by converting the agent’s text responses into speech after a tool call has run. If you’re looking to have speech happen during or right after a tool call, you can use methods like
session.say()
or
agent.say()
directly within the tool’s execution function to create that TTS output. Would you like me to walk you through how to use these methods step-by-step to get speech working during a tool call? I’m here to help! Sources: Text-to-speech (TTS) models | LiveKit Docs | agent.py | livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | examples/src/basic_tool_call_agent.ts
f
when I am using realtime model it fails to call session.say()
t
I understand that the
session.say()
method might not work as expected when using a realtime model, and I'm here to help clarify why. Realtime models handle speech generation internally, so they don’t rely on a separate TTS plugin. Instead, a great way to get speech output is by using the
generate_reply()
method, which works perfectly with realtime models. Let me walk you through how you can use
generate_reply()
step-by-step: 1. First, initialize your realtime model with the parameters you want, like voice and modalities. For example:
Copy code
from livekit.plugins.openai import realtime
model = realtime.RealtimeModel(
    voice="sage", 
    modalities=["audio"], 
    instructions="You are a helpful assistant."
)
2. Next, create and start an
AgentSession
using the realtime model:
Copy code
from livekit.agents import AgentSession
session = AgentSession(llm=model)
await session.start()
3. Finally, you can trigger speech output by calling
generate_reply()
like this:
await session.generate_reply(instructions="Greet the user warmly.")
If you have any questions or need help tailoring this to your specific needs, please don’t hesitate to reach out. I’m here to support you! Sources: Agent speech and audio | LiveKit Docs | sip-refer/agent.py | livekit-agents/livekit/agents/llm/realtime.py | Realtime model plugins | LiveKit Docs
f
can I use RunContext to know if there is TTS model ?
t
I understand that figuring out whether a TTS model is configured can be a bit tricky. Just to clarify, RunContext isn’t really the right tool for this since it’s meant to provide real-time info during an agent session and doesn’t have access to configuration details like the TTS model setup. But no worries! You can easily check if a TTS model is available by looking at the
agent.tts
property. This will give you the configured TTS object or
None
if there isn’t one set up. Here’s a quick example:
Copy code
if agent.tts is not None:
    print("TTS model is configured")
else:
    print("No TTS model is configured")
If you have any more questions or need a hand with this, just let me know—I’m here to help! Sources: agents/src/inference/tts.ts | Text-to-speech (TTS) models | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_activity.py | complex-agents/medical_office_triage/triage.py