adamant-airport-69140
12/05/2025, 12:19 PMtall-airline-16756
12/05/2025, 12:19 PMtall-airline-16756
12/05/2025, 12:20 PMfrom livekit.plugins import speechmatics
stt = speechmatics.STT(
enable_diarization=True,
speaker_active_format="<{speaker_id}>{text}<!--{speaker_id}-->"
)
1. Stream audio to the STT plugin and read transcription events
• Open an STT stream and iterate events; final transcripts include speaker labels:
stt_stream = stt.stream()
async for event in stt_stream:
if event.type == SpeechEventType.FINAL_TRANSCRIPT:
transcript = event.alternatives[0].text
# transcript contains speaker markers per speaker_active_format
1. Send the transcription back to clients (example: send as LiveKit text message)
• Publish the transcript from the server/local participant on a topic (e.g., lk.transcription):
await ctx.room.local_participant.send_text(
transcript,
topic="lk.transcription"
)
• Alternatively emit via a custom text stream or external API depending on your app architecture.
1. Frontend: listen for the text stream/topic and render speaker labels
• Ensure clients subscribe to the same text topic (e.g., lk.transcription) and parse the speaker markers inserted by the STT plugin.
If you’d like, tell me:
• which STT plugin you plan to use (Speechmatics or another), and
• whether you want transcripts sent as LiveKit text messages or to an external endpoint,
and I’ll give a tailored code example for your setup.
Sources: Speechmatics STT plugin guide | LiveKit Docs | Speech-to-text (STT) models | LiveKit Docs