most-vr-18651
08/05/2025, 10:00 AMChatCLI -> AgentSession -> TranscriptSynchronizer -> ChatCLI
2025-08-05 024332,317 - DEBUG livekit.agents - using transcript io: AgentSession -> TranscriptSynchronizer -> ChatCLI
2025-08-05 024332,318 - ERROR livekit.agents - unhandled exception while running the job task
Traceback (most recent call last):
File "C:\Users\dell\anaconda3\envs\publicaai\Lib\site-packages\opentelemetry\util\_decorator.py", line 71, in async_wrapper
return await func(*args, **kwargs) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\dell\anaconda3\envs\publicaai\Lib\site-packages\livekit\agents\ipc\job_proc_lazy_main.py", line 240, in _traceable_entrypoint
await self._job_entrypoint_fnc(job_ctx)
File "C:\Users\dell\Documents\friday_jarvis\agent.py", line 40, in entrypoint
await session.say(
~~~~~~~~~~~^
"Welcome! I'm here to help. Please ask me anything.",
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
allow_interruptions=False
^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "C:\Users\dell\anaconda3\envs\publicaai\Lib\site-packages\livekit\agents\voice\agent_session.py", line 685, in say
handle = self._activity.say(
text,
...<2 lines>...
add_to_chat_ctx=add_to_chat_ctx,
)
File "C:\Users\dell\anaconda3\envs\publicaai\Lib\site-packages\livekit\agents\voice\agent_activity.py", line 662, in say
raise RuntimeError("trying to generate speech from text without a TTS model")
RuntimeError: trying to generate speech from text without a TTS model
this is the code causing the error :
from dotenv import load_dotenv
from livekit import agents
from livekit.agents import AgentSession, Agent, RoomInputOptions, RoomOutputOptions
# from livekit.plugins import (
# noise_cancellation,
# )
from livekit.plugins import google, openai, silero
from prompts import AGENT_INSTRUCTION, SESSION_INSTRUCTION
from livekit.agents.llm import RealtimeCapabilities
from tools import get_weather, search_web, send_email
load_dotenv()
class Assistant(Agent):
def __init__(self) -> None:
super().__init__(
instructions=AGENT_INSTRUCTION,
tools=[
get_weather,
search_web,
send_email
],
)
async def entrypoint(ctx: agents.JobContext):
session = AgentSession(
llm=openai.realtime.RealtimeModel(),
vad=silero.VAD.load()
)
await session.start(
room=ctx.room,
agent=Assistant()
)
await session.say(
"Welcome! I'm here to help. Please ask me anything.",
allow_interruptions=False
)
if name == "__main__":
agents.cli.run_app(agents.WorkerOptions(entrypoint_fnc=entrypoint))tall-airline-16756
08/05/2025, 10:00 AMtall-airline-16756
08/05/2025, 10:01 AMpip install "livekit-agents[elevenlabs]"
3. Import the TTS Module: For ElevenLabs, use:
from livekit.plugins.elevenlabs import TTS
4. Initialize the TTS Instance: Configure it with your API credentials and settings. Example for ElevenLabs:
tts = TTS(
api_key="your_api_key",
voice="voice_id"
)
5. Pass the TTS Instance to AgentSession: Update your session initialization:
session = AgentSession(
llm=openai.realtime.RealtimeModel(),
vad=silero.VAD.load(),
tts=tts
)
6. Use the say Method: You can now call:
await session.say("Welcome! I'm here to help.")
Replace placeholders like your_api_key with your actual credentials. Let me know if you need further assistance!most-vr-18651
08/05/2025, 10:04 AMtall-airline-16756
08/05/2025, 10:05 AMfrom livekit.agents import APIConnectOptions
conn_options = APIConnectOptions(
timeout=10.0, # Connection timeout in seconds
max_retry=3, # Number of retries
retry_interval=1.0 # Interval between retries
)
2. Custom HTTP Client: You can also use a custom HTTP client with longer timeout settings like this:
import httpx
from livekit.plugins import openai as lk_openai
custom_client = openai.AsyncClient(
http_client=httpx.AsyncClient(
timeout=httpx.Timeout(connect=30.0, read=15.0, write=15.0, pool=10.0),
follow_redirects=True
)
)
tts = lk_openai.TTS(client=custom_client)
3. Disable Turn Detection: That warning pops up because server-side turn detection doesn’t play well with allow_interruptions=False. To fix this, turn off turn detection in the RealtimeModel and use VAD instead.
4. Check API Status: It’s always good to double-check that OpenAI’s API is up and running smoothly and that your internet connection is stable.
5. Test Configuration: Run a quick test script to make sure your timeout settings are working as you expect.
If you hit any snags or want a hand with anything else, just let me know—I’m here to help! Sources: livekit-plugins/livekit-plugins-inworld/livekit/plugins/inworld/tts.py