is it possible to use both STT and real time api f...
# ask-ai
b
is it possible to use both STT and real time api for the same agent ?
t
Thanks for reaching out, Vishnu. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Yes — you can use both STT and a real-time model for the same agent. Why you’d do this: • Real-time models (OpenAI Realtime, Gemini Live, Ultravox) handle the core speech/response flow but do not provide low-latency interim transcriptions. • Adding a separate STT plugin (Deepgram, AssemblyAI, etc.) supplies incremental transcripts for live subtitles, UI display, and — importantly — turn detection using LiveKit’s turn detector models. How it works (high level): • The real-time model handles generation and speech output. • The STT plugin runs in parallel to provide live transcription and feed the turn detector or UI. • Both run side-by-side in the same agent session; this is a supported configuration. One note: running both incurs extra cost because you’ll have two transcription systems active. Would you like a short example config for your stack (which STT provider and real-time model are you using)? Sources: Realtime model plugins | LiveKit Docs | LiveKit turn detector plugin | LiveKit docs
b
this is working fine and transcription also doing good ii want to use realtime time openai too after that STT use TTS and STT only for commit first and for the transcription purpose only
t
Thanks — glad transcription is working well. I want to make sure I understand your desired flow so I can give precise guidance. Quick clarifying questions: 1. By "use realtime OpenAI too after that STT" do you mean: first send audio to the OpenAI Realtime model, then run a separate STT pass on the same audio (or on the model's output)? 2. When you say "TTS and STT only for commit first," do you mean you want to generate TTS (agent speech) and immediately run STT to create a committed/final transcript of that TTS output? 3. For "transcription purpose only" — do you want the STT results only for display/storage (no further processing by the real-time model), or do you want those transcripts fed back into the agent for context/actions? 4. Which STT provider are you using (Deepgram, AssemblyAI, other)? Which TTS are you using? 5. Any latency or cost constraints I should consider? Answering these will let me: • confirm the correct sequence (Realtime → STT → TTS → STT) you want, • recommend where to run turn detection vs. final commit, • give a short config example for your provider stack.
b
this working well but the agent audio is not coming to microsip where as if we speak its transcribbed
t
Thanks — I’m looking into why your agent’s audio isn’t reaching MicroSIP while user speech is transcribed correctly. A few targeted questions and quick checks will help me pinpoint the problem: 1. How do you trigger agent speech in code? ◦ Example:
session.say(...)
,
generate_reply()
+ TTS, or Realtime speech output? 1. Is the agent publishing a LocalAudioTrack when it speaks? ◦ Can you confirm
agent.local_participant.published_tracks
shows an audio track after the agent speaks? 1. How is MicroSIP joining the room? ◦ Is it a SIP participant via your SIP trunk/dispatch rule pointing to the same LiveKit room as the agent? 1. Can you check the LiveKit server logs for any errors when the agent calls
say
or publishes audio? 2. From the SIP side, confirm: ◦ MicroSIP shows the call connected. ◦ No one-way audio settings or codec mismatches (G.711/G.722 etc.) in your SIP gateway. 1. If possible, share a short code snippet that shows how you create/publish the agent’s audio (redact secrets). If you prefer, start by checking (and tell me results): • Whether
published_tracks
includes a
LocalAudioTrack
during agent speech. • SIP logs showing RTP packets from LiveKit to your SIP gateway when the agent speaks. Give me answers to 1–3 and any logs/snippets you can share; I’ll suggest the exact next steps. Sources: Agent session | LiveKit docs | sip | livekit/livekit_composite | DeepWiki
b
image.png
t
Thanks — the screenshot is helpful. A few targeted checks to get your agent audio into MicroSIP: 1. Confirm codec compatibility • Your MicroSIP enabled codecs are G.711 A-law/u-law. Ensure LiveKit/SIP gateway is set to offer G.711 on egress to the SIP trunk. If LiveKit is publishing Opus or G.722 only, the SIP gateway must transcode to G.711. 1. Check SIP gateway/transcoder settings • Verify the SIP gateway between LiveKit and MicroSIP is configured to transcode incoming Opus/G.722 -> G.711. Check gateway logs for codec negotiation and any fallback failures. 1. Verify agent publishes audio track • When the agent speaks, confirm a LocalAudioTrack exists (e.g.,
agent.local_participant.published_tracks
shows an audio track). If no track is published, MicroSIP won’t receive audio. 1. Confirm SIP participant subscribes to agent track • Ensure the SIP participant is joined to the same LiveKit room and subscribed to the agent’s audio track (RoomIO should forward published tracks to SIP egress). 1. Check one-way audio / RTP flow • On the SIP side, confirm RTP is flowing from LiveKit to MicroSIP (packet counts, codecs, ports). MicroSIP showing “connected” isn’t enough — inspect RTP stats or gateway logs for incoming audio packets and codec used. 1. Quick tests to isolate: • Temporarily enable Opus/G.722 in MicroSIP (if supported) to see if agent audio appears without transcoding. • Play a known audio file into the agent’s LocalAudioTrack and confirm MicroSIP hears it (distinguishes agent publish vs. TTS generation issues). Please share: • How the SIP gateway is configured (transcoding enabled? which codecs negotiated in logs). • The agent code snippet you use to produce/publish TTS (redact keys). • A short log excerpt showing codec negotiation or published_tracks after the agent speaks. With those I’ll point to the exact change (gateway codec, LiveKit publish settings, or agent publish call) to restore agent audio to MicroSIP.
b
Untitled
t
Thanks — I noticed your last message was empty. Do you want to continue troubleshooting the MicroSIP audio issue? If so, please share any of the following you can: • SIP gateway/transcoder settings or codec negotiation logs (showing what codecs were offered/accepted) • The agent code snippet that generates/publishes TTS (redact secrets) • Output of
agent.local_participant.published_tracks
after the agent speaks • MicroSIP settings screenshot (your previous screenshot helped) or RTP stats showing incoming packets If you prefer, tell me which of the checklist items from my last message you’ve already checked and I’ll suggest the next step.
b
have you seen that log from the agent
t
I haven’t received the agent log yet. Which log are you referring to — the LiveKit agent logs, SIP gateway codec negotiation, or the agent’s TTS publish logs? Please paste the relevant log excerpt (redact any secrets) or attach it. I’ll review it and point out what to look for (published tracks, codec negotiation, RTP errors) and next steps.
b
(venv) PS D:\AgnoX> python app/agents/openai_agent.py dev 2025-12-03 151301,140 - livekit.agents - INFO - received job request INFO livekit.agents received job request {"job_id": "AJ_juDXxrkaBGVM", "dispatch_id": "AD_UzKonZNsD5bU", "room": "call-", "room_id": "RM_AVsUCCr4ffLN", "agent_name": "AgnoX-AI-Agent", "resuming": false, "enable_recording": true} 2025-12-03 151301,142 - livekit.agents - DEBUG - configuring session recording 151301.142 DEBUG livekit.agents configuring session recording {"hostname": "voicebot-7yfcrx6m.livekit.cloud"} 2025-12-03 151301,151 - livekit.agents - DEBUG - input stream attached 151301.151 DEBUG livekit.agents input stream attached {"participant": null, "source": "SOURCE_UNKNOWN", "accepted_sources": ["SOURCE_MICROPHONE"]} 2025-12-03 151301,154 - livekit.agents - DEBUG - input stream detached 151301.154 DEBUG livekit.agents input stream detached {"participant": null, "source": "SOURCE_UNKNOWN", "accepted_sources": ["SOURCE_MICROPHONE"]} 2025-12-03 151301,156 - livekit.agents - DEBUG - input stream attached 151301.156 DEBUG livekit.agents input stream attached {"participant": null, "source": "SOURCE_UNKNOWN", "accepted_sources": ["SOURCE_MICROPHONE"]} 2025-12-03 151301,183 - livekit.agents - DEBUG - received assignment 151301.183 DEBUG livekit.agents received assignment {"agent_name": "AgnoX-AI-Agent", "room_id": "RM_AVsUCCr4ffLN", "room": "call-", "job_id": "AJ_juDXxrkaBGVM", "dispatch_id": "AD_UzKonZNsD5bU", "enable_recording": true} 2025-12-03 151301,187 - livekit.agents - INFO - initializing job runner 151301.187 INFO livekit.agents initializing job runner {"tid": 15740} 2025-12-03 151301,190 - asyncio - DEBUG - Using proactor: IocpProactor 151301.190 DEBUG asyncio Using proactor: IocpProactor 2025-12-03 151301,192 - livekit.agents - INFO - job runner initialized 151301.192 INFO livekit.agents job runner initialized {"tid": 15740, "elapsed_time": 0.0} 2025-12-03 151301,198 - __mp_main__ - INFO - OpenAICustomerServiceAgent initialized 151301.198 INFO __mp_main__ OpenAICustomerServiceAgent initialized 2025-12-03 151301,528 - livekit.agents - DEBUG - start reading stream 151301.528 DEBUG livekit.agents start reading stream {"participant": "sip_+15183171307", "source": "SOURCE_MICROPHONE"} 2025-12-03 151301,535 - livekit.agents - DEBUG - using audio io:
RoomIO
->
RecorderIO
->
AgentSession
->
RecorderIO
->
TranscriptSynchronizer
->
RoomIO
151301.535 DEBUG livekit.agents using audio io:
RoomIO
->
RecorderIO
->
AgentSession
->
RecorderIO
->
TranscriptSynchronizer
->
RoomIO
2025-12-03 151301,538 - livekit.agents - DEBUG - using transcript io:
AgentSession
->
TranscriptSynchronizer
->
RoomIO
151301.538 DEBUG livekit.agents using transcript io:
AgentSession
->
TranscriptSynchronizer
->
RoomIO
2025-12-03 151301,552 - __mp_main__ - INFO - Agent session started successfully with Krisp BVCTelephony noise cancellation 151301.552 INFO __mp_main__ Agent session started successfully with Krisp BVCTelephony noise cancellation 2025-12-03 151301,589 - __mp_main__ - INFO - Waiting for participants to join room call- 151301.589 INFO __mp_main__ Waiting for participants to join room call- 2025-12-03 151301,598 - __mp_main__ - INFO - Current participants: 1 total, 1 real (non-agent) 151301.598 INFO __mp_main__ Current participants: 1 total, 1 real (non-agent) 2025-12-03 151301,610 - __mp_main__ - INFO - Real participant joined; count: 1 151301.610 INFO __mp_main__ Real participant joined; count: 1 2025-12-03 151301,628 - __mp_main__ - INFO - Real participant: sip_+15183171307 151301.628 INFO __mp_main__ Real participant: sip_+15183171307 2025-12-03 151301,644 - __mp_main__ - INFO - Sending greeting: Hello Customer-nown! Welcome back. Thank you for calling again. How can I help you today? 151301.644 INFO __mp_main__ Sending greeting: Hello Customer-nown! Welcome back. Thank you for calling again. How can I help you today? 2025-12-03 151301,663 - app.services.queue_manager - INFO - QueueManager initialized 151301.663 INFO app.services.qu… QueueManager initialized 2025-12-03 151301,666 - __mp_main__ - INFO - Database and services initialized successfully 151301.666 INFO __mp_main__ Database and services initialized successfully 2025-12-03 151301,964 - livekit.plugins.silero - WARNING - inference is slower than realtime 151301.964 WARNI… livekit.plugins… inference is slower than realtime {"delay": 0.2544680000056978} 2025-12-03 151301,968 - livekit.plugins.silero - WARNING - inference is slower than realtime 151301.968 WARNI… livekit.plugins… inference is slower than realtime {"delay": 0.25083540000848004} 2025-12-03 151302,090 - __mp_main__ - INFO - Connected to room: call- 151302.090 INFO __mp_main__ Connected to room: call- 2025-12-03 151302,093 - __mp_main__ - WARNING - Another agent already exists in room call- (found 1 agents). Exiting to prevent duplicate agents. 151302.093 WARNI… __mp_main__ Another agent already exists in room call- (found 1 agents). Exiting to prevent duplicate agents. 2025-12-03 151302,104 - app.services.queue_manager - INFO - Marked queue entry 266 as completed 151302.104 INFO app.services.qu… Marked queue entry 266 as completed 2025-12-03 151304,532 - root - INFO - ignoring text stream with topic 'lk.transcription', no callback attached 151304.532 INFO root ignoring text stream with topic 'lk.transcription', no callback attached 2025-12-03 151308,290 - livekit.agents - DEBUG - received user transcript 151308.290 DEBUG livekit.agents received user transcript {"user_transcript": "Hello.", "language": "english", "transcript_delay": 2.3780517578125} 2025-12-03 151308,296 - __mp_main__ - INFO - Keeping session alive until participant disconnects. 151308.296 INFO __mp_main__ Keeping session alive until participant disconnects. 2025-12-03 151308,298 - livekit.agents - WARNING - _SegmentSynchronizerImpl.resume called after close 151308.298 WARNI… livekit.agents _SegmentSynchronizerImpl.resume called after close 2025-12-03 151308,334 - root - INFO - ignoring text stream with topic 'lk.transcription', no callback attached 151308.334 INFO root ignoring text stream with topic 'lk.transcription', no callback attached 2025-12-03 151308,356 - root - INFO - ignoring text stream with topic 'lk.transcription', no callback attached 151308.356 INFO root ignoring text stream with topic 'lk.transcription', no callback attached 2025-12-03 151311,175 - root - INFO - ignoring text stream with topic 'lk.transcription', no callback attached 151311.175 INFO root ignoring text stream with topic 'lk.transcription', no callback attached 2025-12-03 151321,482 - livekit.agents - DEBUG - received user transcript 151321.482 DEBUG livekit.agents received user transcript {"user_transcript": "Can you hear me?", "language": "english", "transcript_delay": 2.319852352142334} 2025-12-03 151321,524 - root - INFO - ignoring text stream with topic 'lk.transcription', no callback attached 151321.524 INFO root ignoring text stream with topic 'lk.transcription', no callback attached 2025-12-03 151321,540 - root - INFO - ignoring text stream with topic 'lk.transcription', no callback attached 151321.540 INFO root ignoring text stream with topic 'lk.transcription', no callback attached 2025-12-03 151323,675 - root - INFO - ignoring text stream with topic 'lk.transcription', no callback attached 151323.675 INFO root ignoring text stream with topic 'lk.transcription', no callback attached 2025-12-03 151333,993 - livekit.agents - DEBUG - received user transcript 151333.993 DEBUG livekit.agents received user transcript {"user_transcript": "Pace it out, pace it out.", "language": "english", "transcript_delay": 0.030034780502319336} 2025-12-03 151334,038 - root - INFO - ignoring text stream with topic 'lk.transcription', no callback attached 151334.038 INFO root ignoring text stream with topic 'lk.transcription', no callback attached 2025-12-03 151334,043 - root - INFO - ignoring text stream with topic 'lk.transcription', no callback attached 151334.043 INFO root ignoring text stream with topic 'lk.transcription', no callback attached 2025-12-03 151337,103 - root - INFO - ignoring text stream with topic 'lk.transcription', no callback attached 151337.103 INFO root ignoring text stream with topic 'lk.transcription', no callback attached 2025-12-03 151339,435 - livekit.agents - INFO - closing agent session due to participant disconnect (disable via
RoomInputOptions.close_on_disconnect=False
) 151339.435 INFO livekit.agents closing agent session due to participant disconnect (disable {"participant": "sip_+15183171307", "reason": via
RoomInputOptions.close_on_disconnect=False
) "CLIENT_INITIATED"} 2025-12-03 151339,441 - livekit.agents - DEBUG - stream closed 151339.441 DEBUG livekit.agents stream closed {"participant": "sip_+15183171307", "source": "SOURCE_MICROPHONE"} 2025-12-03 151339,459 - livekit.agents - DEBUG - input stream detached 151339.459 DEBUG livekit.agents input stream detached {"participant": "sip_+15183171307", "source": "SOURCE_UNKNOWN", "accepted_sources": ["SOURCE_MICROPHONE"]} 2025-12-03 151339,588 - livekit.agents - DEBUG - session closed 151339.588 DEBUG livekit.agents session closed {"reason": "participant_disconnected", "error": null} 2025-12-03 151339,805 - __mp_main__ - INFO - Participant disconnected, conversation completed 151339.805 INFO __mp_main__ Participant disconnected, conversation completed 2025-12-03 151339,808 - __mp_main__ - WARNING - Skipping session update: database pool is closed 151339.808 WARNI… __mp_main__ Skipping session update: database pool is closed 2025-12-03 151339,810 - __mp_main__ - WARNING - Skipping queue update: database pool is closed 151339.810 WARNI… __mp_main__ Skipping queue update: database pool is closed 2025-12-03 151339,814 - __mp_main__ - INFO - Session 271 completed (resolved by AI) 151339.814 INFO __mp_main__ Session 271 completed (resolved by AI)
t
Thanks — the agent log is helpful. I reviewed it and here are the focused next steps to identify why MicroSIP hears the caller (STT works) but not the agent TTS/audio. What I see in the log (relevant facts) • Agent session starts, joins room, and sees the SIP participant (sip_+15183171307). • Agent sends a greeting ("Sending greeting: Hello Customer...") — so TTS generation was triggered. • Transcription of user audio is received successfully. • No explicit errors publishing an agent audio track are shown. • Room uses
RoomIO
and
RecorderIO
(default routing should forward agent audio to SIP egress). • Warnings: inference slower than realtime and a duplicate-agent warning (agent exited because another agent exists). Those likely aren’t the cause of one-way audio. Likely causes to check (prioritized) 1. SIP gateway codec/transcoding mismatch ◦ MicroSIP supports only G.711 A-law/u-law per your screenshot. If LiveKit or the TTS output is Opus/G.722, the SIP gateway must transcode to G.711. Check the gateway logs for codec negotiation and confirm LiveKit egress is offering G.711 or the gateway is transcoding. 1. Agent not publishing a LocalAudioTrack when speaking ◦ Confirm the agent is publishing a LocalAudioTrack. After the greeting is sent, inspect
agent.local_participant.published_tracks
(or equivalent debug output) to ensure an audio track appears. 1. SIP participant subscription / RoomIO routing ◦ Verify the SIP participant is subscribed to the agent’s audio track. Ensure your RoomIO configuration didn’t accidentally disable egress of agent tracks to SIP. 1. RTP flow / one-way audio on SIP side ◦ On the SIP gateway or MicroSIP, check RTP packet counts and codec in use after the agent speaks. If no RTP packets arrive from LiveKit to the SIP gateway for agent audio, the problem is on the LiveKit → gateway path; if RTP arrives but MicroSIP can't decode it, it’s a codec mismatch. Concrete next checks I need from you • Paste the output of
agent.local_participant.published_tracks
(or confirm whether an audio track is published after the agent greeting). • SIP gateway logs or codec negotiation snippet showing offer/answer (which codecs were offered/accepted). • If available, RTP stats from the SIP gateway or MicroSIP (packet counts, codec in use) while greeting is played. • Your agent code snippet that triggers TTS/publishes audio (redact secrets). Quick troubleshooting actions you can run now • Temporarily allow Opus/G.722 in MicroSIP (if possible) to see if agent audio appears without transcoding. • Play a short prerecorded audio file into the agent’s LocalAudioTrack to confirm LiveKit → SIP egress carries arbitrary audio. • Check gateway config and enable/transcoding for Opus/G.722 → G.711. If you share the three items requested (published_tracks, gateway codec logs, and the TTS publish snippet) I’ll pinpoint whether this is a publish/subscription issue, a RoomIO routing problem, or a codec/transcoding mismatch and give the exact config change to fix it.
b
t
Thanks — please paste the part of your agent code that triggers TTS / generates the agent audio and publishes it to the room (redact any secrets). Focus on the functions that call
say
,
generate_reply
, create/publish LocalAudioTrack, or configure RoomIO/SIP egress. If possible also include: • Any code that configures
RoomIO
or
AgentSession
audio routing. • How the SIP egress/dispatch is set up in your app (the dispatch rule or gateway call). I’ll review and point out what's preventing the agent audio from reaching MicroSIP.
b
{ "sipDispatchRuleId": "SDR_FvRDidWYu9Vf", "rule": { "dispatchRuleDirect": { "roomName": "call-" } }, "name": "agnox-15183171307", "metadata": "{\"source_number\": \"+15183171307\", \"service\": \"customer_service\"}", "roomConfig": { "agents": [ { "agentName": "AgnoX-AI-Agent" } ] } } this is my dispatch rule from the livekit
t
Thanks — I reviewed your dispatch rule and logs. The dispatch rule is the likely root cause. Why: your rule uses "roomName": "call-" which is an incomplete room identifier. That can cause the SIP participant and agent to be routed to an invalid/incorrect room so agent audio isn’t forwarded to the SIP egress even though incoming audio (STT) works. What to do (quick steps) 1. Fix the dispatch rule: • If you want a single static room, set a valid room name:
Copy code
"rule": {
  "dispatchRuleDirect": {
    "roomName": "call-room"
  }
}
• If you want per-call rooms, switch to individual dispatch with a prefix:
Copy code
"rule": {
  "dispatchRuleIndividual": {
    "roomPrefix": "call-"
  }
}
1. Restart/reload the dispatch rule and redeploy the agent, then test again. 2. Verify in the agent after greeting: •
agent.local_participant.published_tracks
includes an audio track. • LiveKit logs show the agent published an audio track and RoomIO routed it to SIP egress. 1. Confirm SIP gateway codec handling: • MicroSIP shows only G.711 enabled; ensure your SIP gateway transcodes Opus/G.722 → G.711 or offer G.711 on egress. If you can, temporarily enable Opus/G.722 in MicroSIP to test. If you prefer, paste the updated dispatch rule or a short log after you change it and I’ll confirm the next steps. Sources: SIP dispatch rule | LiveKit docs | Agents telephony integration | LiveKit docs | Agent session | LiveKit docs
b
livekit plugins using which codec?
t
LiveKit publishes all audio over WebRTC using Opus. Plugin backends (TTS/STT/Realtime models) may produce audio in PCM/WAV/MP3/etc., but before sending to room participants that audio is encoded as Opus. Implications for your SIP/MicroSIP path: • LiveKit → WebRTC: Opus on the wire. • SIP trunks may negotiate G.722 or G.711 with your gateway; the gateway must transcode between Opus and the SIP codec (e.g., Opus→G.711) if the SIP endpoint only supports G.711. • For TTS/STT plugins, ensure the plugin output format (PCM/WAV) is acceptable upstream — LiveKit will encode it to Opus when publishing. If you want, tell me which plugin (TTS provider or realtime model) and which SIP gateway/provider you’re using and I’ll recommend exact settings to ensure proper transcoding and playback in MicroSIP. Sources: Codecs and more | LiveKit docs | Track egress | LiveKit docs | Stream import | LiveKit docs | Rime TTS plugin guide | LiveKit Docs | Speechify TTS plugin guide | LiveKit Docs