8000 Add Rhasspy integration by synesthesiam · Pull Request #28821 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Closed
wants to merge 4 commits into from
Closed

Conversation

synesthesiam
Copy link
Contributor
@synesthesiam synesthesiam commented Nov 16, 2019

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):

rhasspy:
  api_url: http://YOUR_RHASSPY_SERVER:12101/api/
  language: en-US
  register_conversation: true
  make_intent_commands: true

# Rhasspy will register as a conversation agent
conversation:

stt:
  - platform: rhasspy
    api_url: http://YOUR_RHASSPY_SERVER:12101/api/

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

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. Update and include derived files by running python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

try:
# First chunk is a WAV header (no frames)
header_chunk = True
with io.BytesIO() as wav_io:
Copy link
Member

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

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.

Copy link
Member

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

@cgtobi cgtobi changed the title Rhasspy Add new Rhasspy integration Nov 25, 2019
INTENT_IS_DEVICE_OFF = "IsDeviceOff"

# Confirms or disconfirms if a cover is currently open
INTENT_IS_COVER_OPEN = "IsCoverOpen"
Copy link
Member

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"
Copy link
Member

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

Comment on lines +338 to +340
"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}})",
Copy link
Contributor

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>)",
Copy link
Contributor

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?

@daniele-athome
Copy link
Contributor
daniele-athome commented Jan 17, 2020

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?

@springstan springstan changed the title Add new Rhasspy integration Add Rhasspy integration Jan 21, 2020
@stale
Copy link
stale bot commented Mar 21, 2020

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.
Thank you for your contributions.

@stale stale bot added the stale label Mar 21, 2020
@balloob balloob closed this Mar 21, 2020
@lock lock bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
405A
Development

Successfully merging this pull request may close these issues.

5 participants
0