-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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
Implement new Google TTS API via dedicated library #43863
Conversation
Co-authored-by: Joakim Sørensen <hi@ludeeus.dev>
Tested the changes, works for me. tts:
- platform: google_translate Message is played in English if service is called with just a message ✔️ tts:
- platform: google_translate
language: nl Message is played in Dutch if service is called with just a message ✔️ Also tested a longer message (the actual weather report, lol) as well. Message is playing completely, but "chunking" is audible. I guess this is due to the type of TTS (Google Translate) and not necessarily a code problem - but I might be wrong there. |
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 tests need some adjustments, other than that it looks great 👍
tests/components/google_translate/test_tts.py
Co-authored-by: Joakim Sørensen <hi@ludeeus.dev>
Thanks for the test fixes. I was just on it but you were faster. |
assert len(aioclient_mock.mock_calls) == 1 | ||
|
||
@patch("gtts_token.gtts_token.Token.calculate_token", autospec=True, return_value=5) | ||
def test_service_say_timeout(self, mock_calculate, aioclient_mock): |
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.
There is only 1 error type, that's when it raises gTTsError so I removed all other types of tests.
assert len(aioclient_mock.mock_calls) == 1 | ||
|
||
@patch("gtts_token.gtts_token.Token.calculate_token", autospec=True, return_value=5) | ||
def test_service_say_long_size(self, mock_calculate, aioclient_mock): |
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.
This is now handled inside the lib. Don't need a test.
@@ -94,14 +111,6 @@ def __init__(self, hass, lang): | |||
"""Init Google TTS service.""" | |||
self.hass = hass |
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 don't need to pass in hass
anymore now. 🎉
Proposed change
I personally don't use google tts, but this has been tested successfully by @hmmbob (thanks!).
This PR should fix the google TTS functionality. The reason for that is described in #43258 as well as the analysis of the new API structure.
It also cleans up the code a bit as most of the stuff is done in the library already including message chunking and language checking. I only added the languages again as HA uses it in the Schema and would most likely want to keep it this way. The languages are defined here in the lib:
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: