Can I choose the transcript generated in TTS? what...
# ask-ai
c
Can I choose the transcript generated in TTS? what if I want to pass metadata in the transcript, what to do?
t
Thanks for reaching out, Subham. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm glad you're exploring how to work with the transcript generated by the TTS system in LiveKit! While you can't embed metadata directly within the transcript text itself, there are some great ways to associate metadata alongside your transcript: • Log Metadata: You can use the
transcription_node
to log structured data like role, confidence, or session ID alongside each transcript chunk. This helps keep everything organized. • Publish Metadata: The
publishData()
method lets you send metadata as structured JSON to participants or other services, making sharing seamless. • Stream Text: With
streamText()
, you can write chunks and include metadata in attributes or topics, perfect for real-time streaming scenarios. If you're looking for precise timing details, you can enable TTS-aligned transcripts by setting
use_tts_aligned_transcript=True
in your configuration. This will give you word- or sentence-level timestamps, depending on the TTS model you’re using. Please feel free to reach out if you'd like more details or examples on how to implement any of these features—I’m here to help! Sources: Text and transcriptions | LiveKit docs | How to capture real-time agent transcriptions during conversations | Understanding Transcript Timing in Voice Conversations | packages/livekit-rtc/src/participant.ts | Pipeline nodes and hooks | LiveKit docs
c
Copy code
uv run python src/agent.py dev                                          38s py 3.12.3
2025-11-16 15:49:48,064 - DEBUG asyncio - Using selector: KqueueSelector 
2025-11-16 15:49:48,064 - DEV  livekit.agents - Watching /Users/subhamdas/self-nm/agent-starter-python/src 
2025-11-16 15:49:48,861 - DEBUG asyncio - Using selector: KqueueSelector 
2025-11-16 15:49:48,864 - INFO livekit.agents - starting worker {"version": "1.2.18", "rtc-version": "1.0.12"}
2025-11-16 15:49:48,864 - INFO livekit.agents - starting inference executor 
2025-11-16 15:49:48,867 - INFO livekit.agents - initializing process {"pid": 12975, "inference": true}
2025-11-16 15:49:49,611 - DEBUG livekit.agents - initializing inference runner {"runner": "lk_end_of_utterance_multilingual", "pid": 12975, "inference": true}
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
2025-11-16 15:49:50,689 - DEBUG livekit.agents - inference runner initialized {"runner": "lk_end_of_utterance_multilingual", "elapsed_time": 1.077446083072573, "pid": 12975, "inference": true}
2025-11-16 15:49:50,689 - INFO livekit.agents - process initialized {"pid": 12975, "inference": true, "elapsed_time": 1.82}
2025-11-16 15:49:50,689 - DEBUG asyncio - Using selector: KqueueSelector {"pid": 12975, "inference": true}
2025-11-16 15:49:50,764 - INFO livekit.agents - registered worker {"id": "AW_Gak2e4fswAMk", "url": "wss://qualif-u8qw08qc.livekit.cloud", "region": "India South", "protocol": 16}
2025-11-16 15:49:56,538 - INFO livekit.agents - received job request {"job_id": "AJ_byk49wvPQs8a", "dispatch_id": "AD_u5PD3L3MBsyu", "room_name": "playground-w0WQ-Y4n0", "agent_name": "", "resuming": false}
2025-11-16 15:49:56,566 - INFO livekit.agents - initializing process {"pid": 12978}
2025-11-16 15:49:57,448 - INFO livekit.agents - process initialized {"pid": 12978, "elapsed_time": 0.88}
2025-11-16 15:49:57,448 - DEBUG asyncio - Using selector: KqueueSelector {"pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:49:57,990 - DEBUG livekit.agents - input stream attached {"room": "playground-w0WQ-Y4n0", "participant": null, "source": "SOURCE_UNKNOWN", "accepted_sources": ["SOURCE_MICROPHONE"], "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:49:57,995 - DEBUG livekit.agents - using audio io: `RoomIO` -> `AgentSession` -> `TranscriptSynchronizer` -> `RoomIO` {"room": "playground-w0WQ-Y4n0", "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:49:57,995 - DEBUG livekit.agents - using transcript io: `AgentSession` -> `TranscriptSynchronizer` -> `RoomIO` {"room": "playground-w0WQ-Y4n0", "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:49:58,093 - DEBUG livekit.agents - start reading stream {"room": "playground-w0WQ-Y4n0", "participant": "identity-xd5h", "source": "SOURCE_MICROPHONE", "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:49:58,095 - DEBUG livekit.agents - http_session(): creating a new httpclient ctx {"room": "playground-w0WQ-Y4n0", "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:49:58,861 - INFO livekit.agents - TTS metrics {"room": "playground-w0WQ-Y4n0", "model_name": "eleven_flash_v2_5", "model_provider": "ElevenLabs", "ttfb": 0.40096941601950675, "audio_duration": 2.35, "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:50:01,207 - INFO livekit.agents - STT metrics {"room": "playground-w0WQ-Y4n0", "model_name": "Scribe", "model_provider": "ElevenLabs", "audio_duration": 1.17, "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:50:01,207 - DEBUG livekit.agents - received user transcript {"room": "playground-w0WQ-Y4n0", "user_transcript": "Mm.", "language": "eng", "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:50:01,210 - WARNING livekit.agents - _SegmentSynchronizerImpl.resume called after close {"room": "playground-w0WQ-Y4n0", "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:50:01,345 - INFO livekit.agents - Turn detector does not support language eng {"room": "playground-w0WQ-Y4n0", "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:50:01,346 - INFO livekit.agents - EOU metrics {"room": "playground-w0WQ-Y4n0", "model_name": "multilingual", "model_provider": "livekit", "end_of_utterance_delay": 0.58, "transcription_delay": 0.44, "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:50:01,603 - WARNING livekit.agents - failed to generate LLM completion, retrying in 0.1s
Traceback (most recent call last):
  File "/Users/subhamdas/self-nm/agent-starter-python/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py", line 190, in _main_task
    return await self._run()
           ^^^^^^^^^^^^^^^^^
  File "/Users/subhamdas/self-nm/agent-starter-python/.venv/lib/python3.12/site-packages/livekit/agents/inference/llm.py", line 341, in _run
    raise APIStatusError(
livekit.agents._exceptions.APIStatusError: Error code: 400 - {'error': {'message': "invalid JSON schema for tool end_call, tools[0].function.parameters: 'required' present but 'properties' is missing", 'type': 'invalid_request_error', 'param': 'tool end_call, tools[0].function.parameters'}} (status_code=400, request_id=req_01ka62vhp4fwbbh5aa1m0bf21n, body={'message': "invalid JSON schema for tool end_call, tools[0].function.parameters: 'required' present but 'properties' is missing", 'type': 'invalid_request_error', 'param': 'tool end_call, tools[0].function.parameters'}, retryable=True) {"room": "playground-w0WQ-Y4n0", "llm": "livekit.plugins.groq.services.LLM", "attempt": 1, "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:50:01,803 - WARNING livekit.agents - failed to generate LLM completion, retrying in 2.0s
Traceback (most recent call last):
  File "/Users/subhamdas/self-nm/agent-starter-python/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py", line 190, in _main_task
    return await self._run()
           ^^^^^^^^^^^^^^^^^
  File "/Users/subhamdas/self-nm/agent-starter-python/.venv/lib/python3.12/site-packages/livekit/agents/inference/llm.py", line 341, in _run
    raise APIStatusError(
livekit.agents._exceptions.APIStatusError: Error code: 400 - {'error': {'message': "invalid JSON schema for tool end_call, tools[0].function.parameters: 'required' present but 'properties' is missing", 'type': 'invalid_request_error', 'param': 'tool end_call, tools[0].function.parameters'}} (status_code=400, request_id=req_01ka62vhvzf50ag4nnfyfecamv, body={'message': "invalid JSON schema for tool end_call, tools[0].function.parameters: 'required' present but 'properties' is missing", 'type': 'invalid_request_error', 'param': 'tool end_call, tools[0].function.parameters'}, retryable=True) {"room": "playground-w0WQ-Y4n0", "llm": "livekit.plugins.groq.services.LLM", "attempt": 2, "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:50:01,940 - INFO livekit.agents - STT metrics {"room": "playground-w0WQ-Y4n0", "model_name": "Scribe", "model_provider": "ElevenLabs", "audio_duration": 1.2, "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:50:01,940 - DEBUG livekit.agents - received user transcript {"room": "playground-w0WQ-Y4n0", "user_transcript": "Dziękuję.", "language": "pol", "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:50:01,941 - INFO livekit.agents - Turn detector does not support language pol {"room": "playground-w0WQ-Y4n0", "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:50:01,949 - INFO livekit.agents - EOU metrics {"room": "playground-w0WQ-Y4n0", "model_name": "multilingual", "model_provider": "livekit", "end_of_utterance_delay": 1.17, "transcription_delay": 1.17, "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:50:02,022 - WARNING livekit.agents - failed to generate LLM completion, retrying in 0.1s
Traceback (most recent call last):
  File "/Users/subhamdas/self-nm/agent-starter-python/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py", line 190, in _main_task
    return await self._run()
           ^^^^^^^^^^^^^^^^^
  File "/Users/subhamdas/self-nm/agent-starter-python/.venv/lib/python3.12/site-packages/livekit/agents/inference/llm.py", line 341, in _run
    raise APIStatusError(
livekit.agents._exceptions.APIStatusError: Error code: 400 - {'error': {'message': "invalid JSON schema for tool end_call, tools[0].function.parameters: 'required' present but 'properties' is missing", 'type': 'invalid_request_error', 'param': 'tool end_call, tools[0].function.parameters'}} (status_code=400, request_id=req_01ka62vj38fwb80a279gjnwxj7, body={'message': "invalid JSON schema for tool end_call, tools[0].function.parameters: 'required' present but 'properties' is missing", 'type': 'invalid_request_error', 'param': 'tool end_call, tools[0].function.parameters'}, retryable=True) {"room": "playground-w0WQ-Y4n0", "llm": "livekit.plugins.groq.services.LLM", "attempt": 1, "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:50:02,230 - WARNING livekit.agents - failed to generate LLM completion, retrying in 2.0s
Traceback (most recent call last):
  File "/Users/subhamdas/self-nm/agent-starter-python/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py", line 190, in _main_task
    return await self._run()
           ^^^^^^^^^^^^^^^^^
  File "/Users/subhamdas/self-nm/agent-starter-python/.venv/lib/python3.12/site-packages/livekit/agents/inference/llm.py", line 341, in _run
    raise APIStatusError(
livekit.agents._exceptions.APIStatusError: Error code: 400 - {'error': {'message': "invalid JSON schema for tool end_call, tools[0].function.parameters: 'required' present but 'properties' is missing", 'type': 'invalid_request_error', 'param': 'tool end_call, tools[0].function.parameters'}} (status_code=400, request_id=req_01ka62vj8pf5086f6mbczmbkq7, body={'message': "invalid JSON schema for tool end_call, tools[0].function.parameters: 'required' present but 'properties' is missing", 'type': 'invalid_request_error', 'param': 'tool end_call, tools[0].function.parameters'}, retryable=True) {"room": "playground-w0WQ-Y4n0", "llm": "livekit.plugins.groq.services.LLM", "attempt": 2, "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
2025-11-16 15:50:04,303 - WARNING livekit.agents - failed to generate LLM completion, retrying in 2.0s
Traceback (most recent call last):
  File "/Users/subhamdas/self-nm/agent-starter-python/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py", line 190, in _main_task
    return await self._run()
           ^^^^^^^^^^^^^^^^^
  File "/Users/subhamdas/self-nm/agent-starter-python/.venv/lib/python3.12/site-packages/livekit/agents/inference/llm.py", line 341, in _run
    raise APIStatusError(
livekit.agents._exceptions.APIStatusError: Error code: 400 - {'error': {'message': "invalid JSON schema for tool end_call, tools[0].function.parameters: 'required' present but 'properties' is missing", 'type': 'invalid_request_error', 'param': 'tool end_call, tools[0].function.parameters'}} (status_code=400, request_id=req_01ka62vmaefwcrbvxyrecq5ywd, body={'message': "invalid JSON schema for tool end_call, tools[0].function.parameters: 'required' present but 'properties' is missing", 'type': 'invalid_request_error', 'param': 'tool end_call, tools[0].function.parameters'}, retryable=True) {"room": "playground-w0WQ-Y4n0", "llm": "livekit.plugins.groq.services.LLM", "attempt": 3, "pid": 12978, "job_id": "AJ_byk49wvPQs8a"}
explain what am I doing wrong?
t
It looks like the error is happening because the JSON schema for your tool's parameters includes a
required
field but is missing the corresponding
properties
field. Whenever you have a
required
field, the
properties
field is essential. To help you fix this, please make sure your tool's parameters object has both
properties
and
required
fields. Here's a simple example to guide you:
Copy code
{
  "parameters": {
    "type": "object",
    "properties": {
      "location": {
        "type": "string",
        "description": "The city and country to look up weather for."
      }
    },
    "required": [
      "location"
    ]
  }
}
Here are a few important things to keep in mind: • Make sure
properties
lists all the parameters your tool can accept. •
required
should only include the names of the parameters that must be provided. • Double-check that every required parameter is actually defined inside
properties
. If your tool doesn't have any required parameters, you can simply use an empty
required
array like this:
Copy code
{
  "parameters": {
    "type": "object",
    "properties": {},
    "required": []
  }
}
Please feel free to reach out if you'd like me to walk you through this with your specific tool or if you need more examples. I'm here to help! Sources: Tool definition and use | LiveKit docs | tools/server/tests/unit/test_tool_call.py
c
where is this tool defined? Did any change happen?
t
I'm happy to help you with the
end_call
tool! It's defined in LiveKit within the
SIPLifecycleAgent
class, located in the
sip_lifecycle.py
file. This tool uses the
@function_tool
decorator and is thoughtfully designed to end a call by deleting the associated room, after creating a farewell message and making sure the audio finishes playing smoothly. As of now, there haven't been any recent documented changes or updates to the schema or how the
end_call
tool works. If you feel something might have changed, it could be helpful to double-check your local setup or compare it with the latest LiveKit version just to be sure. Please feel free to reach out if you'd like a hand finding the tool in your codebase or if you need any more guidance with setting it up—I’m here to support you! Sources: telephony/sip_lifecycle.py | Agent speech and audio | LiveKit docs | livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti...
c
Did the latest livekit roll outs make any changes regarding tool call?
t
I'm excited to share the latest updates from LiveKit's rollouts, especially with the Agents 1.0 migration! They've brought some important changes around tool calls and schemas that I think you'll find helpful: • The
@llm.ai_callable
decorator has been replaced with
@function_tool
for defining tools in Python, making things a bit more straightforward. • Now, argument types for tools are inferred directly from the function signature and docstring, so annotated types are no longer needed. • Tool execution functions receive a
RunContext
(Python) or
{ ctx }
(Node.js) object, which lets you access the agent’s current state more easily. • There’s now standardized support for parallel tool calls across LLM plugins, enabling models to make multiple tool calls at once when this feature is turned on. • The
tool_choice
parameter is consistently supported, giving you better control over whether tool usage is automatic, required, or disabled. These improvements are designed to make tool handling smoother and more consistent. If you have any questions or need a hand adapting to these changes, please don’t hesitate to reach out—I’m here to help! Sources: Groq LLM plugin guide | LiveKit Docs | tools/server/tests/unit/test_tool_call.py | Agents v0.x migration guide - Python | LiveKit docs | Agents v0.x migration guide - Node.js | LiveKit Docs | xAI LLM plugin guide | LiveKit Docs