🎯 Voice AI Consulting
Get dedicated support and consultation to ensure your specific needs are met.
Consult an AI Expert

TLDR: Word-level confidence scores tell you how certain a speech-to-text model is about each transcribed word. This tutorial shows you how to get word-level confidence scores in Python and how to set word-confidence thresholds to detect uncertain words.

What is a Confidence Score?

A confidence score is a numerical probability value that indicates how certain a machine learning model is about its prediction. In the context of speech recognition, confidence scores help measure the reliability of the model's output and identify potential errors in automated transcriptions.

What is a Word-Level Confidence Score?

Word-level confidence scores are probability scores represented as numerical values between 0.0 and 1.0 that indicate how certain an ASR model is about each transcribed word. These per-word confidence scores help estimate word-level reliability and improve transcription quality:

  • 0.0: Lowest confidence (very uncertain)
  • 1.0: Highest confidence (very certain)

Confidence scores vary across Automatic Speech Recognition (ASR) engines and indicate model certainty rather than guaranteed accuracy. An ASR model might be 90% accurate but have poorly calibrated confidence scores. Different speech-to-text providers may return different word-level confidence values for the same transcribed word, and some systems like open-source Whisper don't provide confidence scores at all.

Why Confidence Scores Matter?

Word-level confidence scores can improve an application's reliability and user experience. For example, A voice assistant can use low word-level confidence scores to ask "Did you say...?" instead of executing an uncertain command, or a transcription software can flag uncertain words for human review to improve transcription quality and accuracy.

Implement Word-Level Confidence Scores in Python

What You'll Need:

  • Python 3.9+
  • An audio file to transcribe (WAV, MP3, FLAC, or other common formats)
  • Picovoice AccessKey from the Picovoice Console

What You'll Build:

  • Python script to get transcriptions with word-level confidence scores
  • Python script to detect low-confidence words using a custom threshold

Install the Speech-to-Text SDK

Install the speech-to-text SDK using pip:

Full Code to Get Word-Level Confidence Scores in Python

Here's the complete working code that transcribes an audio file and displays each word with its individual confidence score:

Run the Word Confidence Python Script

Save the code as word_confidence.py and run it from the command line with your Picovoice AccessKey and audio file path:

Python Code Output: Word-Level Confidence Scores

Each word includes a confidence score (0.0 to 1.0) associated with it. Lower confidence scores indicate uncertain recognition and potentially misrecognized words; higher confidence scores indicate confident recognition and greater reliability.

Detect Low-Confidence Words in Speech-to-Text (Word Confidence Threshold)

One of the most practical uses of word-level confidence scores is identifying uncertain words that may need review. Here's the Python code to automatically flag low-confidence words using a custom confidence threshold:

The confidence threshold can be set based on the application's tolerance for errors: high-stakes applications like medical or legal transcription can have higher thresholds to catch more potential errors for review and ensure word-level accuracy, while casual applications like notes or captions can use relatively lower thresholds to balance between flagging uncertain words and maintaining workflow efficiency.

Run the Word Confidence Threshold Detection Code

Save the code as low_confidence_detector.py and run it from the command line with your AccessKey and audio file path

Python Code Output: Word Confidence Threshold

The script filters words below the 0.90 confidence threshold and displays each flagged word with its confidence score and timestamp. This makes it easy to locate uncertain words in the audio for manual review or further processing.

Leopard Speech-to-Text offers additional production-ready features like speaker diarization, timestamps and automatic punctuation. Explore all speech-to-text features to get reliable and high quality transcriptions.

Start building production-ready speech recognition applications with word-level confidence scores for better transcription quality control today!

Start Free