-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Add Rhasspy integration #28821
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
Add Rhasspy integration #28821
Conversation
try: | ||
# First chunk is a WAV header (no frames) | ||
header_chunk = True | ||
with io.BytesIO() as wav_io: |
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.
Like in function description, you need stream this directly to backend services. If you need an wave header, set the format to wave only. That is not our platform to deal with this things.
_LOGGER.debug("Receiving audio") | ||
try: | ||
# Drop WAV header | ||
await stream.readchunk() |
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.
That works with Ada
because we create a wave header on the fly. Not sure if that works with somethings else they send the wave header as part of the audio stream. I'm not a wave header expert I don't know if you can read a fixed amount of bytes or parse it until a special char after that it's audio. However, I'm fine with this code.
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.
Maybe you should add AudioFormat.RAW
so you except only raw data without wave and don't need to remove that?
text = await client.stream_to_text(stream) | ||
|
||
return SpeechResult(text=text, result=SpeechResultState.SUCCESS) | ||
except Exception: # pylint: disable=broad-except |
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 a reason why pylint doesn't allow for catching Exception
. Please pick only the exception they you suppose there. And use try/except
only around the place where this exception needs to be handled.
INTENT_IS_DEVICE_OFF = "IsDeviceOff" | ||
|
||
# Confirms or disconfirms if a cover is currently open | ||
INTENT_IS_COVER_OPEN = "IsCoverOpen" |
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.
These intents should become part of Home Assistant core, they should not be part of the Rhasspy integration. That way they are available for anyone using them.
I've opened #29280 that will make it easier to add these. Integrations can include a new intent.py
to register them. See the PR for an example.
# ----------------------------------------------------------------------------- | ||
|
||
# Confirms or disconfirms if a device is currently on | ||
INTENT_IS_DEVICE_ON = "IsDeviceOn" |
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.
These could be added to the Intent integration. We should make sure that all intents that are added to Home Assistant start with Hass
"hour_half_expr = (<one_to_nine>{hours} and (a half){{minutes:30}})", | ||
"hour_expr = (((one:1){hours}) | ((<one_to_nine>){hours}) | <hour_half_expr>) (hour | hours)", | ||
"minute_half_expr = (<one_to_fifty_nine>{minutes} and (a half){{seconds:30}})", |
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.
I don't know if it's intended, but it caused an error when I copied these rules in my Rhasspy instance manually: double curly brackets around minutes:30 and seconds:30 are wrong (they produce an error in my instance).
"teens = (ten:10 | eleven:11 | twelve:12 | thirteen:13 | fourteen:14 | fifteen:15 | sixteen:16 | seventeen:17 | eighteen:18 | nineteen:19)", | ||
"", | ||
"tens = (twenty:20 | thirty:30 | forty:40 | fifty:50)", | ||
"one_to_nine = (one:1 | <two_to_nine>)", |
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.
I believe this is duplicated?
Just an off-topic note on the timer intent: on a 8 GB RAM Intel I3 amd64 it's been 5 minutes training and system is currently at 4 GB of used RAM and rising. Probably related to this? |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
Description:
Adds integration with Rhasspy voice assistant. Generates voice commands from available entities and uses remote Rhasspy server for speech/intent recognition.
Pull request with documentation for home-assistant.io (if applicable): home-assistant/home-assistant.io#11202
Example entry for
configuration.yaml
(if applicable):Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
python3 -m script.hassfest
.requirements_all.txt
by runningpython3 -m script.gen_requirements_all
..coveragerc
.If the code does not interact with devices: