murf 1.2.3__py3-none-any.whl → 2.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of murf might be problematic. Click here for more details.
- murf/__init__.py +37 -1
- murf/auth/client.py +11 -9
- murf/base_client.py +3 -20
- murf/client.py +0 -8
- murf/core/__init__.py +4 -0
- murf/core/client_wrapper.py +18 -17
- murf/core/http_client.py +6 -6
- murf/core/pydantic_utilities.py +2 -2
- murf/core/unchecked_base_model.py +305 -0
- murf/dubbing/jobs/client.py +37 -31
- murf/dubbing/languages/client.py +25 -21
- murf/dubbing/projects/client.py +37 -31
- murf/dubbing_client.py +0 -8
- murf/environment.py +10 -3
- murf/stream_input/__init__.py +5 -0
- murf/stream_input/types/__init__.py +6 -0
- murf/stream_input/types/receive_message.py +7 -0
- murf/stream_input/types/send_message.py +9 -0
- murf/text/client.py +15 -13
- murf/text_to_speech/client.py +79 -37
- murf/types/__init__.py +44 -0
- murf/types/api_job_response.py +2 -2
- murf/types/api_project_response.py +2 -2
- murf/types/api_voice.py +2 -2
- murf/types/audio_output.py +27 -0
- murf/types/auth_token_response.py +2 -2
- murf/types/character_count.py +2 -2
- murf/types/clear_context.py +20 -0
- murf/types/dub_api_detail_response.py +2 -2
- murf/types/dub_job_status_response.py +2 -2
- murf/types/final_output.py +27 -0
- murf/types/form_data_content_disposition.py +2 -2
- murf/types/generate_speech_response.py +2 -2
- murf/types/group_api_project_response.py +2 -2
- murf/types/locale_response.py +2 -2
- murf/types/metadata.py +2 -2
- murf/types/murf_api_translation_response.py +2 -2
- murf/types/pronunciation_detail.py +2 -2
- murf/types/send_text.py +35 -0
- murf/types/send_text_voice_config.py +55 -0
- murf/types/send_text_voice_config_pronunciation_dictionary_value.py +30 -0
- murf/types/send_text_voice_config_pronunciation_dictionary_value_type.py +5 -0
- murf/types/set_advanced_settings.py +20 -0
- murf/types/set_voice_configuration_or_initialize_context.py +26 -0
- murf/types/set_voice_configuration_or_initialize_context_voice_config.py +57 -0
- murf/types/set_voice_configuration_or_initialize_context_voice_config_pronunciation_dictionary_value.py +30 -0
- murf/types/set_voice_configuration_or_initialize_context_voice_config_pronunciation_dictionary_value_type.py +7 -0
- murf/types/source_locale_response.py +2 -2
- murf/types/speech_to_speech_response.py +2 -2
- murf/types/style_details.py +2 -2
- murf/types/translation.py +2 -2
- murf/types/tts_request_both_payload.py +29 -0
- murf/types/tts_request_both_payload_voice_config.py +44 -0
- murf/types/tts_request_both_payload_voice_config_pronunciation_dictionary.py +22 -0
- murf/types/tts_request_both_payload_voice_config_pronunciation_dictionary_guess.py +20 -0
- murf/types/word_duration_response.py +2 -2
- murf/voice_changer/client.py +29 -23
- {murf-1.2.3.dist-info → murf-2.0.1.dist-info}/METADATA +1 -1
- murf-2.0.1.dist-info/RECORD +101 -0
- murf-1.2.3.dist-info/RECORD +0 -80
- {murf-1.2.3.dist-info → murf-2.0.1.dist-info}/LICENSE +0 -0
- {murf-1.2.3.dist-info → murf-2.0.1.dist-info}/WHEEL +0 -0
murf/text/client.py
CHANGED
|
@@ -4,7 +4,7 @@ import typing
|
|
|
4
4
|
from ..core.client_wrapper import SyncClientWrapper
|
|
5
5
|
from ..core.request_options import RequestOptions
|
|
6
6
|
from ..types.murf_api_translation_response import MurfApiTranslationResponse
|
|
7
|
-
from ..core.
|
|
7
|
+
from ..core.unchecked_base_model import construct_type
|
|
8
8
|
from ..errors.bad_request_error import BadRequestError
|
|
9
9
|
from ..errors.payment_required_error import PaymentRequiredError
|
|
10
10
|
from ..errors.forbidden_error import ForbiddenError
|
|
@@ -60,6 +60,7 @@ class TextClient:
|
|
|
60
60
|
"""
|
|
61
61
|
_response = self._client_wrapper.httpx_client.request(
|
|
62
62
|
"v1/text/translate",
|
|
63
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
63
64
|
method="POST",
|
|
64
65
|
json={
|
|
65
66
|
"targetLanguage": target_language,
|
|
@@ -75,7 +76,7 @@ class TextClient:
|
|
|
75
76
|
if 200 <= _response.status_code < 300:
|
|
76
77
|
return typing.cast(
|
|
77
78
|
MurfApiTranslationResponse,
|
|
78
|
-
|
|
79
|
+
construct_type(
|
|
79
80
|
type_=MurfApiTranslationResponse, # type: ignore
|
|
80
81
|
object_=_response.json(),
|
|
81
82
|
),
|
|
@@ -84,7 +85,7 @@ class TextClient:
|
|
|
84
85
|
raise BadRequestError(
|
|
85
86
|
typing.cast(
|
|
86
87
|
typing.Optional[typing.Any],
|
|
87
|
-
|
|
88
|
+
construct_type(
|
|
88
89
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
89
90
|
object_=_response.json(),
|
|
90
91
|
),
|
|
@@ -94,7 +95,7 @@ class TextClient:
|
|
|
94
95
|
raise PaymentRequiredError(
|
|
95
96
|
typing.cast(
|
|
96
97
|
typing.Optional[typing.Any],
|
|
97
|
-
|
|
98
|
+
construct_type(
|
|
98
99
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
99
100
|
object_=_response.json(),
|
|
100
101
|
),
|
|
@@ -104,7 +105,7 @@ class TextClient:
|
|
|
104
105
|
raise ForbiddenError(
|
|
105
106
|
typing.cast(
|
|
106
107
|
typing.Optional[typing.Any],
|
|
107
|
-
|
|
108
|
+
construct_type(
|
|
108
109
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
109
110
|
object_=_response.json(),
|
|
110
111
|
),
|
|
@@ -114,7 +115,7 @@ class TextClient:
|
|
|
114
115
|
raise InternalServerError(
|
|
115
116
|
typing.cast(
|
|
116
117
|
typing.Optional[typing.Any],
|
|
117
|
-
|
|
118
|
+
construct_type(
|
|
118
119
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
119
120
|
object_=_response.json(),
|
|
120
121
|
),
|
|
@@ -124,7 +125,7 @@ class TextClient:
|
|
|
124
125
|
raise ServiceUnavailableError(
|
|
125
126
|
typing.cast(
|
|
126
127
|
typing.Optional[typing.Any],
|
|
127
|
-
|
|
128
|
+
construct_type(
|
|
128
129
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
129
130
|
object_=_response.json(),
|
|
130
131
|
),
|
|
@@ -186,6 +187,7 @@ class AsyncTextClient:
|
|
|
186
187
|
"""
|
|
187
188
|
_response = await self._client_wrapper.httpx_client.request(
|
|
188
189
|
"v1/text/translate",
|
|
190
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
189
191
|
method="POST",
|
|
190
192
|
json={
|
|
191
193
|
"targetLanguage": target_language,
|
|
@@ -201,7 +203,7 @@ class AsyncTextClient:
|
|
|
201
203
|
if 200 <= _response.status_code < 300:
|
|
202
204
|
return typing.cast(
|
|
203
205
|
MurfApiTranslationResponse,
|
|
204
|
-
|
|
206
|
+
construct_type(
|
|
205
207
|
type_=MurfApiTranslationResponse, # type: ignore
|
|
206
208
|
object_=_response.json(),
|
|
207
209
|
),
|
|
@@ -210,7 +212,7 @@ class AsyncTextClient:
|
|
|
210
212
|
raise BadRequestError(
|
|
211
213
|
typing.cast(
|
|
212
214
|
typing.Optional[typing.Any],
|
|
213
|
-
|
|
215
|
+
construct_type(
|
|
214
216
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
215
217
|
object_=_response.json(),
|
|
216
218
|
),
|
|
@@ -220,7 +222,7 @@ class AsyncTextClient:
|
|
|
220
222
|
raise PaymentRequiredError(
|
|
221
223
|
typing.cast(
|
|
222
224
|
typing.Optional[typing.Any],
|
|
223
|
-
|
|
225
|
+
construct_type(
|
|
224
226
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
225
227
|
object_=_response.json(),
|
|
226
228
|
),
|
|
@@ -230,7 +232,7 @@ class AsyncTextClient:
|
|
|
230
232
|
raise ForbiddenError(
|
|
231
233
|
typing.cast(
|
|
232
234
|
typing.Optional[typing.Any],
|
|
233
|
-
|
|
235
|
+
construct_type(
|
|
234
236
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
235
237
|
object_=_response.json(),
|
|
236
238
|
),
|
|
@@ -240,7 +242,7 @@ class AsyncTextClient:
|
|
|
240
242
|
raise InternalServerError(
|
|
241
243
|
typing.cast(
|
|
242
244
|
typing.Optional[typing.Any],
|
|
243
|
-
|
|
245
|
+
construct_type(
|
|
244
246
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
245
247
|
object_=_response.json(),
|
|
246
248
|
),
|
|
@@ -250,7 +252,7 @@ class AsyncTextClient:
|
|
|
250
252
|
raise ServiceUnavailableError(
|
|
251
253
|
typing.cast(
|
|
252
254
|
typing.Optional[typing.Any],
|
|
253
|
-
|
|
255
|
+
construct_type(
|
|
254
256
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
255
257
|
object_=_response.json(),
|
|
256
258
|
),
|
murf/text_to_speech/client.py
CHANGED
|
@@ -7,7 +7,7 @@ from ..types.pronunciation_detail import PronunciationDetail
|
|
|
7
7
|
from ..core.request_options import RequestOptions
|
|
8
8
|
from ..types.generate_speech_response import GenerateSpeechResponse
|
|
9
9
|
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
10
|
-
from ..core.
|
|
10
|
+
from ..core.unchecked_base_model import construct_type
|
|
11
11
|
from ..errors.bad_request_error import BadRequestError
|
|
12
12
|
from ..errors.payment_required_error import PaymentRequiredError
|
|
13
13
|
from ..errors.forbidden_error import ForbiddenError
|
|
@@ -43,6 +43,7 @@ class TextToSpeechClient:
|
|
|
43
43
|
sample_rate: typing.Optional[float] = OMIT,
|
|
44
44
|
style: typing.Optional[str] = OMIT,
|
|
45
45
|
variation: typing.Optional[int] = OMIT,
|
|
46
|
+
word_durations_as_original_text: typing.Optional[bool] = OMIT,
|
|
46
47
|
request_options: typing.Optional[RequestOptions] = None,
|
|
47
48
|
) -> GenerateSpeechResponse:
|
|
48
49
|
"""
|
|
@@ -66,7 +67,7 @@ class TextToSpeechClient:
|
|
|
66
67
|
Set to true to receive audio in response as a Base64 encoded string instead of a url.
|
|
67
68
|
|
|
68
69
|
format : typing.Optional[str]
|
|
69
|
-
Format of the generated audio file. Valid values: MP3, WAV, FLAC, ALAW, ULAW
|
|
70
|
+
Format of the generated audio file. Valid values: MP3, WAV, FLAC, ALAW, ULAW, PCM, OGG
|
|
70
71
|
|
|
71
72
|
model_version : typing.Optional[GenerateSpeechRequestModelVersion]
|
|
72
73
|
Valid values: GEN1, GEN2. Use GEN2 to generate audio using new and advanced model. Outputs from Gen 2 will sound better, but different from the old model
|
|
@@ -97,6 +98,9 @@ class TextToSpeechClient:
|
|
|
97
98
|
variation : typing.Optional[int]
|
|
98
99
|
Higher values will add more variation in terms of Pause, Pitch, and Speed to the voice. Only available for Gen2 model.
|
|
99
100
|
|
|
101
|
+
word_durations_as_original_text : typing.Optional[bool]
|
|
102
|
+
If set to true, the word durations in response will return words as the original input text. (English only)
|
|
103
|
+
|
|
100
104
|
request_options : typing.Optional[RequestOptions]
|
|
101
105
|
Request-specific configuration.
|
|
102
106
|
|
|
@@ -119,6 +123,7 @@ class TextToSpeechClient:
|
|
|
119
123
|
"""
|
|
120
124
|
_response = self._client_wrapper.httpx_client.request(
|
|
121
125
|
"v1/speech/generate",
|
|
126
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
122
127
|
method="POST",
|
|
123
128
|
json={
|
|
124
129
|
"audioDuration": audio_duration,
|
|
@@ -139,6 +144,7 @@ class TextToSpeechClient:
|
|
|
139
144
|
"text": text,
|
|
140
145
|
"variation": variation,
|
|
141
146
|
"voiceId": voice_id,
|
|
147
|
+
"wordDurationsAsOriginalText": word_durations_as_original_text,
|
|
142
148
|
},
|
|
143
149
|
headers={
|
|
144
150
|
"content-type": "application/json",
|
|
@@ -150,7 +156,7 @@ class TextToSpeechClient:
|
|
|
150
156
|
if 200 <= _response.status_code < 300:
|
|
151
157
|
return typing.cast(
|
|
152
158
|
GenerateSpeechResponse,
|
|
153
|
-
|
|
159
|
+
construct_type(
|
|
154
160
|
type_=GenerateSpeechResponse, # type: ignore
|
|
155
161
|
object_=_response.json(),
|
|
156
162
|
),
|
|
@@ -159,7 +165,7 @@ class TextToSpeechClient:
|
|
|
159
165
|
raise BadRequestError(
|
|
160
166
|
typing.cast(
|
|
161
167
|
typing.Optional[typing.Any],
|
|
162
|
-
|
|
168
|
+
construct_type(
|
|
163
169
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
164
170
|
object_=_response.json(),
|
|
165
171
|
),
|
|
@@ -169,7 +175,7 @@ class TextToSpeechClient:
|
|
|
169
175
|
raise PaymentRequiredError(
|
|
170
176
|
typing.cast(
|
|
171
177
|
typing.Optional[typing.Any],
|
|
172
|
-
|
|
178
|
+
construct_type(
|
|
173
179
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
174
180
|
object_=_response.json(),
|
|
175
181
|
),
|
|
@@ -179,7 +185,7 @@ class TextToSpeechClient:
|
|
|
179
185
|
raise ForbiddenError(
|
|
180
186
|
typing.cast(
|
|
181
187
|
typing.Optional[typing.Any],
|
|
182
|
-
|
|
188
|
+
construct_type(
|
|
183
189
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
184
190
|
object_=_response.json(),
|
|
185
191
|
),
|
|
@@ -189,7 +195,7 @@ class TextToSpeechClient:
|
|
|
189
195
|
raise InternalServerError(
|
|
190
196
|
typing.cast(
|
|
191
197
|
typing.Optional[typing.Any],
|
|
192
|
-
|
|
198
|
+
construct_type(
|
|
193
199
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
194
200
|
object_=_response.json(),
|
|
195
201
|
),
|
|
@@ -199,7 +205,7 @@ class TextToSpeechClient:
|
|
|
199
205
|
raise ServiceUnavailableError(
|
|
200
206
|
typing.cast(
|
|
201
207
|
typing.Optional[typing.Any],
|
|
202
|
-
|
|
208
|
+
construct_type(
|
|
203
209
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
204
210
|
object_=_response.json(),
|
|
205
211
|
),
|
|
@@ -219,6 +225,7 @@ class TextToSpeechClient:
|
|
|
219
225
|
format: typing.Optional[str] = OMIT,
|
|
220
226
|
multi_native_locale: typing.Optional[str] = OMIT,
|
|
221
227
|
pitch: typing.Optional[int] = OMIT,
|
|
228
|
+
pronunciation_dictionary: typing.Optional[typing.Dict[str, PronunciationDetail]] = OMIT,
|
|
222
229
|
rate: typing.Optional[int] = OMIT,
|
|
223
230
|
sample_rate: typing.Optional[float] = OMIT,
|
|
224
231
|
style: typing.Optional[str] = OMIT,
|
|
@@ -240,7 +247,7 @@ class TextToSpeechClient:
|
|
|
240
247
|
Valid values: STEREO, MONO
|
|
241
248
|
|
|
242
249
|
format : typing.Optional[str]
|
|
243
|
-
Format of the generated audio file. Valid values: MP3, WAV
|
|
250
|
+
Format of the generated audio file. Valid values: MP3, WAV, PCM
|
|
244
251
|
|
|
245
252
|
multi_native_locale : typing.Optional[str]
|
|
246
253
|
Specifies the language for the generated audio, enabling a voice to speak in multiple languages natively. Only available in the Gen2 model.
|
|
@@ -249,6 +256,13 @@ class TextToSpeechClient:
|
|
|
249
256
|
pitch : typing.Optional[int]
|
|
250
257
|
Pitch of the voiceover
|
|
251
258
|
|
|
259
|
+
pronunciation_dictionary : typing.Optional[typing.Dict[str, PronunciationDetail]]
|
|
260
|
+
An object used to define custom pronunciations.
|
|
261
|
+
|
|
262
|
+
Example 1: {"live":{"type": "IPA", "pronunciation": "laɪv"}}.
|
|
263
|
+
|
|
264
|
+
Example 2: {"2022":{"type": "SAY_AS", "pronunciation": "twenty twenty two"}}
|
|
265
|
+
|
|
252
266
|
rate : typing.Optional[int]
|
|
253
267
|
Speed of the voiceover
|
|
254
268
|
|
|
@@ -280,12 +294,18 @@ class TextToSpeechClient:
|
|
|
280
294
|
"""
|
|
281
295
|
with self._client_wrapper.httpx_client.stream(
|
|
282
296
|
"v1/speech/stream",
|
|
297
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
283
298
|
method="POST",
|
|
284
299
|
json={
|
|
285
300
|
"channelType": channel_type,
|
|
286
301
|
"format": format,
|
|
287
302
|
"multiNativeLocale": multi_native_locale,
|
|
288
303
|
"pitch": pitch,
|
|
304
|
+
"pronunciationDictionary": convert_and_respect_annotation_metadata(
|
|
305
|
+
object_=pronunciation_dictionary,
|
|
306
|
+
annotation=typing.Dict[str, PronunciationDetail],
|
|
307
|
+
direction="write",
|
|
308
|
+
),
|
|
289
309
|
"rate": rate,
|
|
290
310
|
"sampleRate": sample_rate,
|
|
291
311
|
"style": style,
|
|
@@ -310,7 +330,7 @@ class TextToSpeechClient:
|
|
|
310
330
|
raise BadRequestError(
|
|
311
331
|
typing.cast(
|
|
312
332
|
typing.Optional[typing.Any],
|
|
313
|
-
|
|
333
|
+
construct_type(
|
|
314
334
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
315
335
|
object_=_response.json(),
|
|
316
336
|
),
|
|
@@ -320,7 +340,7 @@ class TextToSpeechClient:
|
|
|
320
340
|
raise PaymentRequiredError(
|
|
321
341
|
typing.cast(
|
|
322
342
|
typing.Optional[typing.Any],
|
|
323
|
-
|
|
343
|
+
construct_type(
|
|
324
344
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
325
345
|
object_=_response.json(),
|
|
326
346
|
),
|
|
@@ -330,7 +350,7 @@ class TextToSpeechClient:
|
|
|
330
350
|
raise ForbiddenError(
|
|
331
351
|
typing.cast(
|
|
332
352
|
typing.Optional[typing.Any],
|
|
333
|
-
|
|
353
|
+
construct_type(
|
|
334
354
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
335
355
|
object_=_response.json(),
|
|
336
356
|
),
|
|
@@ -340,7 +360,7 @@ class TextToSpeechClient:
|
|
|
340
360
|
raise InternalServerError(
|
|
341
361
|
typing.cast(
|
|
342
362
|
typing.Optional[typing.Any],
|
|
343
|
-
|
|
363
|
+
construct_type(
|
|
344
364
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
345
365
|
object_=_response.json(),
|
|
346
366
|
),
|
|
@@ -350,7 +370,7 @@ class TextToSpeechClient:
|
|
|
350
370
|
raise ServiceUnavailableError(
|
|
351
371
|
typing.cast(
|
|
352
372
|
typing.Optional[typing.Any],
|
|
353
|
-
|
|
373
|
+
construct_type(
|
|
354
374
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
355
375
|
object_=_response.json(),
|
|
356
376
|
),
|
|
@@ -390,6 +410,7 @@ class TextToSpeechClient:
|
|
|
390
410
|
"""
|
|
391
411
|
_response = self._client_wrapper.httpx_client.request(
|
|
392
412
|
"v1/speech/voices",
|
|
413
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
393
414
|
method="GET",
|
|
394
415
|
headers={
|
|
395
416
|
"token": str(token) if token is not None else None,
|
|
@@ -400,7 +421,7 @@ class TextToSpeechClient:
|
|
|
400
421
|
if 200 <= _response.status_code < 300:
|
|
401
422
|
return typing.cast(
|
|
402
423
|
typing.List[ApiVoice],
|
|
403
|
-
|
|
424
|
+
construct_type(
|
|
404
425
|
type_=typing.List[ApiVoice], # type: ignore
|
|
405
426
|
object_=_response.json(),
|
|
406
427
|
),
|
|
@@ -409,7 +430,7 @@ class TextToSpeechClient:
|
|
|
409
430
|
raise BadRequestError(
|
|
410
431
|
typing.cast(
|
|
411
432
|
typing.Optional[typing.Any],
|
|
412
|
-
|
|
433
|
+
construct_type(
|
|
413
434
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
414
435
|
object_=_response.json(),
|
|
415
436
|
),
|
|
@@ -419,7 +440,7 @@ class TextToSpeechClient:
|
|
|
419
440
|
raise ForbiddenError(
|
|
420
441
|
typing.cast(
|
|
421
442
|
typing.Optional[typing.Any],
|
|
422
|
-
|
|
443
|
+
construct_type(
|
|
423
444
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
424
445
|
object_=_response.json(),
|
|
425
446
|
),
|
|
@@ -429,7 +450,7 @@ class TextToSpeechClient:
|
|
|
429
450
|
raise InternalServerError(
|
|
430
451
|
typing.cast(
|
|
431
452
|
typing.Optional[typing.Any],
|
|
432
|
-
|
|
453
|
+
construct_type(
|
|
433
454
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
434
455
|
object_=_response.json(),
|
|
435
456
|
),
|
|
@@ -439,7 +460,7 @@ class TextToSpeechClient:
|
|
|
439
460
|
raise ServiceUnavailableError(
|
|
440
461
|
typing.cast(
|
|
441
462
|
typing.Optional[typing.Any],
|
|
442
|
-
|
|
463
|
+
construct_type(
|
|
443
464
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
444
465
|
object_=_response.json(),
|
|
445
466
|
),
|
|
@@ -472,6 +493,7 @@ class AsyncTextToSpeechClient:
|
|
|
472
493
|
sample_rate: typing.Optional[float] = OMIT,
|
|
473
494
|
style: typing.Optional[str] = OMIT,
|
|
474
495
|
variation: typing.Optional[int] = OMIT,
|
|
496
|
+
word_durations_as_original_text: typing.Optional[bool] = OMIT,
|
|
475
497
|
request_options: typing.Optional[RequestOptions] = None,
|
|
476
498
|
) -> GenerateSpeechResponse:
|
|
477
499
|
"""
|
|
@@ -495,7 +517,7 @@ class AsyncTextToSpeechClient:
|
|
|
495
517
|
Set to true to receive audio in response as a Base64 encoded string instead of a url.
|
|
496
518
|
|
|
497
519
|
format : typing.Optional[str]
|
|
498
|
-
Format of the generated audio file. Valid values: MP3, WAV, FLAC, ALAW, ULAW
|
|
520
|
+
Format of the generated audio file. Valid values: MP3, WAV, FLAC, ALAW, ULAW, PCM, OGG
|
|
499
521
|
|
|
500
522
|
model_version : typing.Optional[GenerateSpeechRequestModelVersion]
|
|
501
523
|
Valid values: GEN1, GEN2. Use GEN2 to generate audio using new and advanced model. Outputs from Gen 2 will sound better, but different from the old model
|
|
@@ -526,6 +548,9 @@ class AsyncTextToSpeechClient:
|
|
|
526
548
|
variation : typing.Optional[int]
|
|
527
549
|
Higher values will add more variation in terms of Pause, Pitch, and Speed to the voice. Only available for Gen2 model.
|
|
528
550
|
|
|
551
|
+
word_durations_as_original_text : typing.Optional[bool]
|
|
552
|
+
If set to true, the word durations in response will return words as the original input text. (English only)
|
|
553
|
+
|
|
529
554
|
request_options : typing.Optional[RequestOptions]
|
|
530
555
|
Request-specific configuration.
|
|
531
556
|
|
|
@@ -556,6 +581,7 @@ class AsyncTextToSpeechClient:
|
|
|
556
581
|
"""
|
|
557
582
|
_response = await self._client_wrapper.httpx_client.request(
|
|
558
583
|
"v1/speech/generate",
|
|
584
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
559
585
|
method="POST",
|
|
560
586
|
json={
|
|
561
587
|
"audioDuration": audio_duration,
|
|
@@ -576,6 +602,7 @@ class AsyncTextToSpeechClient:
|
|
|
576
602
|
"text": text,
|
|
577
603
|
"variation": variation,
|
|
578
604
|
"voiceId": voice_id,
|
|
605
|
+
"wordDurationsAsOriginalText": word_durations_as_original_text,
|
|
579
606
|
},
|
|
580
607
|
headers={
|
|
581
608
|
"content-type": "application/json",
|
|
@@ -587,7 +614,7 @@ class AsyncTextToSpeechClient:
|
|
|
587
614
|
if 200 <= _response.status_code < 300:
|
|
588
615
|
return typing.cast(
|
|
589
616
|
GenerateSpeechResponse,
|
|
590
|
-
|
|
617
|
+
construct_type(
|
|
591
618
|
type_=GenerateSpeechResponse, # type: ignore
|
|
592
619
|
object_=_response.json(),
|
|
593
620
|
),
|
|
@@ -596,7 +623,7 @@ class AsyncTextToSpeechClient:
|
|
|
596
623
|
raise BadRequestError(
|
|
597
624
|
typing.cast(
|
|
598
625
|
typing.Optional[typing.Any],
|
|
599
|
-
|
|
626
|
+
construct_type(
|
|
600
627
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
601
628
|
object_=_response.json(),
|
|
602
629
|
),
|
|
@@ -606,7 +633,7 @@ class AsyncTextToSpeechClient:
|
|
|
606
633
|
raise PaymentRequiredError(
|
|
607
634
|
typing.cast(
|
|
608
635
|
typing.Optional[typing.Any],
|
|
609
|
-
|
|
636
|
+
construct_type(
|
|
610
637
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
611
638
|
object_=_response.json(),
|
|
612
639
|
),
|
|
@@ -616,7 +643,7 @@ class AsyncTextToSpeechClient:
|
|
|
616
643
|
raise ForbiddenError(
|
|
617
644
|
typing.cast(
|
|
618
645
|
typing.Optional[typing.Any],
|
|
619
|
-
|
|
646
|
+
construct_type(
|
|
620
647
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
621
648
|
object_=_response.json(),
|
|
622
649
|
),
|
|
@@ -626,7 +653,7 @@ class AsyncTextToSpeechClient:
|
|
|
626
653
|
raise InternalServerError(
|
|
627
654
|
typing.cast(
|
|
628
655
|
typing.Optional[typing.Any],
|
|
629
|
-
|
|
656
|
+
construct_type(
|
|
630
657
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
631
658
|
object_=_response.json(),
|
|
632
659
|
),
|
|
@@ -636,7 +663,7 @@ class AsyncTextToSpeechClient:
|
|
|
636
663
|
raise ServiceUnavailableError(
|
|
637
664
|
typing.cast(
|
|
638
665
|
typing.Optional[typing.Any],
|
|
639
|
-
|
|
666
|
+
construct_type(
|
|
640
667
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
641
668
|
object_=_response.json(),
|
|
642
669
|
),
|
|
@@ -656,6 +683,7 @@ class AsyncTextToSpeechClient:
|
|
|
656
683
|
format: typing.Optional[str] = OMIT,
|
|
657
684
|
multi_native_locale: typing.Optional[str] = OMIT,
|
|
658
685
|
pitch: typing.Optional[int] = OMIT,
|
|
686
|
+
pronunciation_dictionary: typing.Optional[typing.Dict[str, PronunciationDetail]] = OMIT,
|
|
659
687
|
rate: typing.Optional[int] = OMIT,
|
|
660
688
|
sample_rate: typing.Optional[float] = OMIT,
|
|
661
689
|
style: typing.Optional[str] = OMIT,
|
|
@@ -677,7 +705,7 @@ class AsyncTextToSpeechClient:
|
|
|
677
705
|
Valid values: STEREO, MONO
|
|
678
706
|
|
|
679
707
|
format : typing.Optional[str]
|
|
680
|
-
Format of the generated audio file. Valid values: MP3, WAV
|
|
708
|
+
Format of the generated audio file. Valid values: MP3, WAV, PCM
|
|
681
709
|
|
|
682
710
|
multi_native_locale : typing.Optional[str]
|
|
683
711
|
Specifies the language for the generated audio, enabling a voice to speak in multiple languages natively. Only available in the Gen2 model.
|
|
@@ -686,6 +714,13 @@ class AsyncTextToSpeechClient:
|
|
|
686
714
|
pitch : typing.Optional[int]
|
|
687
715
|
Pitch of the voiceover
|
|
688
716
|
|
|
717
|
+
pronunciation_dictionary : typing.Optional[typing.Dict[str, PronunciationDetail]]
|
|
718
|
+
An object used to define custom pronunciations.
|
|
719
|
+
|
|
720
|
+
Example 1: {"live":{"type": "IPA", "pronunciation": "laɪv"}}.
|
|
721
|
+
|
|
722
|
+
Example 2: {"2022":{"type": "SAY_AS", "pronunciation": "twenty twenty two"}}
|
|
723
|
+
|
|
689
724
|
rate : typing.Optional[int]
|
|
690
725
|
Speed of the voiceover
|
|
691
726
|
|
|
@@ -725,12 +760,18 @@ class AsyncTextToSpeechClient:
|
|
|
725
760
|
"""
|
|
726
761
|
async with self._client_wrapper.httpx_client.stream(
|
|
727
762
|
"v1/speech/stream",
|
|
763
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
728
764
|
method="POST",
|
|
729
765
|
json={
|
|
730
766
|
"channelType": channel_type,
|
|
731
767
|
"format": format,
|
|
732
768
|
"multiNativeLocale": multi_native_locale,
|
|
733
769
|
"pitch": pitch,
|
|
770
|
+
"pronunciationDictionary": convert_and_respect_annotation_metadata(
|
|
771
|
+
object_=pronunciation_dictionary,
|
|
772
|
+
annotation=typing.Dict[str, PronunciationDetail],
|
|
773
|
+
direction="write",
|
|
774
|
+
),
|
|
734
775
|
"rate": rate,
|
|
735
776
|
"sampleRate": sample_rate,
|
|
736
777
|
"style": style,
|
|
@@ -755,7 +796,7 @@ class AsyncTextToSpeechClient:
|
|
|
755
796
|
raise BadRequestError(
|
|
756
797
|
typing.cast(
|
|
757
798
|
typing.Optional[typing.Any],
|
|
758
|
-
|
|
799
|
+
construct_type(
|
|
759
800
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
760
801
|
object_=_response.json(),
|
|
761
802
|
),
|
|
@@ -765,7 +806,7 @@ class AsyncTextToSpeechClient:
|
|
|
765
806
|
raise PaymentRequiredError(
|
|
766
807
|
typing.cast(
|
|
767
808
|
typing.Optional[typing.Any],
|
|
768
|
-
|
|
809
|
+
construct_type(
|
|
769
810
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
770
811
|
object_=_response.json(),
|
|
771
812
|
),
|
|
@@ -775,7 +816,7 @@ class AsyncTextToSpeechClient:
|
|
|
775
816
|
raise ForbiddenError(
|
|
776
817
|
typing.cast(
|
|
777
818
|
typing.Optional[typing.Any],
|
|
778
|
-
|
|
819
|
+
construct_type(
|
|
779
820
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
780
821
|
object_=_response.json(),
|
|
781
822
|
),
|
|
@@ -785,7 +826,7 @@ class AsyncTextToSpeechClient:
|
|
|
785
826
|
raise InternalServerError(
|
|
786
827
|
typing.cast(
|
|
787
828
|
typing.Optional[typing.Any],
|
|
788
|
-
|
|
829
|
+
construct_type(
|
|
789
830
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
790
831
|
object_=_response.json(),
|
|
791
832
|
),
|
|
@@ -795,7 +836,7 @@ class AsyncTextToSpeechClient:
|
|
|
795
836
|
raise ServiceUnavailableError(
|
|
796
837
|
typing.cast(
|
|
797
838
|
typing.Optional[typing.Any],
|
|
798
|
-
|
|
839
|
+
construct_type(
|
|
799
840
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
800
841
|
object_=_response.json(),
|
|
801
842
|
),
|
|
@@ -843,6 +884,7 @@ class AsyncTextToSpeechClient:
|
|
|
843
884
|
"""
|
|
844
885
|
_response = await self._client_wrapper.httpx_client.request(
|
|
845
886
|
"v1/speech/voices",
|
|
887
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
846
888
|
method="GET",
|
|
847
889
|
headers={
|
|
848
890
|
"token": str(token) if token is not None else None,
|
|
@@ -853,7 +895,7 @@ class AsyncTextToSpeechClient:
|
|
|
853
895
|
if 200 <= _response.status_code < 300:
|
|
854
896
|
return typing.cast(
|
|
855
897
|
typing.List[ApiVoice],
|
|
856
|
-
|
|
898
|
+
construct_type(
|
|
857
899
|
type_=typing.List[ApiVoice], # type: ignore
|
|
858
900
|
object_=_response.json(),
|
|
859
901
|
),
|
|
@@ -862,7 +904,7 @@ class AsyncTextToSpeechClient:
|
|
|
862
904
|
raise BadRequestError(
|
|
863
905
|
typing.cast(
|
|
864
906
|
typing.Optional[typing.Any],
|
|
865
|
-
|
|
907
|
+
construct_type(
|
|
866
908
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
867
909
|
object_=_response.json(),
|
|
868
910
|
),
|
|
@@ -872,7 +914,7 @@ class AsyncTextToSpeechClient:
|
|
|
872
914
|
raise ForbiddenError(
|
|
873
915
|
typing.cast(
|
|
874
916
|
typing.Optional[typing.Any],
|
|
875
|
-
|
|
917
|
+
construct_type(
|
|
876
918
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
877
919
|
object_=_response.json(),
|
|
878
920
|
),
|
|
@@ -882,7 +924,7 @@ class AsyncTextToSpeechClient:
|
|
|
882
924
|
raise InternalServerError(
|
|
883
925
|
typing.cast(
|
|
884
926
|
typing.Optional[typing.Any],
|
|
885
|
-
|
|
927
|
+
construct_type(
|
|
886
928
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
887
929
|
object_=_response.json(),
|
|
888
930
|
),
|
|
@@ -892,7 +934,7 @@ class AsyncTextToSpeechClient:
|
|
|
892
934
|
raise ServiceUnavailableError(
|
|
893
935
|
typing.cast(
|
|
894
936
|
typing.Optional[typing.Any],
|
|
895
|
-
|
|
937
|
+
construct_type(
|
|
896
938
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
897
939
|
object_=_response.json(),
|
|
898
940
|
),
|