diff --git a/homeassistant/components/cloud/manifest.json b/homeassistant/components/cloud/manifest.json index 34b245072df..3f065868794 100644 --- a/homeassistant/components/cloud/manifest.json +++ b/homeassistant/components/cloud/manifest.json @@ -8,5 +8,5 @@ "integration_type": "system", "iot_class": "cloud_push", "loggers": ["hass_nabucasa"], - "requirements": ["hass-nabucasa==0.64.1"] + "requirements": ["hass-nabucasa==0.65.0"] } diff --git a/homeassistant/components/cloud/stt.py b/homeassistant/components/cloud/stt.py index 13062db57d6..f78e877a2f5 100644 --- a/homeassistant/components/cloud/stt.py +++ b/homeassistant/components/cloud/stt.py @@ -5,7 +5,7 @@ from collections.abc import AsyncIterable import logging from hass_nabucasa import Cloud -from hass_nabucasa.voice import VoiceError +from hass_nabucasa.voice import STT_LANGUAGES, VoiceError from homeassistant.components.stt import ( AudioBitRates, @@ -23,29 +23,6 @@ from .const import DOMAIN _LOGGER = logging.getLogger(__name__) -SUPPORT_LANGUAGES = [ - "da-DK", - "de-DE", - "en-AU", - "en-CA", - "en-GB", - "en-US", - "es-ES", - "fi-FI", - "fr-CA", - "fr-FR", - "it-IT", - "ja-JP", - "nl-NL", - "pl-PL", - "pt-PT", - "ru-RU", - "sv-SE", - "th-TH", - "zh-CN", - "zh-HK", -] - async def async_get_engine(hass, config, discovery_info=None): """Set up Cloud speech component.""" @@ -64,7 +41,7 @@ class CloudProvider(Provider): @property def supported_languages(self) -> list[str]: """Return a list of supported languages.""" - return SUPPORT_LANGUAGES + return STT_LANGUAGES @property def supported_formats(self) -> list[AudioFormats]: @@ -95,7 +72,7 @@ class CloudProvider(Provider): self, metadata: SpeechMetadata, stream: AsyncIterable[bytes] ) -> SpeechResult: """Process an audio stream to STT service.""" - content = ( + content_type = ( f"audio/{metadata.format!s}; codecs=audio/{metadata.codec!s};" " samplerate=16000" ) @@ -103,7 +80,9 @@ class CloudProvider(Provider): # Process STT try: result = await self.cloud.voice.process_stt( - stream, content, metadata.language + stream=stream, + content_type=content_type, + language=metadata.language, ) except VoiceError as err: _LOGGER.debug("Voice error: %s", err) diff --git a/homeassistant/components/cloud/tts.py b/homeassistant/components/cloud/tts.py index a10b0c98cd8..438bfa580d7 100644 --- a/homeassistant/components/cloud/tts.py +++ b/homeassistant/components/cloud/tts.py @@ -1,7 +1,7 @@ """Support for the cloud for text to speech service.""" from hass_nabucasa import Cloud -from hass_nabucasa.voice import MAP_VOICE, AudioOutput, VoiceError +from hass_nabucasa.voice import MAP_VOICE, TTS_VOICES, AudioOutput, VoiceError import voluptuous as vol from homeassistant.components.tts import ( @@ -14,8 +14,9 @@ from homeassistant.components.tts import ( from .const import DOMAIN ATTR_GENDER = "gender" +ATTR_VOICE = "voice" -SUPPORT_LANGUAGES = list({key[0] for key in MAP_VOICE}) +SUPPORT_LANGUAGES = list(TTS_VOICES) def validate_lang(value): @@ -92,7 +93,7 @@ class CloudProvider(Provider): @property def supported_options(self): """Return list of supported options like voice, emotion.""" - return [ATTR_GENDER, ATTR_AUDIO_OUTPUT] + return [ATTR_GENDER, ATTR_VOICE, ATTR_AUDIO_OUTPUT] @property def default_options(self): @@ -107,9 +108,10 @@ class CloudProvider(Provider): # Process TTS try: data = await self.cloud.voice.process_tts( - message, - language, - gender=options[ATTR_GENDER], + text=message, + language=language, + gender=options.get(ATTR_GENDER), + voice=options.get(ATTR_VOICE), output=options[ATTR_AUDIO_OUTPUT], ) except VoiceError: diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index 4408b30ce1f..63d33d089bc 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -22,7 +22,7 @@ cryptography==40.0.2 dbus-fast==1.84.2 fnv-hash-fast==0.3.1 ha-av==10.0.0 -hass-nabucasa==0.64.1 +hass-nabucasa==0.65.0 hassil==1.0.6 home-assistant-bluetooth==1.9.3 home-assistant-frontend==20230411.1 diff --git a/requirements_all.txt b/requirements_all.txt index a15eb60b87a..8f49467d707 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -869,7 +869,7 @@ ha-philipsjs==3.0.0 habitipy==0.2.0 # homeassistant.components.cloud -hass-nabucasa==0.64.1 +hass-nabucasa==0.65.0 # homeassistant.components.splunk hass_splunk==0.1.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 0cbf33a0fe4..a52f2348084 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -670,7 +670,7 @@ ha-philipsjs==3.0.0 habitipy==0.2.0 # homeassistant.components.cloud -hass-nabucasa==0.64.1 +hass-nabucasa==0.65.0 # homeassistant.components.conversation hassil==1.0.6 diff --git a/tests/components/cloud/test_tts.py b/tests/components/cloud/test_tts.py index 4d2ac35d56d..39de6e1536d 100644 --- a/tests/components/cloud/test_tts.py +++ b/tests/components/cloud/test_tts.py @@ -76,7 +76,7 @@ async def test_provider_properties(cloud_with_prefs) -> None: provider = await tts.async_get_engine( Mock(data={const.DOMAIN: cloud_with_prefs}), None, {} ) - assert provider.supported_options == ["gender", "audio_output"] + assert provider.supported_options == ["gender", "voice", "audio_output"] assert "nl-NL" in provider.supported_languages @@ -85,5 +85,5 @@ async def test_get_tts_audio(cloud_with_prefs) -> None: provider = await tts.async_get_engine( Mock(data={const.DOMAIN: cloud_with_prefs}), None, {} ) - assert provider.supported_options == ["gender", "audio_output"] + assert provider.supported_options == ["gender", "voice", "audio_output"] assert "nl-NL" in provider.supported_languages