@@ -319,6 +319,7 @@ async def synthesize(self, text: str, voice: str, **kwargs):
319319 - `speed` (float): Floating point value between 0.25 (slow) and 2.0 (fast); Defaults to 1.0
320320 - `return_durations` (bool): If `True`, the response will include word durations detail. Defaults to `False`.
321321 - `return_seed` (bool): If `True`, the response will include the seed used for synthesis. Defaults to `False`.
322+ - `language` (str): The desired language of the synthesized speech. Two letter ISO 639-1 code. Defaults to `en`.
322323 - `length` (int): The desired target length of the output speech in seconds. Maximum 300.0 (5 minutes)
323324
324325 Deprecated parameters:
@@ -362,7 +363,8 @@ async def synthesize(self, text: str, voice: str, **kwargs):
362363 if return_durations is True :
363364 form_data .add_field ('return_durations' , 'true' )
364365 return_seed = kwargs .get ('return_seed' , False )
365-
366+ if 'language' in kwargs :
367+ form_data .add_field ('language' , kwargs .get ('language' ))
366368 async with self ._session .post (url , data = form_data , headers = self ._build_headers ()) as resp :
367369 await self ._handle_response_errors (resp , 'Speech.synthesize' )
368370 response_data = await resp .json ()
@@ -384,6 +386,7 @@ async def synthesize_streaming(self, voice: str, return_extras: bool = False, **
384386 - `voice` (str): The voice id to use for this connection.
385387 - `speed` (float): The speed to use for synthesis. Defaults to 1.0.
386388 - `return_extras` (bool): If `True`, the response will include word durations detail. Defaults to `False`.
389+ - `language` (str): The desired language of the synthesized speech. Two letter ISO 639-1 code. Defaults to `en`.
387390
388391 Returns:
389392 - `StreamingSynthesisConnection`: The streaming connection object.
@@ -406,6 +409,8 @@ async def synthesize_streaming(self, voice: str, return_extras: bool = False, **
406409 if 'expressive' in kwargs :
407410 init_msg ['expressive' ] = kwargs ['expressive' ]
408411 init_msg ['send_extras' ] = return_extras
412+ if 'language' in kwargs :
413+ init_msg ['language' ] = kwargs ['language' ]
409414 ws = await self ._session .ws_connect (f'{ self ._base_url } { _SYNTHESIZE_STREAMING_ENDPOINT } ' )
410415 await ws .send_str (json .dumps (init_msg ))
411416 return StreamingSynthesisConnection (ws , return_extras )
0 commit comments