@@ -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
@@ -68,14 +79,18 @@ def __init__(
68
79
@overload
69
80
def speech_to_text (self , params : SpeechToTextParams ) -> SpeechToTextResponse : ...
70
81
@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 : ...
72
85
73
86
def speech_to_text (
74
87
self ,
75
88
blob : Union [SpeechToTextParams , bytes ],
76
89
options : Optional [SpeechToTextParams ] = None ,
77
90
) -> 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
79
94
resp = Request (
80
95
config = self .config ,
81
96
path = "/ai/transcribe" ,
@@ -99,7 +114,6 @@ def speech_to_text(
99
114
).perform_with_content ()
100
115
return resp
101
116
102
-
103
117
def text_to_speech (self , params : TextToSpeechParams ) -> TextToSpeechResponse :
104
118
path = "/ai/tts"
105
119
resp = Request (
@@ -120,6 +134,37 @@ def speaker_voice_accents(self) -> TextToSpeechResponse:
120
134
).perform_with_content ()
121
135
return resp
122
136
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
+
123
168
124
169
class AsyncAudio (ClientConfig ):
125
170
config : AsyncRequestConfig
@@ -138,9 +183,13 @@ def __init__(
138
183
)
139
184
140
185
@overload
141
- async def speech_to_text (self , params : SpeechToTextParams ) -> SpeechToTextResponse : ...
186
+ async def speech_to_text (
187
+ self , params : SpeechToTextParams
188
+ ) -> SpeechToTextResponse : ...
142
189
@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 : ...
144
193
145
194
async def speech_to_text (
146
195
self ,
@@ -155,7 +204,7 @@ async def speech_to_text(
155
204
verb = "post" ,
156
205
).perform_with_content ()
157
206
return resp
158
-
207
+
159
208
options = options or {}
160
209
path = build_path (base_path = "/ai/transcribe" , params = options )
161
210
content_type = options .get ("content_type" , "application/octet-stream" )
0 commit comments