Skip to content

Audio

AudioFormat

Bases: str, Enum

Audio encodings a text-to-speech node can request.

Adapters translate these into the provider's own format names, so one node configuration works across providers.

Source code in dynamiq/types/audio.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
class AudioFormat(str, enum.Enum):
    """Audio encodings a text-to-speech node can request.

    Adapters translate these into the provider's own format names, so one node configuration
    works across providers.
    """

    MP3 = "mp3"
    WAV = "wav"
    PCM = "pcm"
    OPUS = "opus"
    FLAC = "flac"
    AAC = "aac"
    MULAW = "mulaw"
    ALAW = "alaw"

Speaker

Bases: BaseModel

A speaker detected by diarization. id is the provider's own label.

Source code in dynamiq/types/audio.py
100
101
102
103
104
class Speaker(BaseModel):
    """A speaker detected by diarization. ``id`` is the provider's own label."""

    id: str
    label: str

SpeakerHints

Bases: BaseModel

Guidance for speaker diarization.

Each provider adapter maps the hints its API accepts and ignores the rest, so the same configuration is valid for every provider.

Source code in dynamiq/types/audio.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class SpeakerHints(BaseModel):
    """Guidance for speaker diarization.

    Each provider adapter maps the hints its API accepts and ignores the rest, so the same
    configuration is valid for every provider.
    """

    expected: int | None = Field(default=None, ge=1, description="Exact number of speakers, when known.")
    min: int | None = Field(default=None, ge=1, description="Lower bound on the number of speakers.")
    max: int | None = Field(default=None, ge=1, description="Upper bound on the number of speakers.")

    @model_validator(mode="after")
    def validate_bounds(self):
        if self.min is not None and self.max is not None and self.min > self.max:
            raise ValueError("Speaker hint 'min' must not exceed 'max'.")
        return self

TimestampGranularity

Bases: str, Enum

How much timing detail a transcription should carry.

Source code in dynamiq/types/audio.py
47
48
49
50
51
52
class TimestampGranularity(str, enum.Enum):
    """How much timing detail a transcription should carry."""

    NONE = "none"
    SEGMENT = "segment"
    WORD = "word"

Transcript

Bases: BaseModel

Provider-neutral transcription result.

content is the plain text every provider returns. transcript is the same text rendered with speaker labels when diarization produced them. segments and words carry timing and speakers; words is empty when the provider returns none.

Source code in dynamiq/types/audio.py
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
class Transcript(BaseModel):
    """Provider-neutral transcription result.

    ``content`` is the plain text every provider returns. ``transcript`` is the same text rendered
    with speaker labels when diarization produced them. ``segments`` and ``words`` carry timing and
    speakers; ``words`` is empty when the provider returns none.
    """

    content: str = Field(description="Plain transcript text.")
    transcript: str = Field(description="Speaker-labelled transcript; equals content without diarization.")
    language: str | None = None
    languages: list[str] = Field(default_factory=list)
    duration: float | None = Field(default=None, description="Audio duration in seconds.")
    speakers: list[Speaker] = Field(default_factory=list)
    segments: list[TranscriptSegment] = Field(default_factory=list)
    words: list[TranscriptWord] = Field(default_factory=list)
    usage: dict[str, Any] = Field(default_factory=dict)
    raw: dict[str, Any] = Field(default_factory=dict, description="Untouched provider response.")

TranscriptSegment

Bases: BaseModel

A contiguous span of speech. Times are seconds from the start of the audio.

Source code in dynamiq/types/audio.py
84
85
86
87
88
89
90
91
92
93
94
95
96
97
class TranscriptSegment(BaseModel):
    """A contiguous span of speech. Times are seconds from the start of the audio."""

    id: str
    text: str
    start: float | None = None
    end: float | None = None
    speaker: str | None = None
    confidence: float | None = None
    language: str | None = None
    synthetic: bool = Field(
        default=False,
        description="True when the segment was rebuilt from word-level output instead of returned by the provider.",
    )

TranscriptWord

Bases: BaseModel

A single word (or punctuation mark / audio event) with optional timing and speaker.

Source code in dynamiq/types/audio.py
73
74
75
76
77
78
79
80
81
class TranscriptWord(BaseModel):
    """A single word (or punctuation mark / audio event) with optional timing and speaker."""

    word: str
    start: float | None = None
    end: float | None = None
    speaker: str | None = None
    confidence: float | None = None
    type: Literal["word", "punctuation", "audio_event"] = "word"