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) options = options_schema(options)
encoding = options[CONF_ENCODING] encoding = options[CONF_ENCODING]
gender = texttospeech.SsmlVoiceGender[options[CONF_GENDER]]
voice = options[CONF_VOICE] voice = options[CONF_VOICE]
if voice and not voice.startswith(language): if voice:
language = voice[:5] gender = None
if not voice.startswith(language):
language = voice[:5]
request = texttospeech.SynthesizeSpeechRequest( request = texttospeech.SynthesizeSpeechRequest(
input=texttospeech.SynthesisInput(**{options[CONF_TEXT_TYPE]: message}), input=texttospeech.SynthesisInput(**{options[CONF_TEXT_TYPE]: message}),
voice=texttospeech.VoiceSelectionParams( voice=texttospeech.VoiceSelectionParams(
language_code=language, language_code=language,
ssml_gender=texttospeech.SsmlVoiceGender[options[CONF_GENDER]], ssml_gender=gender,
name=voice, name=voice,
), ),
audio_config=texttospeech.AudioConfig( audio_config=texttospeech.AudioConfig(