Audio To Text
Defines a base class for audio to text converter used in Gen AI applications.
Quick Start
# Assume `converter` is an instance of a BaseAudioToText subclass
# Returns a TextResult object with combined text and metadata
result = await converter.convert_to_text_result(source="path/to/audio.mp3")
# Or for backward compatibility, returns a list of AudioTranscript segments
segments = await converter.convert(audio_source="path/to/audio.mp3")
BaseAudioToText()
Bases: BaseModalityConverter, Component, ABC
An abstract base class for audio to text used in Gen AI applications.
Extends BaseModalityConverter
so audio converters participate in the shared modality-converter hierarchy.
The primary convert API remains list-based for backward compatibility;
use convert_to_text_result for the unified
TextResult contract.
convert(audio_source=None, *, source=None, **kwargs)
async
Convert audio to timestamped transcript segments.
This is the primary backward-compatible API used across gllm-* integrations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
audio_source
|
str | bytes | None
|
The source of the audio to convert. Accepted as a positional or keyword argument for backward compatibility. |
None
|
source
|
str | bytes | None
|
Keyword-only alias for |
None
|
**kwargs
|
Any
|
Additional transcription parameters. |
{}
|
Returns:
| Type | Description |
|---|---|
list[AudioTranscript]
|
list[AudioTranscript]: Timestamped transcript segments. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither |
convert_to_text_result(audio_source=None, *, source=None, **kwargs)
async
Convert audio to the unified TextResult format used by modality converters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
audio_source
|
str | bytes | None
|
The source of the audio to convert. |
None
|
source
|
str | bytes | None
|
Keyword-only alias for |
None
|
**kwargs
|
Any
|
Additional transcription parameters. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
TextResult |
TextResult
|
Combined transcript text with structured segment metadata. |