mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Correctly return file extension in Google Cloud TTS (#120849)
This commit is contained in:
parent
255cc9ed74
commit
5deb69d492
@ -265,7 +265,7 @@ class GoogleCloudTTSProvider(Provider):
|
|||||||
_LOGGER.error("Error: %s when validating options: %s", err, options)
|
_LOGGER.error("Error: %s when validating options: %s", err, options)
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
encoding = options[CONF_ENCODING]
|
encoding = texttospeech.AudioEncoding[options[CONF_ENCODING]]
|
||||||
gender = texttospeech.SsmlVoiceGender[options[CONF_GENDER]]
|
gender = texttospeech.SsmlVoiceGender[options[CONF_GENDER]]
|
||||||
voice = options[CONF_VOICE]
|
voice = options[CONF_VOICE]
|
||||||
if voice:
|
if voice:
|
||||||
@ -281,7 +281,7 @@ class GoogleCloudTTSProvider(Provider):
|
|||||||
name=voice,
|
name=voice,
|
||||||
),
|
),
|
||||||
audio_config=texttospeech.AudioConfig(
|
audio_config=texttospeech.AudioConfig(
|
||||||
audio_encoding=texttospeech.AudioEncoding[encoding],
|
audio_encoding=encoding,
|
||||||
speaking_rate=options[CONF_SPEED],
|
speaking_rate=options[CONF_SPEED],
|
||||||
pitch=options[CONF_PITCH],
|
pitch=options[CONF_PITCH],
|
||||||
volume_gain_db=options[CONF_GAIN],
|
volume_gain_db=options[CONF_GAIN],
|
||||||
@ -295,4 +295,11 @@ class GoogleCloudTTSProvider(Provider):
|
|||||||
_LOGGER.error("Error occurred during Google Cloud TTS call: %s", err)
|
_LOGGER.error("Error occurred during Google Cloud TTS call: %s", err)
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
return encoding, response.audio_content
|
if encoding == texttospeech.AudioEncoding.MP3:
|
||||||
|
extension = "mp3"
|
||||||
|
elif encoding == texttospeech.AudioEncoding.OGG_OPUS:
|
||||||
|
extension = "ogg"
|
||||||
|
else:
|
||||||
|
extension = "wav"
|
||||||
|
|
||||||
|
return extension, response.audio_content
|
||||||
|
Loading…
x
Reference in New Issue
Block a user