how can i send transcription in stt standalone spe...
# ask-ai
a
how can i send transcription in stt standalone speaker diarization mode?
t
Thanks for reaching out, bogdanmelnikbo. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking how to send transcription results when using STT in standalone speaker-diarization mode. Here's how you can do that. 1. Use a diarization-capable STT plugin (example: Speechmatics) • Create the plugin with diarization enabled and set the speaker format:
Copy code
from 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:
Copy code
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
):
Copy code
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