crooked-tiger-31253
04/30/2026, 9:08 PMtall-airline-16756
04/30/2026, 9:08 PMtall-airline-16756
04/30/2026, 9:08 PMFINAL_TRANSCRIPT as definitive. The engine typically moves to FINAL_TRANSCRIPT after it detects end-of-speech (pause/endpointing) or a model-based turn-end.
If you want, tell me which integration or language SDK you’re using (JS, Python, or server-side plugin) and I’ll show a short code snippet for filtering final transcripts.
Sources: Speechmatics STT plugin guide | LiveKit Documentation | Speech-to-text (STT) models overview | LiveKit Documentation | Turn Detection for Voice Agents: VAD, Endpointing, and Model-Based Detectio..., with interactive elementscrooked-tiger-31253
04/30/2026, 9:09 PMtall-airline-16756
04/30/2026, 9:09 PMcrooked-tiger-31253
04/30/2026, 9:09 PMtall-airline-16756
04/30/2026, 9:10 PMimport asyncio
from enum import Enum
from typing import AsyncIterable
# --- Mock types (replace with your LiveKit SDK types) ---
class SpeechEventType(Enum):
INTERIM_TRANSCRIPT = "INTERIM_TRANSCRIPT"
FINAL_TRANSCRIPT = "FINAL_TRANSCRIPT"
START_OF_SPEECH = "START_OF_SPEECH"
END_OF_SPEECH = "END_OF_SPEECH"
class Alt:
def __init__(self, text: str):
self.text = text
class SpeechEvent:
def __init__(self, type: SpeechEventType, alternatives: list[Alt]):
self.type = type
self.alternatives = alternatives
# --- Example: process STT stream and call LLM on final transcripts ---
async def call_llm(prompt: str) -> str:
"""
Replace with your LLM client call (OpenAI/other). This is an async stub.
"""
await asyncio.sleep(0.1) # simulate network
return f"LLM response for: {prompt}"
async def process_stt_stream(stream: AsyncIterable[SpeechEvent]):
async for event in stream:
# ignore events with no alternatives
if not getattr(event, "alternatives", None):
continue
text = event.alternatives[0].text
if event.type == SpeechEventType.INTERIM_TRANSCRIPT:
# optional: update UI or buffer
print(f"Interim: {text}")
elif event.type == SpeechEventType.FINAL_TRANSCRIPT:
print(f"Final: {text}")
# send final transcript to LLM
llm_response = await call_llm(text)
print(f"LLM -> {llm_response}")
elif event.type == SpeechEventType.START_OF_SPEECH:
print("Start of speech")
elif event.type == SpeechEventType.END_OF_SPEECH:
print("End of speech")
# --- Example mock stream to demonstrate behavior ---
async def mock_stt_events():
events = [
SpeechEvent(SpeechEventType.INTERIM_TRANSCRIPT, [Alt("i")]),
SpeechEvent(SpeechEventType.INTERIM_TRANSCRIPT, [Alt("i love play")]),
SpeechEvent(SpeechEventType.INTERIM_TRANSCRIPT, [Alt("i love playing in the park")]),
SpeechEvent(SpeechEventType.INTERIM_TRANSCRIPT, [Alt("i love playing in the park with my")]),
SpeechEvent(SpeechEventType.FINAL_TRANSCRIPT, [Alt("i love playing in the park with my daughter")]),
]
for e in events:
await asyncio.sleep(0.05)
yield e
# --- Run demo ---
async def main():
await process_stt_stream(mock_stt_events())
if __name__ == "__main__":
asyncio.run(main())
If you want, tell me which LLM client (OpenAI, Anthropic, etc.) and which LiveKit Python object you receive the SpeechEvent stream from, and I’ll adapt the snippet to real SDK calls.
Sources: Build a multilingual voice agent that automatically switches languages | Li... | Speech-to-text (STT) models overview | LiveKit Documentation, with interactive elementslimited-activity-37999
05/01/2026, 9:26 PMtall-airline-16756
05/01/2026, 9:26 PM