mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
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:
parent
75e3afd369
commit
bf608691d5
@ -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(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user