Prompt
How do I add word-level confidence to transcript output?
Latest observation
To add word-level confidence to transcript output, the exact method depends on the speech-to-text engine or API you’re using. In general, you want the recognizer to return per-word metadata and then include that in your transcript JSON/text.
Common approaches
1) Enable word confidence / word metadata in the STT API
Many APIs have a flag like:
enableWordConfidenceshow_word_confidenceword_time_offsetsenable_word_time_offsetsdetailed_results
When enabled, the response usually includes each word with:
- the word text
- start/end time
- confidence score
Example shape:
{
"transcript": "hello world",
"words": [
{ "word": "hello", "confidence": 0.98, "start": 0.2, "end": 0.5 },
{ "word": "world", "confidence": 0.91, "start": 0.6, "end": 0.9 }
]
}
2) Add word confidence to your transcript formatter
If your STT output already includes word-level data, modify your formatter to append confidence:
hello(0.98) world(0.91)
Or in JSON:
{
"transcript": "hello world",
"word_confidence": [
{"word": "hello", "confidence": 0.98},
{"word": "world", "confidence": 0.91}
]
}
3) If your model only returns segment-level confidence
Some systems return confidence for the whole segment, not individual words. In that case:
- You cannot get true word-level confidence directly
- You can only approximate it using token probabilities/logprobs if the model exposes them
- Or switch to a model/API that supports word-level confidence
If you’re using a specific platform
Here are common examples:
Google Cloud Speech-to-Text
Enable word-level confidence in the recognition config and inspect words in the result.
AWS Transcribe
Use transcription settings that include speaker/word metadata; word confidence availability depends on the API/output type.
Whisper / OpenAI-style transcription
Word-level confidence is not always returned directly. You may need:
- token probabilities/logprobs, if available
- alignment tools like
whisperxfor timestamps and derived scores - a separate confidence estimation layer
Best practice
Store transcript output as structured data, not plain text only:
{
"text": "hello world",
"words": [
{"text": "hello", "confidence": 0.98},
{"text": "world", "confidence": 0.91}
]
}
That way you can render it in different formats later.
If you tell me which speech-to-text library or API you’re using, I can show the exact code to enable word-level confidence.