Skip to main content

DecodingResult

A frozen dataclass that contains the results of decoding a 30-second audio segment. Returned by the decode() function.

Fields

Required Fields

torch.Tensor
required
Encoded audio features from the encoder with shape (n_audio_ctx, n_audio_state). These are the internal representations used for decoding.
str
required
Detected or specified language code (e.g., "en", "fr", "ja")

Optional Fields

Optional[Dict[str, float]]
default:"None"
Probability distribution over all languages. Keys are language codes, values are probabilities. Only populated when language detection is performed.
List[int]
default:"[]"
List of integer token IDs that were decoded (excluding special tokens like SOT and EOT)
str
default:"\"\""
Decoded text transcription
float
default:"np.nan"
Average log probability of the generated tokens. More negative values indicate lower model confidence.
float
default:"np.nan"
Probability that the audio segment contains no speech. Values closer to 1.0 indicate the model thinks there’s no speech.
float
default:"np.nan"
Temperature value used for sampling. Will be 0.0 for greedy decoding.
float
default:"np.nan"
Ratio of text length to token count. Very high values may indicate repetitive or hallucinated output.

Usage Examples

Basic Decoding

Checking Result Quality

Language Detection

Batch Processing

Filtering Low-Quality Results

Accessing Token Information

Reusing Audio Features

Quality Metrics

avg_logprob

Average log probability indicates model confidence:
  • > -0.5: Very high confidence
  • -0.5 to -1.0: High confidence (typical for clear speech)
  • -1.0 to -1.5: Moderate confidence
  • < -1.5: Low confidence (may indicate unclear audio or errors)

no_speech_prob

Probability of no speech in the segment:
  • < 0.3: Likely contains speech
  • 0.3 to 0.6: Uncertain
  • > 0.6: Likely no speech (silence, music, noise)

compression_ratio

Ratio of text characters to token count:
  • < 0.8: Possibly truncated output
  • 0.8 to 2.4: Normal range
  • > 2.4: Possible hallucination or repetition
  • > 3.0: Very likely hallucination

Notes

When to Use DecodingResult

  • Quality filtering: Use metrics to filter out poor transcriptions
  • Language detection: Check language_probs for multi-language content
  • Debugging: Inspect tokens and audio_features for troubleshooting
  • Confidence scoring: Use avg_logprob to assess transcription reliability

Batch vs Single Results

The decode() function returns:
  • Single DecodingResult when input mel has shape (80, 3000)
  • List[DecodingResult] when input mel has shape (batch, 80, 3000)

Immutability

The dataclass is frozen (immutable). To modify a result, create a new instance:

Memory Considerations

The audio_features tensor is included in each result. For large batches, consider:
  • Discarding audio features if not needed for further processing
  • Processing audio in smaller batches
  • Using the features for multiple decoding attempts with different options