55import base64
66from collections .abc import Callable
77from functools import wraps
8- from typing import Any , Literal , TypeVar , Union
8+ from typing import Any , Literal , TypeVar
99from unittest .mock import MagicMock
1010
1111from anyio import Event
1212
1313from autogen .import_utils import optional_import_block
1414
1515with optional_import_block () as result :
16- from openai import NotGiven , OpenAI
16+ from openai import Omit , OpenAI
1717
1818__all__ = ["text_to_speech" , "trace" ]
1919
@@ -24,7 +24,7 @@ def text_to_speech(
2424 openai_api_key : str ,
2525 model : str = "tts-1" ,
2626 voice : Literal ["alloy" , "echo" , "fable" , "onyx" , "nova" , "shimmer" ] = "alloy" ,
27- response_format : Union [ Literal ["mp3" , "opus" , "aac" , "flac" , "wav" , "pcm" ], "NotGiven" ] = "pcm" ,
27+ response_format : Literal ["mp3" , "opus" , "aac" , "flac" , "wav" , "pcm" ] | Omit = "pcm" ,
2828) -> str :
2929 """Convert text to voice using OpenAI API.
3030
@@ -33,7 +33,7 @@ def text_to_speech(
3333 openai_api_key (str): OpenAI API key.
3434 model (str, optional): Model to use for the conversion. Defaults to "tts-1".
3535 voice (Literal["alloy", "echo", "fable", "onyx", "nova", "shimmer"], optional): Voice to use for the conversion. Defaults to "alloy".
36- response_format (Union[ Literal["mp3", "opus", "aac", "flac", "wav", "pcm"], NotGiven] , optional): Response format. Defaults to "pcm".
36+ response_format (Literal["mp3", "opus", "aac", "flac", "wav", "pcm"] | Omit , optional): Response format. Defaults to "pcm".
3737
3838 Returns:
3939 str: Base64 encoded audio.
0 commit comments