|
9 | 9 | from .helpers import build_path |
10 | 10 |
|
11 | 11 |
|
12 | | -class TextToSpeechParams(TypedDict): |
13 | | - text: str |
14 | | - accent: NotRequired[SupportedAccents] |
15 | | - speaker_clone_url: NotRequired[str] |
16 | | - speaker_clone_file_store_key: NotRequired[str] |
17 | | - return_type: NotRequired[Literal["url", "binary", "base64"]] |
18 | | - |
19 | | - |
20 | | -class TTSCloneParams(TypedDict): |
21 | | - url: NotRequired[str] |
22 | | - file_store_key: NotRequired[str] |
23 | | - name: str |
24 | | - |
25 | | - |
26 | | -class ListTTSVoiceClonesParams(TypedDict): |
27 | | - limit: NotRequired[int] |
28 | | - page: NotRequired[int] |
29 | | - |
30 | | - |
31 | | -class TextToSpeechResponse(TypedDict): |
32 | | - success: bool |
33 | | - text: str |
34 | | - chunks: List[object] |
35 | | - |
36 | 12 |
|
37 | 13 | class SpeechToTextParams(TypedDict): |
38 | 14 | url: NotRequired[str] |
@@ -102,36 +78,6 @@ def speech_to_text(self, blob: Union[SpeechToTextParams, bytes], options: Option |
102 | 78 | resp = Request(config=self.config, path=path, params=options, data=blob, headers=headers, verb="post").perform_with_content() |
103 | 79 | return resp |
104 | 80 |
|
105 | | - def text_to_speech(self, params: TextToSpeechParams) -> TextToSpeechResponse: |
106 | | - path = "/ai/tts" |
107 | | - resp = Request( |
108 | | - config=self.config, |
109 | | - path=path, |
110 | | - params=cast(Dict[Any, Any], params), |
111 | | - verb="post", |
112 | | - ).perform_with_content() |
113 | | - return resp |
114 | | - |
115 | | - def speaker_voice_accents(self) -> TextToSpeechResponse: |
116 | | - path = "/ai/tts" |
117 | | - resp = Request(config=self.config, path=path, params={}, verb="get").perform_with_content() |
118 | | - return resp |
119 | | - |
120 | | - def create_clone(self, params: TTSCloneParams) -> TextToSpeechResponse: |
121 | | - path = "/ai/tts/clone" |
122 | | - resp = Request(config=self.config, path=path, params=cast(Dict[Any, Any], params), verb="post").perform_with_content() |
123 | | - |
124 | | - return resp |
125 | | - |
126 | | - def list_clones(self, params: ListTTSVoiceClonesParams) -> TextToSpeechResponse: |
127 | | - path = "/ai/tts/clone" |
128 | | - resp = Request(config=self.config, path=path, params=cast(Dict[Any, Any], params), verb="get").perform_with_content() |
129 | | - return resp |
130 | | - |
131 | | - def delete_clone(self, voice_id: str) -> TextToSpeechResponse: |
132 | | - path = f"/ai/tts/clone/{voice_id}" |
133 | | - resp = Request(config=self.config, path=path, params={}, verb="delete").perform_with_content() |
134 | | - return resp |
135 | 81 |
|
136 | 82 |
|
137 | 83 | class AsyncAudio(ClientConfig): |
@@ -186,52 +132,3 @@ async def speech_to_text( |
186 | 132 | ).perform_with_content() |
187 | 133 | return resp |
188 | 134 |
|
189 | | - async def text_to_speech(self, params: TextToSpeechParams) -> TextToSpeechResponse: |
190 | | - path = "/ai/tts" |
191 | | - resp = await AsyncRequest( |
192 | | - config=self.config, |
193 | | - path=path, |
194 | | - params=cast(Dict[Any, Any], params), |
195 | | - verb="post", |
196 | | - ).perform_with_content() |
197 | | - return resp |
198 | | - |
199 | | - async def speaker_voice_accents(self) -> TextToSpeechResponse: |
200 | | - path = "/ai/tts" |
201 | | - resp = await AsyncRequest( |
202 | | - config=self.config, |
203 | | - path=path, |
204 | | - params={}, |
205 | | - verb="get", |
206 | | - ).perform_with_content() |
207 | | - return resp |
208 | | - |
209 | | - async def create_clone(self, params: TTSCloneParams) -> TextToSpeechResponse: |
210 | | - path = "/ai/tts/clone" |
211 | | - resp = await AsyncRequest( |
212 | | - config=self.config, |
213 | | - path=path, |
214 | | - params=cast(Dict[Any, Any], params), |
215 | | - verb="post" |
216 | | - ).perform_with_content() |
217 | | - return resp |
218 | | - |
219 | | - async def list_clones(self, params: ListTTSVoiceClonesParams) -> TextToSpeechResponse: |
220 | | - path = "/ai/tts/clone" |
221 | | - resp = await AsyncRequest( |
222 | | - config=self.config, |
223 | | - path=path, |
224 | | - params=cast(Dict[Any, Any], params), |
225 | | - verb="get" |
226 | | - ).perform_with_content() |
227 | | - return resp |
228 | | - |
229 | | - async def delete_clone(self, voice_id: str) -> TextToSpeechResponse: |
230 | | - path = f"/ai/tts/clone/{voice_id}" |
231 | | - resp = await AsyncRequest( |
232 | | - config=self.config, |
233 | | - path=path, |
234 | | - params={}, |
235 | | - verb="delete" |
236 | | - ).perform_with_content() |
237 | | - return resp |
0 commit comments