Skip to content

Make the TTS voices type exportable #577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 24, 2025
Merged

Conversation

mangiucugna
Copy link
Contributor

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)

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.
@rohan-mehta
Copy link

@mangiucugna this looks great - can you move it to a top level type instead of inside the class please?

@mangiucugna
Copy link
Contributor Author

@rohan-mehta yes of course makes more sense 😅

Ok now with the new changes this is how it will work:

from agents.voice import TTSVoice
DEFAULT_TTS_VOICE: TTSVoice = "alloy"

...

tts_voice: 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)

I have renamed the type to TTSVoice because is more inline with the rest of types in the library (and python in general)

@rm-openai rm-openai merged commit aa197e1 into openai:main Apr 24, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants