@@ -16,6 +16,17 @@ class TextToSpeechParams(TypedDict):
1616 speaker_clone_file_store_key : NotRequired [str ]
1717
1818
19+ class TTSCloneParams (TypedDict ):
20+ url : NotRequired [str ]
21+ file_store_key : NotRequired [str ]
22+ name : str
23+
24+
25+ class GetTTSVoiceClonesParams (TypedDict ):
26+ limit : NotRequired [int ]
27+ page : NotRequired [int ]
28+
29+
1930class TextToSpeechResponse (TypedDict ):
2031 success : bool
2132 text : str
@@ -68,14 +79,18 @@ def __init__(
6879 @overload
6980 def speech_to_text (self , params : SpeechToTextParams ) -> SpeechToTextResponse : ...
7081 @overload
71- def speech_to_text (self , file : bytes , options : Optional [SpeechToTextParams ] = None ) -> SpeechToTextResponse : ...
82+ def speech_to_text (
83+ self , file : bytes , options : Optional [SpeechToTextParams ] = None
84+ ) -> SpeechToTextResponse : ...
7285
7386 def speech_to_text (
7487 self ,
7588 blob : Union [SpeechToTextParams , bytes ],
7689 options : Optional [SpeechToTextParams ] = None ,
7790 ) -> SpeechToTextResponse :
78- if isinstance (blob , dict ): # If params is provided as a dict, we assume it's the first argument
91+ if isinstance (
92+ blob , dict
93+ ): # If params is provided as a dict, we assume it's the first argument
7994 resp = Request (
8095 config = self .config ,
8196 path = "/ai/transcribe" ,
@@ -99,7 +114,6 @@ def speech_to_text(
99114 ).perform_with_content ()
100115 return resp
101116
102-
103117 def text_to_speech (self , params : TextToSpeechParams ) -> TextToSpeechResponse :
104118 path = "/ai/tts"
105119 resp = Request (
@@ -120,6 +134,37 @@ def speaker_voice_accents(self) -> TextToSpeechResponse:
120134 ).perform_with_content ()
121135 return resp
122136
137+ def create_clone (self , params : TTSCloneParams ) -> TextToSpeechResponse :
138+ path = "/ai/tts/clone"
139+ resp = Request (
140+ config = self .config ,
141+ path = path ,
142+ params = cast (Dict [Any , Any ], params ),
143+ verb = "post" ,
144+ ).perform_with_content ()
145+
146+ return resp
147+
148+ def get_clones (self , params : GetTTSVoiceClonesParams ) -> TextToSpeechResponse :
149+ path = "/ai/tts/clone"
150+ resp = Request (
151+ config = self .config ,
152+ path = path ,
153+ params = cast (Dict [Any , Any ], params ),
154+ verb = "get" ,
155+ ).perform_with_content ()
156+ return resp
157+
158+ def delete_clone (self , voice_id : str ) -> TextToSpeechResponse :
159+ path = f"/ai/tts/clone/{ voice_id } "
160+ resp = Request (
161+ config = self .config ,
162+ path = path ,
163+ params = {},
164+ verb = "delete" ,
165+ ).perform_with_content ()
166+ return resp
167+
123168
124169class AsyncAudio (ClientConfig ):
125170 config : AsyncRequestConfig
@@ -138,9 +183,13 @@ def __init__(
138183 )
139184
140185 @overload
141- async def speech_to_text (self , params : SpeechToTextParams ) -> SpeechToTextResponse : ...
186+ async def speech_to_text (
187+ self , params : SpeechToTextParams
188+ ) -> SpeechToTextResponse : ...
142189 @overload
143- async def speech_to_text (self , file : bytes , options : Optional [SpeechToTextParams ] = None ) -> SpeechToTextResponse : ...
190+ async def speech_to_text (
191+ self , file : bytes , options : Optional [SpeechToTextParams ] = None
192+ ) -> SpeechToTextResponse : ...
144193
145194 async def speech_to_text (
146195 self ,
@@ -155,7 +204,7 @@ async def speech_to_text(
155204 verb = "post" ,
156205 ).perform_with_content ()
157206 return resp
158-
207+
159208 options = options or {}
160209 path = build_path (base_path = "/ai/transcribe" , params = options )
161210 content_type = options .get ("content_type" , "application/octet-stream" )
0 commit comments