Do not set gender if voice name is specified in Google Cloud TTS (#120848)

* Use TextToSpeechAsyncClient in Google Cloud TTS

* Do not set gender if voice name is specified in Google Cloud TTS
This commit is contained in:
tronikos 2024-06-30 02:03:24 -07:00 committed by GitHub
parent 75e3afd369
commit bf608691d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -262,15 +262,18 @@ class GoogleCloudTTSProvider(Provider):
options = options_schema(options)
encoding = options[CONF_ENCODING]
gender = texttospeech.SsmlVoiceGender[options[CONF_GENDER]]
voice = options[CONF_VOICE]
if voice and not voice.startswith(language):
language = voice[:5]
if voice:
gender = None
if not voice.startswith(language):
language = voice[:5]
request = texttospeech.SynthesizeSpeechRequest(
input=texttospeech.SynthesisInput(**{options[CONF_TEXT_TYPE]: message}),
voice=texttospeech.VoiceSelectionParams(
language_code=language,
ssml_gender=texttospeech.SsmlVoiceGender[options[CONF_GENDER]],
ssml_gender=gender,
name=voice,
),
audio_config=texttospeech.AudioConfig(