1313class SpeechToTextParams (TypedDict ):
1414 url : NotRequired [str ]
1515 file_store_key : NotRequired [str ]
16- language : NotRequired [str ]
16+ language : NotRequired [Union [ str , Literal [ "auto" ]] ]
1717 translate : NotRequired [bool ]
1818 by_speaker : NotRequired [bool ]
1919 webhook_url : NotRequired [str ]
@@ -56,9 +56,15 @@ def __init__(
5656 @overload
5757 def speech_to_text (self , params : SpeechToTextParams ) -> SpeechToTextResponse : ...
5858 @overload
59- def speech_to_text (self , file : bytes , options : Optional [SpeechToTextParams ] = None ) -> SpeechToTextResponse : ...
59+ def speech_to_text (
60+ self , file : bytes , options : Optional [SpeechToTextParams ] = None
61+ ) -> SpeechToTextResponse : ...
6062
61- def speech_to_text (self , blob : Union [SpeechToTextParams , bytes ], options : Optional [SpeechToTextParams ] = None ) -> SpeechToTextResponse :
63+ def speech_to_text (
64+ self ,
65+ blob : Union [SpeechToTextParams , bytes ],
66+ options : Optional [SpeechToTextParams ] = None ,
67+ ) -> SpeechToTextResponse :
6268 if isinstance (
6369 blob , dict
6470 ): # If params is provided as a dict, we assume it's the first argument
@@ -75,11 +81,17 @@ def speech_to_text(self, blob: Union[SpeechToTextParams, bytes], options: Option
7581 content_type = options .get ("content_type" , "application/octet-stream" )
7682 headers = {"Content-Type" : content_type }
7783
78- resp = Request (config = self .config , path = path , params = options , data = blob , headers = headers , verb = "post" ).perform_with_content ()
84+ resp = Request (
85+ config = self .config ,
86+ path = path ,
87+ params = options ,
88+ data = blob ,
89+ headers = headers ,
90+ verb = "post" ,
91+ ).perform_with_content ()
7992 return resp
8093
8194
82-
8395class AsyncAudio (ClientConfig ):
8496 config : AsyncRequestConfig
8597
@@ -97,7 +109,9 @@ def __init__(
97109 )
98110
99111 @overload
100- async def speech_to_text (self , params : SpeechToTextParams ) -> SpeechToTextResponse : ...
112+ async def speech_to_text (
113+ self , params : SpeechToTextParams
114+ ) -> SpeechToTextResponse : ...
101115 @overload
102116 async def speech_to_text (
103117 self , file : bytes , options : Optional [SpeechToTextParams ] = None
0 commit comments