From 72fad87aefd65d3e7acf5fe700355b3e0784240c Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 17 Feb 2022 12:06:49 +0100 Subject: [PATCH] Update google-cloud-texttospeech to 2.10.0 (#66726) --- .../components/google_cloud/manifest.json | 2 +- homeassistant/components/google_cloud/tts.py | 29 ++++++++++--------- requirements_all.txt | 2 +- script/pip_check | 2 +- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/google_cloud/manifest.json b/homeassistant/components/google_cloud/manifest.json index 90c5eebaeb2..83801d50354 100644 --- a/homeassistant/components/google_cloud/manifest.json +++ b/homeassistant/components/google_cloud/manifest.json @@ -2,7 +2,7 @@ "domain": "google_cloud", "name": "Google Cloud Platform", "documentation": "https://www.home-assistant.io/integrations/google_cloud", - "requirements": ["google-cloud-texttospeech==0.4.0"], + "requirements": ["google-cloud-texttospeech==2.10.0"], "codeowners": ["@lufton"], "iot_class": "cloud_push" } diff --git a/homeassistant/components/google_cloud/tts.py b/homeassistant/components/google_cloud/tts.py index 3d65f4eb297..0de580ef7b7 100644 --- a/homeassistant/components/google_cloud/tts.py +++ b/homeassistant/components/google_cloud/tts.py @@ -122,13 +122,9 @@ SUPPORTED_OPTIONS = [ CONF_TEXT_TYPE, ] -GENDER_SCHEMA = vol.All( - vol.Upper, vol.In(texttospeech.enums.SsmlVoiceGender.__members__) -) +GENDER_SCHEMA = vol.All(vol.Upper, vol.In(texttospeech.SsmlVoiceGender.__members__)) VOICE_SCHEMA = cv.matches_regex(VOICE_REGEX) -SCHEMA_ENCODING = vol.All( - vol.Upper, vol.In(texttospeech.enums.AudioEncoding.__members__) -) +SCHEMA_ENCODING = vol.All(vol.Upper, vol.In(texttospeech.AudioEncoding.__members__)) SPEED_SCHEMA = vol.All(vol.Coerce(float), vol.Clamp(min=MIN_SPEED, max=MAX_SPEED)) PITCH_SCHEMA = vol.All(vol.Coerce(float), vol.Clamp(min=MIN_PITCH, max=MAX_PITCH)) GAIN_SCHEMA = vol.All(vol.Coerce(float), vol.Clamp(min=MIN_GAIN, max=MAX_GAIN)) @@ -263,27 +259,32 @@ class GoogleCloudTTSProvider(Provider): try: params = {options[CONF_TEXT_TYPE]: message} - # pylint: disable=no-member - synthesis_input = texttospeech.types.SynthesisInput(**params) + synthesis_input = texttospeech.SynthesisInput(**params) - voice = texttospeech.types.VoiceSelectionParams( + voice = texttospeech.VoiceSelectionParams( language_code=language, - ssml_gender=texttospeech.enums.SsmlVoiceGender[options[CONF_GENDER]], + ssml_gender=texttospeech.SsmlVoiceGender[options[CONF_GENDER]], name=_voice, ) - audio_config = texttospeech.types.AudioConfig( - audio_encoding=texttospeech.enums.AudioEncoding[_encoding], + audio_config = texttospeech.AudioConfig( + audio_encoding=texttospeech.AudioEncoding[_encoding], speaking_rate=options[CONF_SPEED], pitch=options[CONF_PITCH], volume_gain_db=options[CONF_GAIN], effects_profile_id=options[CONF_PROFILES], ) - # pylint: enable=no-member + + request = { + "voice": voice, + "audio_config": audio_config, + "input": synthesis_input, + } async with async_timeout.timeout(10): + assert self.hass response = await self.hass.async_add_executor_job( - self._client.synthesize_speech, synthesis_input, voice, audio_config + self._client.synthesize_speech, request ) return _encoding, response.audio_content diff --git a/requirements_all.txt b/requirements_all.txt index ac972d24fb5..d963262b712 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -758,7 +758,7 @@ google-api-python-client==1.6.4 google-cloud-pubsub==2.9.0 # homeassistant.components.google_cloud -google-cloud-texttospeech==0.4.0 +google-cloud-texttospeech==2.10.0 # homeassistant.components.nest google-nest-sdm==1.7.1 diff --git a/script/pip_check b/script/pip_check index c30a7382f27..af47f101fbb 100755 --- a/script/pip_check +++ b/script/pip_check @@ -3,7 +3,7 @@ PIP_CACHE=$1 # Number of existing dependency conflicts # Update if a PR resolve one! -DEPENDENCY_CONFLICTS=10 +DEPENDENCY_CONFLICTS=9 PIP_CHECK=$(pip check --cache-dir=$PIP_CACHE) LINE_COUNT=$(echo "$PIP_CHECK" | wc -l)