Skip to content

Commit aa197e1

Browse files
Make the TTS voices type exportable (#577)
When using the voice agent in typed code, it is suboptimal and error prone to type the TTS voice variables in your code independently. With this commit we are making the type exportable so that developers can just use that and be future-proof. Example of usage in code: ``` DEFAULT_TTS_VOICE: TTSModelSettings.TTSVoice = "alloy" ... tts_voice: TTSModelSettings.TTSVoice = DEFAULT_TTS_VOICE ... output = await VoicePipeline( workflow=workflow, config=VoicePipelineConfig( tts_settings=TTSModelSettings( buffer_size=512, transform_data=transform_data, voice=tts_voice, instructions=tts_instructions, )) ).run(audio_input) ``` --------- Co-authored-by: Rohan Mehta <[email protected]>
1 parent 8fd7773 commit aa197e1

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/agents/voice/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
STTModelSettings,
88
TTSModel,
99
TTSModelSettings,
10+
TTSVoice,
1011
VoiceModelProvider,
1112
)
1213
from .models.openai_model_provider import OpenAIVoiceModelProvider
@@ -30,6 +31,7 @@
3031
"STTModelSettings",
3132
"TTSModel",
3233
"TTSModelSettings",
34+
"TTSVoice",
3335
"VoiceModelProvider",
3436
"StreamedAudioResult",
3537
"SingleAgentVoiceWorkflow",

src/agents/voice/model.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
)
1515
DEFAULT_TTS_BUFFER_SIZE = 120
1616

17+
TTSVoice = Literal["alloy", "ash", "coral", "echo", "fable", "onyx", "nova", "sage", "shimmer"]
18+
"""Exportable type for the TTSModelSettings voice enum"""
1719

1820
@dataclass
1921
class TTSModelSettings:
2022
"""Settings for a TTS model."""
21-
22-
voice: (
23-
Literal["alloy", "ash", "coral", "echo", "fable", "onyx", "nova", "sage", "shimmer"] | None
24-
) = None
23+
voice: TTSVoice | None = None
2524
"""
2625
The voice to use for the TTS model. If not provided, the default voice for the respective model
2726
will be used.

0 commit comments

Comments
 (0)