utils
Utility functions for extracting probability metrics from STT services.
- pipecat.services.whisper.utils.extract_whisper_probability(frame: TranscriptionFrame) float | None[source]
Extract probability from Whisper-based TranscriptionFrame result.
Works with Groq, OpenAI Whisper, or other Whisper-based services that use verbose_json format with segments containing avg_logprob.
Converts avg_logprob to probability.
- Parameters:
frame – TranscriptionFrame with result from GroqSTTService or OpenAISTTService (when include_prob_metrics=True and using Whisper models).
- Returns:
Probability (0-1) if available, None otherwise.
Example:
from pipecat.services.groq.stt import GroqSTTService from pipecat.services.whisper.utils import extract_whisper_probability stt = GroqSTTService(include_prob_metrics=True) # ... use stt in pipeline ... # In your frame processor: if isinstance(frame, TranscriptionFrame): prob = extract_whisper_probability(frame) if prob: print(f"Transcription confidence: {prob:.2%}")
- pipecat.services.whisper.utils.extract_openai_gpt4o_probability(frame: TranscriptionFrame) float | None[source]
Extract probability from OpenAI GPT-4o-transcribe TranscriptionFrame result.
- Parameters:
frame – TranscriptionFrame with result from OpenAISTTService using GPT-4o-transcribe model (when include_prob_metrics=True).
- Returns:
Probability (0-1) if available, None otherwise.
Example:
from pipecat.services.openai.stt import OpenAISTTService from pipecat.services.whisper.utils import extract_openai_gpt4o_probability stt = OpenAISTTService(model="gpt-4o-transcribe", include_prob_metrics=True) # ... use stt in pipeline ... # In your frame processor: if isinstance(frame, TranscriptionFrame): prob = extract_openai_gpt4o_probability(frame) if prob: print(f"Transcription confidence: {prob:.2%}")
- pipecat.services.whisper.utils.extract_deepgram_probability(frame: TranscriptionFrame) float | None[source]
Extract probability from Deepgram TranscriptionFrame result.
- Parameters:
frame – TranscriptionFrame with result from DeepgramSTTService.
- Returns:
Probability (0-1) if available, None otherwise. Returns alternative-level confidence if available, otherwise calculates average confidence from word-level confidences.
Example:
from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.whisper.utils import extract_deepgram_probability stt = DeepgramSTTService() # ... use stt in pipeline ... # In your frame processor: if isinstance(frame, TranscriptionFrame): prob = extract_deepgram_probability(frame) if prob: print(f"Transcription confidence: {prob:.2%}")