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

Bump hass-nabucasa to 0.65.0 #91565

Merged
merged 1 commit into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Bump hass-nabucasa to 0.65.0
  • Loading branch information
balloob committed Apr 17, 2023
commit 157f1fc8e66a6458bc0bee6d80a4bb1e289b2e66
2 changes: 1 addition & 1 deletion homeassistant/components/cloud/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
33 changes: 6 additions & 27 deletions homeassistant/components/cloud/stt.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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,
Expand All @@ -23,29 +23,6 @@

_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."""
Expand All @@ -64,7 +41,7 @@ def __init__(self, cloud: Cloud) -> None:
@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]:
Expand Down Expand Up @@ -95,15 +72,17 @@ async def async_process_audio_stream(
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"
)

# 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)
Expand Down
14 changes: 8 additions & 6 deletions homeassistant/components/cloud/tts.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -14,8 +14,9 @@
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):
Expand Down Expand Up @@ -92,7 +93,7 @@ def supported_languages(self):
@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):
Expand All @@ -107,9 +108,10 @@ async def async_get_tts_audio(self, message, language, options=None):
# 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:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/components/cloud/test_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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