Skip to content
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

Merged
merged 4 commits into from
Dec 2, 2020
Merged

Implement new Google TTS API via dedicated library #43863

merged 4 commits into from
Dec 2, 2020

Conversation

marvin-w
Copy link
Contributor

@marvin-w marvin-w commented Dec 2, 2020

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

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

Co-authored-by: Joakim Sørensen <hi@ludeeus.dev>
@hmmbob
Copy link
Contributor

hmmbob commented Dec 2, 2020

Tested the changes, works for me.

tts:
  - platform: google_translate

Message is played in English if service is called with just a message ✔️
Message is played in Dutch if service is called with message and language: nl

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.

Copy link
Member

@ludeeus ludeeus left a 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

balloob and others added 2 commits December 2, 2020 21:20
Co-authored-by: Joakim Sørensen <hi@ludeeus.dev>
@marvin-w
Copy link
Contributor Author

marvin-w commented Dec 2, 2020

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):
Copy link
Member

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):
Copy link
Member

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.

@frenck frenck merged commit ce05665 into home-assistant:dev Dec 2, 2020
@@ -94,14 +111,6 @@ def __init__(self, hass, lang):
"""Init Google TTS service."""
self.hass = hass
Copy link
Member

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. 🎉

@marvin-w marvin-w deleted the feature/google_tts branch December 3, 2020 10:36
@github-actions github-actions bot locked and limited conversation to collaborators Dec 4, 2020
@frenck frenck added this to the 0.118.5 milestone Dec 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Did google_tts change once again? No TTS from google_translate for Google Translate TTS is no longer working
7 participants