New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup language support on TTS #5255
Conversation
@pvizeli, thanks for your PR! By analyzing the history of the files in this pull request, we identified @andrey-git to be a potential reviewer. |
@property | ||
def supported_languages(self): | ||
"""List of supported languages.""" | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type must be iterable for if language_key not in provider.supported_languages
.
Maybe return []
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually since all platforms must override both language
and supported_languages
maybe throw exception in both of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are not wrong with it. I do that while the default handling on all base entities do that in this way. HomeAssistant set property to default None and function to raise a not implement exception.
key = KEY_PATTERN.format(msg_hash, language_key, engine).lower() | ||
use_cache = cache if cache is not None else self.use_cache | ||
|
||
if language_key not in provider.supported_languages: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add to your if to avoid blowing up: if language_key is None or …:
self._lang = lang | ||
|
||
@property | ||
def language(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we should rename this to default_language
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah
@balloob done |
5653684
to
241821e
Compare
@@ -70,7 +81,7 @@ def async_get_tts_audio(self, message, language=None): | |||
# If language is not specified or is not supported - use the language |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not have these checks in platforms.
- This check should be moved to the service, as every platform will need this check
- We should not default to another language but instead log an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was support on service too, I can remove this code.
def supported_languages(self): | ||
"""List of supported languages.""" | ||
return SUPPORT_LANGUAGES | ||
|
||
def get_tts_audio(self, message, language=None): | ||
"""Load TTS using pico2wave.""" | ||
if language not in SUPPORT_LANGUAGES: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
|
||
form_data['src'] = message | ||
|
||
# If language is specified and supported - use it instead of the | ||
# language in the config. | ||
if language in SUPPORT_LANGUAGES: | ||
form_data['hl'] = language | ||
if language not in SUPPORT_LANGUAGES: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
@balloob done. I have remove this code while I had implement this check on service but I was blind to see that was not needed anymore. |
e75de94
to
81f641c
Compare
b49d0a3
to
4d9ba9f
Compare
This reverts commit 4b43537. Revert "Version bump for kodi dependency (home-assistant#5307)" This reverts commit 6abad6b. Revert "Add HMWIOSwitch to sensor, binary (home-assistant#5304)" This reverts commit 2c3f55a. Revert "Remove GTFS default name & string change" This reverts commit 6000c59. Revert "Update pyhomematic 1.19 & small cleanups (home-assistant#5299)" This reverts commit a30711f. Revert "[sensor] Add Dublin bus RTPI sensor (home-assistant#5257)" This reverts commit 1219ca3. Revert "Bugfix group reload (home-assistant#5292)" This reverts commit baa8e53. Revert "Support for TrackR device trackers (home-assistant#5010)" This reverts commit f7a1d63. Revert "Bump pywemo version." This reverts commit dc937cc. Revert "Upgrade to voluptuous to 0.9.3 (home-assistant#5288)" This reverts commit d12decc. Revert "Upgrade distro to 1.0.2 (home-assistant#5291)" This reverts commit 64800fd. Revert "Don't build Adafruit_BBIO - doesn't work on all platforms. (home-assistant#5281)" This reverts commit 9a3c0c8. Revert "Convert flic to synchronous platform. (home-assistant#5276)" This reverts commit eb9b95c. Revert "Upgrade to aiohttp 1.2 (home-assistant#4964)" This reverts commit e68e29e. Revert "Fix TCP sensor to correctly use value_template (home-assistant#5211)" This reverts commit 1cf9ae5. Revert "Cleanup language support on TTS (home-assistant#5255)" This reverts commit 3f3a3bc. Revert "Add last triggered to script (home-assistant#5261)" This reverts commit 467cb18. Revert "Bump flux_led version and make use of PyPi package (home-assistant#5267)" This reverts commit 34a9fb0. Revert "Add support for NAD receivers (home-assistant#5191)" This reverts commit 3b59e16. Revert "Bugfix async device_tracker see callback (home-assistant#5259)" This reverts commit 71fddd2. Revert "Use SHA hash to make token harder to guess (home-assistant#5258)" This reverts commit 922308b.
* Added forecast support to DarkSky modified: homeassistant/components/sensor/darksky.py modified: tests/components/sensor/test_darksky.py * Fix async_volume_up / async_volume_down (#5249) async_volume_up / async_volume_down should be async versions of volume_up / volume_down, not a async version of the default variants of volume_up / volume_down. The previous code always called into the mediaplayers set_volume_level, and never into volume_up / volume_down. Signed-off-by: Anton Lundin <glance@acc.umu.se> * adding a default icon "blind" to a PowerView blinds scene. (#5210) * adding a default icon "blind" to a PowerView blinds scene. * Adding icon property to define blind icon. Removed it from the state attributes dict. * fixing lint error * Added forecast support to DarkSky modified: homeassistant/components/sensor/darksky.py modified: tests/components/sensor/test_darksky.py * Use SHA hash to make token harder to guess (#5258) * Use SHA hash to make token harder to guess Use hashlib SHA256 to encode object id instead of using it directly. * Cache access token Instead of generating a token on the fly cache it in the constructor. * Fix lint * Bugfix async device_tracker see callback (#5259) * Add support for NAD receivers (#5191) * Add support for NAD receivers * remove self.update() in various methods * remove setting attributes in various methods * Change import to hass style * Updated Config Validation, extended daily forecast to all supported types * Fix style errors from previous commit, fix test since adding daily for all supported types * Removed temperature from daily as it isn't supported * Added forecast support to DarkSky modified: homeassistant/components/sensor/darksky.py modified: tests/components/sensor/test_darksky.py * Updated Config Validation, extended daily forecast to all supported types * Fix style errors from previous commit, fix test since adding daily for all supported types * Removed temperature from daily as it isn't supported * Revert "Bugfix camera streams (#5306)" This reverts commit 4b43537. Revert "Version bump for kodi dependency (#5307)" This reverts commit 6abad6b. Revert "Add HMWIOSwitch to sensor, binary (#5304)" This reverts commit 2c3f55a. Revert "Remove GTFS default name & string change" This reverts commit 6000c59. Revert "Update pyhomematic 1.19 & small cleanups (#5299)" This reverts commit a30711f. Revert "[sensor] Add Dublin bus RTPI sensor (#5257)" This reverts commit 1219ca3. Revert "Bugfix group reload (#5292)" This reverts commit baa8e53. Revert "Support for TrackR device trackers (#5010)" This reverts commit f7a1d63. Revert "Bump pywemo version." This reverts commit dc937cc. Revert "Upgrade to voluptuous to 0.9.3 (#5288)" This reverts commit d12decc. Revert "Upgrade distro to 1.0.2 (#5291)" This reverts commit 64800fd. Revert "Don't build Adafruit_BBIO - doesn't work on all platforms. (#5281)" This reverts commit 9a3c0c8. Revert "Convert flic to synchronous platform. (#5276)" This reverts commit eb9b95c. Revert "Upgrade to aiohttp 1.2 (#4964)" This reverts commit e68e29e. Revert "Fix TCP sensor to correctly use value_template (#5211)" This reverts commit 1cf9ae5. Revert "Cleanup language support on TTS (#5255)" This reverts commit 3f3a3bc. Revert "Add last triggered to script (#5261)" This reverts commit 467cb18. Revert "Bump flux_led version and make use of PyPi package (#5267)" This reverts commit 34a9fb0. Revert "Add support for NAD receivers (#5191)" This reverts commit 3b59e16. Revert "Bugfix async device_tracker see callback (#5259)" This reverts commit 71fddd2. Revert "Use SHA hash to make token harder to guess (#5258)" This reverts commit 922308b. * Revert "Revert "Bugfix camera streams (#5306)"" This reverts commit 2ee8c44. * Update darksky.py
Description:
After we support language also on service call, I make a small refactory of language support for future. Now it is also possible to check language on service call and protect cache System for produce not correct files.
If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass