how to get transcript confidence for chat message
# ask-ai
e
how to get transcript confidence for chat message
t
Thanks for reaching out, Aman. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I can help with that. You're asking how to get the transcript confidence for a chat message; I want to make sure I give the right guidance for your setup. A few quick questions so I can answer precisely: • Which STT/transcription plugin are you using (for example Deepgram or AssemblyAI)? • Are you capturing transcriptions via an event listener such as
user_input_transcribed
, or via a plugin API response stored elsewhere? • Do you need the confidence for a live/user input transcript (real-time) or for post-processed transcripts? What I can say now: • Some STT plugins (Deepgram, AssemblyAI) expose confidence metrics internally and use confidence thresholds for end-of-turn detection. • The LiveKit recipe/events like
user_input_transcribed
can be used to receive transcription results, but the documentation does not explicitly state whether the event payload includes a confidence score. Next steps I can take for you: • If you tell me the plugin and how you currently receive transcripts, I will outline the exact places to look for a confidence field (event payload vs plugin response) and show a small example of extracting it. • If your current plugin doesn’t return confidence, I can suggest alternatives: either switching to a plugin that provides confidence or calling the STT provider’s API directly to get confidence scores. Pick one of the options above (answer the three questions or tell me which next step you prefer) and I’ll give the exact code/event examples to extract the confidence value. Sources: Deepgram STT plugin guide | LiveKit Documentation | AssemblyAI plugin guide | LiveKit Documentation | Interrupt User | LiveKit Documentation
e
i'm using deepgram as stt
t
Thanks — that’s helpful. You said you’re using Deepgram for STT; I’ll explain how to get the transcript confidence and show short examples you can adapt. What to expect • Deepgram returns a confidence score with each transcript alternative. The score is a number from 0 to 1 (higher = more confident). • When using Deepgram with LiveKit, the confidence is included in the transcription events (for example via the
user_input_transcribed
event or when processing the
SpeechStream
from the Deepgram plugin). You should read the
alternatives
array on the event and extract the
confidence
from the chosen alternative. Two concise examples you can use 1) Listening to LiveKit transcription events (Python-style pseudocode) • This shows extracting confidence from the event payload when LiveKit emits
user_input_transcribed
.
Copy code
@session.on("user_input_transcribed")
def on_transcript(transcript):
    # Only proceed if we have alternatives
    if transcript.alternatives:
        # Choose the primary alternative (index 0)
        alt = transcript.alternatives[0]
        text = alt.text
        confidence = alt.confidence
        print(f"Transcript: {text}  Confidence: {confidence}")
2) Handling Deepgram SpeechStream directly (async streaming) • If you are consuming the Deepgram stream yourself, check each event for alternatives and confidence.
Copy code
async def recognize_task(stream: deepgram.SpeechStream):
    async for event in stream:
        if event.alternatives:
            alt = event.alternatives[0]
            final_text = alt.text
            confidence = alt.confidence
            if event.is_final:
                print(f"Final transcript: {final_text} (confidence={confidence})")
            else:
                print(f"Interim transcript: {final_text} (confidence={confidence})")
Notes and tips • Alternatives: Many responses contain multiple alternatives. Use whichever alternative makes sense (commonly the first). • Interim vs final: You’ll receive interim events with confidence as well — typically use the final event for production decisions. • Thresholding: If you want to filter low-confidence transcripts, compare the confidence to your threshold (for example, 0.7) before creating a chat message or taking an action. • End-of-turn logic: Deepgram and LiveKit may use confidence thresholds (e.g.,
eager_eot_threshold
or
end_of_turn_confidence_threshold
) internally to decide end-of-turn; those are separate and configurable if you need different behavior. If you want, tell me: • Whether you want sample code for another language (Node, Go, etc.), or • Where you’re consuming transcripts (event handler vs plugin callback) and I’ll give a tailored snippet for that setup. Sources: Deepgram STT plugin guide | LiveKit Documentation | An open source stack for real-time multimodal AI | An open source stack for real-time multimodal AI