Remove side effects from Watson TTS init (#50716)

This commit is contained in:
Franck Nijhof 2021-05-17 10:46:58 +02:00 committed by GitHub
parent a414cad3b2
commit 059e7c925d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -147,6 +147,12 @@ def get_engine(hass, config, discovery_info=None):
output_format = config[CONF_OUTPUT_FORMAT]
service.set_default_headers({"x-watson-learning-opt-out": "true"})
if default_voice in DEPRECATED_VOICES:
_LOGGER.warning(
"Watson TTS voice %s is deprecated, it may be removed in the future",
default_voice,
)
return WatsonTTSProvider(service, supported_languages, default_voice, output_format)
@ -162,12 +168,6 @@ class WatsonTTSProvider(Provider):
self.output_format = output_format
self.name = "Watson TTS"
if self.default_voice in DEPRECATED_VOICES:
_LOGGER.warning(
"Watson TTS voice %s is deprecated, it may be removed in the future",
self.default_voice,
)
@property
def supported_languages(self):
"""Return a list of supported languages."""