From 32580dc6b807173d486948408d601e3e953db7be Mon Sep 17 00:00:00 2001 From: Stefano Baccianella <4247706+mangiucugna@users.noreply.github.com> Date: Wed, 23 Apr 2025 13:47:16 +0200 Subject: [PATCH 1/5] Make the TTS voices type exportable 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. --- src/agents/voice/model.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/agents/voice/model.py b/src/agents/voice/model.py index 220d4b480..6195211b2 100644 --- a/src/agents/voice/model.py +++ b/src/agents/voice/model.py @@ -18,10 +18,8 @@ @dataclass class TTSModelSettings: """Settings for a TTS model.""" - - voice: ( - Literal["alloy", "ash", "coral", "echo", "fable", "onyx", "nova", "sage", "shimmer"] | None - ) = None + TTSVoiceType = Literal["alloy", "ash", "coral", "echo", "fable", "onyx", "nova", "sage", "shimmer"] | None + voice: TTSVoiceType = None """ The voice to use for the TTS model. If not provided, the default voice for the respective model will be used. From 6b5bd3be3c71a61adb0ef908a82fc7f51e527b3a Mon Sep 17 00:00:00 2001 From: Stefano Baccianella <4247706+mangiucugna@users.noreply.github.com> Date: Thu, 24 Apr 2025 06:31:14 +0200 Subject: [PATCH 2/5] Move TTSVoiceType to the top, rename to TTSVoice as it's more idiomatic --- src/agents/voice/model.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/agents/voice/model.py b/src/agents/voice/model.py index 6195211b2..f3b18e3f1 100644 --- a/src/agents/voice/model.py +++ b/src/agents/voice/model.py @@ -14,12 +14,13 @@ ) DEFAULT_TTS_BUFFER_SIZE = 120 +TTSVoice = Literal["alloy", "ash", "coral", "echo", "fable", "onyx", "nova", "sage", "shimmer"] | None +"""Exportable type for the TTSModelSettings voice enum""" @dataclass class TTSModelSettings: """Settings for a TTS model.""" - TTSVoiceType = Literal["alloy", "ash", "coral", "echo", "fable", "onyx", "nova", "sage", "shimmer"] | None - voice: TTSVoiceType = None + voice: TTSVoice = None """ The voice to use for the TTS model. If not provided, the default voice for the respective model will be used. From 1c2676a1da714135b3b440bbb64803d35b6c114f Mon Sep 17 00:00:00 2001 From: Stefano Baccianella <4247706+mangiucugna@users.noreply.github.com> Date: Thu, 24 Apr 2025 06:31:37 +0200 Subject: [PATCH 3/5] Export TTSVoice --- src/agents/voice/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/agents/voice/__init__.py b/src/agents/voice/__init__.py index 499c064c5..361b46d48 100644 --- a/src/agents/voice/__init__.py +++ b/src/agents/voice/__init__.py @@ -7,6 +7,7 @@ STTModelSettings, TTSModel, TTSModelSettings, + TTSVoice, VoiceModelProvider, ) from .models.openai_model_provider import OpenAIVoiceModelProvider From e8cc3f2bb4dbf88d93f751fb49f35f4f4661b871 Mon Sep 17 00:00:00 2001 From: Rohan Mehta Date: Thu, 24 Apr 2025 13:44:29 -0400 Subject: [PATCH 4/5] Update model.py --- src/agents/voice/model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/agents/voice/model.py b/src/agents/voice/model.py index f3b18e3f1..c36a4de76 100644 --- a/src/agents/voice/model.py +++ b/src/agents/voice/model.py @@ -14,13 +14,13 @@ ) DEFAULT_TTS_BUFFER_SIZE = 120 -TTSVoice = Literal["alloy", "ash", "coral", "echo", "fable", "onyx", "nova", "sage", "shimmer"] | None +TTSVoice = Literal["alloy", "ash", "coral", "echo", "fable", "onyx", "nova", "sage", "shimmer"] """Exportable type for the TTSModelSettings voice enum""" @dataclass class TTSModelSettings: """Settings for a TTS model.""" - voice: TTSVoice = None + voice: TTSVoice | None = None """ The voice to use for the TTS model. If not provided, the default voice for the respective model will be used. From 7ceb370bf70ce5ee6179af5b29265fb55895cad2 Mon Sep 17 00:00:00 2001 From: Rohan Mehta Date: Thu, 24 Apr 2025 13:47:05 -0400 Subject: [PATCH 5/5] Update __init__.py --- src/agents/voice/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/agents/voice/__init__.py b/src/agents/voice/__init__.py index 361b46d48..e11ee4467 100644 --- a/src/agents/voice/__init__.py +++ b/src/agents/voice/__init__.py @@ -31,6 +31,7 @@ "STTModelSettings", "TTSModel", "TTSModelSettings", + "TTSVoice", "VoiceModelProvider", "StreamedAudioResult", "SingleAgentVoiceWorkflow",