@@ -16,6 +16,17 @@ class TextToSpeechParams(TypedDict):
16
16
speaker_clone_file_store_key : NotRequired [str ]
17
17
18
18
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
+
19
30
class TextToSpeechResponse (TypedDict ):
20
31
success : bool
21
32
text : str
@@ -70,12 +81,10 @@ def speech_to_text(self, params: SpeechToTextParams) -> SpeechToTextResponse: ..
70
81
@overload
71
82
def speech_to_text (self , file : bytes , options : Optional [SpeechToTextParams ] = None ) -> SpeechToTextResponse : ...
72
83
73
- def speech_to_text (
74
- self ,
75
- blob : Union [SpeechToTextParams , bytes ],
76
- options : Optional [SpeechToTextParams ] = None ,
77
- ) -> SpeechToTextResponse :
78
- if isinstance (blob , dict ): # If params is provided as a dict, we assume it's the first argument
84
+ def speech_to_text (self , blob : Union [SpeechToTextParams , bytes ], options : Optional [SpeechToTextParams ] = None ) -> SpeechToTextResponse :
85
+ if isinstance (
86
+ blob , dict
87
+ ): # If params is provided as a dict, we assume it's the first argument
79
88
resp = Request (
80
89
config = self .config ,
81
90
path = "/ai/transcribe" ,
@@ -89,17 +98,9 @@ def speech_to_text(
89
98
content_type = options .get ("content_type" , "application/octet-stream" )
90
99
headers = {"Content-Type" : content_type }
91
100
92
- resp = Request (
93
- config = self .config ,
94
- path = path ,
95
- params = options ,
96
- data = blob ,
97
- headers = headers ,
98
- verb = "post" ,
99
- ).perform_with_content ()
101
+ resp = Request (config = self .config , path = path , params = options , data = blob , headers = headers , verb = "post" ).perform_with_content ()
100
102
return resp
101
103
102
-
103
104
def text_to_speech (self , params : TextToSpeechParams ) -> TextToSpeechResponse :
104
105
path = "/ai/tts"
105
106
resp = Request (
@@ -112,12 +113,23 @@ def text_to_speech(self, params: TextToSpeechParams) -> TextToSpeechResponse:
112
113
113
114
def speaker_voice_accents (self ) -> TextToSpeechResponse :
114
115
path = "/ai/tts"
115
- resp = Request (
116
- config = self .config ,
117
- path = path ,
118
- params = {},
119
- verb = "get" ,
120
- ).perform_with_content ()
116
+ resp = Request (config = self .config , path = path , params = {}, verb = "get" ).perform_with_content ()
117
+ return resp
118
+
119
+ def create_clone (self , params : TTSCloneParams ) -> TextToSpeechResponse :
120
+ path = "/ai/tts/clone"
121
+ resp = Request (config = self .config , path = path , params = cast (Dict [Any , Any ], params ), verb = "post" ).perform_with_content ()
122
+
123
+ return resp
124
+
125
+ def get_clones (self , params : GetTTSVoiceClonesParams ) -> TextToSpeechResponse :
126
+ path = "/ai/tts/clone"
127
+ resp = Request (config = self .config , path = path , params = cast (Dict [Any , Any ], params ), verb = "get" ).perform_with_content ()
128
+ return resp
129
+
130
+ def delete_clone (self , voice_id : str ) -> TextToSpeechResponse :
131
+ path = f"/ai/tts/clone/{ voice_id } "
132
+ resp = Request (config = self .config , path = path , params = {}, verb = "delete" ).perform_with_content ()
121
133
return resp
122
134
123
135
@@ -140,7 +152,9 @@ def __init__(
140
152
@overload
141
153
async def speech_to_text (self , params : SpeechToTextParams ) -> SpeechToTextResponse : ...
142
154
@overload
143
- async def speech_to_text (self , file : bytes , options : Optional [SpeechToTextParams ] = None ) -> SpeechToTextResponse : ...
155
+ async def speech_to_text (
156
+ self , file : bytes , options : Optional [SpeechToTextParams ] = None
157
+ ) -> SpeechToTextResponse : ...
144
158
145
159
async def speech_to_text (
146
160
self ,
@@ -155,7 +169,7 @@ async def speech_to_text(
155
169
verb = "post" ,
156
170
).perform_with_content ()
157
171
return resp
158
-
172
+
159
173
options = options or {}
160
174
path = build_path (base_path = "/ai/transcribe" , params = options )
161
175
content_type = options .get ("content_type" , "application/octet-stream" )
@@ -190,3 +204,33 @@ async def speaker_voice_accents(self) -> TextToSpeechResponse:
190
204
verb = "get" ,
191
205
).perform_with_content ()
192
206
return resp
207
+
208
+ async def create_clone (self , params : TTSCloneParams ) -> TextToSpeechResponse :
209
+ path = "/ai/tts/clone"
210
+ resp = await AsyncRequest (
211
+ config = self .config ,
212
+ path = path ,
213
+ params = cast (Dict [Any , Any ], params ),
214
+ verb = "post"
215
+ ).perform_with_content ()
216
+ return resp
217
+
218
+ async def get_clones (self , params : GetTTSVoiceClonesParams ) -> TextToSpeechResponse :
219
+ path = "/ai/tts/clone"
220
+ resp = await AsyncRequest (
221
+ config = self .config ,
222
+ path = path ,
223
+ params = cast (Dict [Any , Any ], params ),
224
+ verb = "get"
225
+ ).perform_with_content ()
226
+ return resp
227
+
228
+ async def delete_clone (self , voice_id : str ) -> TextToSpeechResponse :
229
+ path = f"/ai/tts/clone/{ voice_id } "
230
+ resp = await AsyncRequest (
231
+ config = self .config ,
232
+ path = path ,
233
+ params = {},
234
+ verb = "delete"
235
+ ).perform_with_content ()
236
+ return resp
0 commit comments