@@ -370,12 +370,18 @@ class AudioStatus(Enum):
370370 ERROR = 'error'
371371
372372
373+ class VoiceGender (Enum ):
374+ MALE = 'male'
375+ FEMALE = 'female'
376+
377+
373378@dataclass
374379class AudioOptions :
375380 adapt_to : Optional [List [str ]] = None
376381 glossaries : Optional [List [str ]] = None
377382 no_trace : Optional [bool ] = None
378383 style : Optional [TranslationStyle ] = None
384+ voice_gender : Optional [VoiceGender ] = None
379385
380386
381387class Audio (LaraObject ):
@@ -480,7 +486,8 @@ def __init__(self, client: LaraClient):
480486
481487 def upload (self , file_path : str , filename : str , target : str , source : Optional [str ] = None ,
482488 adapt_to : Optional [List [str ]] = None , glossaries : Optional [List [str ]] = None ,
483- no_trace : bool = False , style : Optional [TranslationStyle ] = None ) -> Audio :
489+ no_trace : bool = False , style : Optional [TranslationStyle ] = None ,
490+ voice_gender : Optional [VoiceGender ] = None ) -> Audio :
484491 with open (file_path , 'rb' ) as file_payload :
485492 response_data = self ._client .get ('/v2/audio/upload-url' , {'filename' : filename })
486493
@@ -504,6 +511,8 @@ def upload(self, file_path: str, filename: str, target: str, source: Optional[st
504511
505512 if style is not None :
506513 body ['style' ] = style
514+ if voice_gender is not None :
515+ body ['voice_gender' ] = voice_gender .value
507516
508517 headers = None
509518 if no_trace is True :
@@ -520,10 +529,12 @@ def download(self, id: str) -> bytes:
520529
521530 def translate (self , file_path : str , filename : str , target : str , source : Optional [str ] = None ,
522531 adapt_to : Optional [List [str ]] = None , glossaries : Optional [List [str ]] = None ,
523- no_trace : bool = False , style : Optional [TranslationStyle ] = None ) -> bytes :
532+ no_trace : bool = False , style : Optional [TranslationStyle ] = None ,
533+ voice_gender : Optional [VoiceGender ] = None ) -> bytes :
524534
525535 audio = self .upload (file_path = file_path , filename = filename , target = target , source = source ,
526- adapt_to = adapt_to , glossaries = glossaries , no_trace = no_trace , style = style )
536+ adapt_to = adapt_to , glossaries = glossaries , no_trace = no_trace , style = style ,
537+ voice_gender = voice_gender )
527538
528539 max_wait_time = 60 * 15 # 15 minutes
529540 start = time .time ()
0 commit comments