@@ -37,7 +37,7 @@ class TextToSpeechResponse(TypedDict):
3737class SpeechToTextParams (TypedDict ):
3838 url : NotRequired [str ]
3939 file_store_key : NotRequired [str ]
40- language : NotRequired [str ]
40+ language : NotRequired [Union [ str , Literal [ "auto" ]] ]
4141 translate : NotRequired [bool ]
4242 by_speaker : NotRequired [bool ]
4343 webhook_url : NotRequired [str ]
@@ -80,9 +80,15 @@ def __init__(
8080 @overload
8181 def speech_to_text (self , params : SpeechToTextParams ) -> SpeechToTextResponse : ...
8282 @overload
83- def speech_to_text (self , file : bytes , options : Optional [SpeechToTextParams ] = None ) -> SpeechToTextResponse : ...
83+ def speech_to_text (
84+ self , file : bytes , options : Optional [SpeechToTextParams ] = None
85+ ) -> SpeechToTextResponse : ...
8486
85- def speech_to_text (self , blob : Union [SpeechToTextParams , bytes ], options : Optional [SpeechToTextParams ] = None ) -> SpeechToTextResponse :
87+ def speech_to_text (
88+ self ,
89+ blob : Union [SpeechToTextParams , bytes ],
90+ options : Optional [SpeechToTextParams ] = None ,
91+ ) -> SpeechToTextResponse :
8692 if isinstance (
8793 blob , dict
8894 ): # If params is provided as a dict, we assume it's the first argument
@@ -99,7 +105,14 @@ def speech_to_text(self, blob: Union[SpeechToTextParams, bytes], options: Option
99105 content_type = options .get ("content_type" , "application/octet-stream" )
100106 headers = {"Content-Type" : content_type }
101107
102- resp = Request (config = self .config , path = path , params = options , data = blob , headers = headers , verb = "post" ).perform_with_content ()
108+ resp = Request (
109+ config = self .config ,
110+ path = path ,
111+ params = options ,
112+ data = blob ,
113+ headers = headers ,
114+ verb = "post" ,
115+ ).perform_with_content ()
103116 return resp
104117
105118 def text_to_speech (self , params : TextToSpeechParams ) -> TextToSpeechResponse :
@@ -114,23 +127,37 @@ def text_to_speech(self, params: TextToSpeechParams) -> TextToSpeechResponse:
114127
115128 def speaker_voice_accents (self ) -> TextToSpeechResponse :
116129 path = "/ai/tts"
117- resp = Request (config = self .config , path = path , params = {}, verb = "get" ).perform_with_content ()
130+ resp = Request (
131+ config = self .config , path = path , params = {}, verb = "get"
132+ ).perform_with_content ()
118133 return resp
119134
120135 def create_clone (self , params : TTSCloneParams ) -> TextToSpeechResponse :
121136 path = "/ai/tts/clone"
122- resp = Request (config = self .config , path = path , params = cast (Dict [Any , Any ], params ), verb = "post" ).perform_with_content ()
137+ resp = Request (
138+ config = self .config ,
139+ path = path ,
140+ params = cast (Dict [Any , Any ], params ),
141+ verb = "post" ,
142+ ).perform_with_content ()
123143
124144 return resp
125145
126146 def list_clones (self , params : ListTTSVoiceClonesParams ) -> TextToSpeechResponse :
127147 path = "/ai/tts/clone"
128- resp = Request (config = self .config , path = path , params = cast (Dict [Any , Any ], params ), verb = "get" ).perform_with_content ()
148+ resp = Request (
149+ config = self .config ,
150+ path = path ,
151+ params = cast (Dict [Any , Any ], params ),
152+ verb = "get" ,
153+ ).perform_with_content ()
129154 return resp
130155
131156 def delete_clone (self , voice_id : str ) -> TextToSpeechResponse :
132157 path = f"/ai/tts/clone/{ voice_id } "
133- resp = Request (config = self .config , path = path , params = {}, verb = "delete" ).perform_with_content ()
158+ resp = Request (
159+ config = self .config , path = path , params = {}, verb = "delete"
160+ ).perform_with_content ()
134161 return resp
135162
136163
@@ -151,7 +178,9 @@ def __init__(
151178 )
152179
153180 @overload
154- async def speech_to_text (self , params : SpeechToTextParams ) -> SpeechToTextResponse : ...
181+ async def speech_to_text (
182+ self , params : SpeechToTextParams
183+ ) -> SpeechToTextResponse : ...
155184 @overload
156185 async def speech_to_text (
157186 self , file : bytes , options : Optional [SpeechToTextParams ] = None
@@ -209,29 +238,28 @@ async def speaker_voice_accents(self) -> TextToSpeechResponse:
209238 async def create_clone (self , params : TTSCloneParams ) -> TextToSpeechResponse :
210239 path = "/ai/tts/clone"
211240 resp = await AsyncRequest (
212- config = self .config ,
213- path = path ,
214- params = cast (Dict [Any , Any ], params ),
215- verb = "post"
241+ config = self .config ,
242+ path = path ,
243+ params = cast (Dict [Any , Any ], params ),
244+ verb = "post" ,
216245 ).perform_with_content ()
217246 return resp
218247
219- async def list_clones (self , params : ListTTSVoiceClonesParams ) -> TextToSpeechResponse :
248+ async def list_clones (
249+ self , params : ListTTSVoiceClonesParams
250+ ) -> TextToSpeechResponse :
220251 path = "/ai/tts/clone"
221252 resp = await AsyncRequest (
222- config = self .config ,
223- path = path ,
224- params = cast (Dict [Any , Any ], params ),
225- verb = "get"
253+ config = self .config ,
254+ path = path ,
255+ params = cast (Dict [Any , Any ], params ),
256+ verb = "get" ,
226257 ).perform_with_content ()
227258 return resp
228259
229260 async def delete_clone (self , voice_id : str ) -> TextToSpeechResponse :
230261 path = f"/ai/tts/clone/{ voice_id } "
231262 resp = await AsyncRequest (
232- config = self .config ,
233- path = path ,
234- params = {},
235- verb = "delete"
263+ config = self .config , path = path , params = {}, verb = "delete"
236264 ).perform_with_content ()
237265 return resp
0 commit comments