Correctly return file extension in Google Cloud TTS (#120849)
parent
255cc9ed74
commit
5deb69d492
|
@ -265,7 +265,7 @@ class GoogleCloudTTSProvider(Provider):
|
|||
_LOGGER.error("Error: %s when validating options: %s", err, options)
|
||||
return None, None
|
||||
|
||||
encoding = options[CONF_ENCODING]
|
||||
encoding = texttospeech.AudioEncoding[options[CONF_ENCODING]]
|
||||
gender = texttospeech.SsmlVoiceGender[options[CONF_GENDER]]
|
||||
voice = options[CONF_VOICE]
|
||||
if voice:
|
||||
|
@ -281,7 +281,7 @@ class GoogleCloudTTSProvider(Provider):
|
|||
name=voice,
|
||||
),
|
||||
audio_config=texttospeech.AudioConfig(
|
||||
audio_encoding=texttospeech.AudioEncoding[encoding],
|
||||
audio_encoding=encoding,
|
||||
speaking_rate=options[CONF_SPEED],
|
||||
pitch=options[CONF_PITCH],
|
||||
volume_gain_db=options[CONF_GAIN],
|
||||
|
@ -295,4 +295,11 @@ class GoogleCloudTTSProvider(Provider):
|
|||
_LOGGER.error("Error occurred during Google Cloud TTS call: %s", err)
|
||||
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…
Reference in New Issue