Coder Social home page Coder Social logo

home-assistant / intents Goto Github PK

View Code? Open in Web Editor NEW
427.0 36.0 488.0 6.21 MB

Intents to be used with Home Assistant

Home Page: https://developers.home-assistant.io/docs/voice/overview/

License: Creative Commons Attribution 4.0 International

Python 91.19% Shell 3.37% JavaScript 0.19% CSS 1.30% HTML 3.94%
hacktoberfest

intents's Introduction

Intents for Home Assistant

This repository contains training data for Home Assistant's local voice control.

Repository layout:

  • languages.yaml
    • Supported languages and their language leader.
  • intents.yaml
    • Supported intents
  • sentences/<language>
    • Intent matching sentences in YAML files for <language> with the name <domain>_<intent>.yaml.
    • File format
  • responses/<language>
    • YAML files for <language> with responses for intents.
    • File format
  • tests/<language>
    • YAML files for <language> with test sentences and corresponding intents.
    • File format

See the documentation for more information.

Development

Checkout the repository and get a development environment with script/setup. This will create a new virtual environment in the venv directory of the repository, and install all necessary requirements.

Before developing, always activate your virtual environment with source venv/bin/activate.

Run tests

Validate that the data is correctly formatted:

python3 -m script.intentfest validate --language nl

Run the tests. This will parse the sentences and verifies them with the test sentences.

pytest tests --language nl -k fan_HassTurnOn

Leave off --language to test all languages. Leave off -k to test all files. Add -n auto to use test parallelization.

Test parsing sentences

You can try parsing sentences for a specific language with:

python3 -m script.intentfest parse --language en --sentence 'turn on the lights in the kitchen'

This will print a line of JSON for each --sentence:

{
  "text": "turn on the lights in the kitchen",
  "match": true,
  "intent": "HassTurnOn",
  "slots": {
    "area": "kitchen",
    "domain": "light"
  }
}

Test sampling sentences

You can sample the possible sentences for a specific language with:

python3 -m script.intentfest sample --language en -n 1

This will print a line of JSON for each possible sentence:

python3 -m script.intentfest sample --language en -n 1
{"intent": "HassTurnOff", "text": "turn off all the fan in the kitchen"}
{"intent": "HassTurnOn", "text": "turn on the light in the kitchen"}
{"intent": "HassCloseCover", "text": "close the bedroom lamp"}
{"intent": "HassClimateSetTemperature", "text": "set the temp to 0 degrees celsius"}
{"intent": "HassLightSet", "text": "set the bedroom lamp brightness to 0 percent"}
{"intent": "HassOpenCover", "text": "open the bedroom lamp"}
{"intent": "HassClimateGetTemperature", "text": "what's the temp "}

You can filter for specific intents by adding --intents HassTurnOn HassTurnOff.

Leave off -n to generate all possible sentences.

Test sampling template

To quickly test a sentence template, use:

python3 -m script.intentfest sample_template <template>

For example:

python3 -m script.intentfest sample_template 'open [the] door'
open the door
open door

You can add lists, ranges, and expansion rules as well:

python3 -m script.intentfest sample_template 'set color to <color> and brightness to {brightness}' --values color red green --range brightness 1 2 --rule color '[the] {color}'

Add new language

python3 -m script.intentfest add_language <language code> <language name>

<language code> should be something like en or pl according to ISO 639.

Language name should be the name of the language in its own language.

intents's People

Contributors

ahmed-farag36 avatar andrejs2 avatar arunshekher avatar balloob avatar bluefoxlee avatar davefx avatar dependabot[bot] avatar dontinelli avatar hepoh3 avatar hristo-atanasov avatar jlpouffier avatar lastrada avatar limitless00net avatar luboskadasi avatar mib1185 avatar mitrokun avatar natfaji avatar nikito7 avatar piitaya avatar schizza avatar skynetua avatar slegars56 avatar spuljko avatar steffenrapp avatar svarthvitt avatar swonge avatar synesthesiam avatar tetele avatar thefes avatar v1k70rk4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

intents's Issues

Adding Lojban

While this is partially a joking suggestion, I do think adding lojban as a language, could be interesting from a parsing/intent suggestion perspective, as the last time I looked at this conlang, it was built extremely logically.

(Note: I'm not at all proficient with the language, I'm putting an issue here out of interest, but also intrigue, due to the above logical/structural properties the language has)

I guess, however, that this also immediately is about the question; will HA consider/support conlangs, and under which conditions, or with what kind of community support.

Setup did not work for me

I added pip install -r requirements.txt to the readme earlier today, but it got removed again. I see that the setup should do it, but when I ran the setup and then added a new language I got this:

lellky@MacBook-Air intents % python3 -m script.intentfest add_language sv
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/lellky/Projects/intents/script/intentfest/__main__.py", line 29, in <module>
    sys.exit(main())
  File "/Users/lellky/Projects/intents/script/intentfest/__main__.py", line 23, in main
    module = importlib.import_module(f".{args.action}", "script.intentfest")
  File "/opt/homebrew/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/lellky/Projects/intents/script/intentfest/add_language.py", line 4, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'

Arabic language support

Hello,
firstly, thank you so much for this awesome work, and I want to contribute to add Arabic language and be assigned as a leader.

Ukrainian language support

Support for the Ukrainian language is very important. We really need an assistant in our language. This will be the first assistant in Ukrainian history
I am ready to be a volunteer in this project in my free time from the war :)

What gender should we pick when writting sentences?

I'm trying to add a new language (Polish) and after running the script I started filling in all the new files.
I noticed that for example, we have this sentence (_common > responses > errors > no_intent):

Sorry, I couldn't understand that

which can be translated in 2 ways in Polish:

Nie mogłem tego zrozumieć

or

Nie mogłam tego zrozumieć

The first one is a male version and the second is a female version.
Even Google Translate suggests two versions:
image

Any plans to support this scenario? I'm sure that not only Polish has this rule.
Verbs with past or future complex times have both forms (ref: https://polski.info/pl/grammar/verbs#verbs7), so ideally we should have a way to declare two responses (if we plan to add voices in both genders) or we should specify that if a sentence has multiple forms we should pick one (which?). It will be hard or sometimes impossible to write sentences that are impersonal (non-gender specific)

Spanish Language Leader

Hi team!
It would be an honor for me to help in the Spanish translation of Home Assistant.

French Language Leader

Hello, if the lead is available, I would be interested in contributing to the implementation/validation of ASR French grammars. I have some experience in this field and would like to contribute contribute to HA.

Hungarian language leader

I'd like to volunteer as Language leader for Hungarian. I maintain the main Hungarian translation of Home Assistant on Lokalise, also contribute by maintaining the ESPHome feature requests repo and give users support on ESPHome Discord.

Having some experience in this field I'm available for reviewing, merging and also contributing to intents in Hungarian.

Adding Czech

I started working on the Czech translation. I'm putting this here, just for the information others

German language leader

Hi,

i'm available for reviewing, merging and also contributing to intents in German.

Best regards
Thomas

Problem with special characters

Hello, I´ve problem with special charakters like "ň","č","ľ"

PS \intents> python3 -m script.intentfest parse --language sk --sentence 'zapni nočná lampa'
{
  "text": "zapni nočná lampa",
  "match": false
}
PS \intents> python3 -m script.intentfest parse --language sk --sentence 'zapni noäťn㡠lampa'
{
  "text": "zapni noäťn㡠lampa",
  "match": true,
  "intent": "HassTurnOn",
    "name": "light.bedroom_lamp"
  }

Danish language leader

Hi! I would like to apply for the position as Danish language leader. I’m a native Danish speaker and have experience with internationalisation and localisation of software.

Looking forward to contributing!

Support for Traditional Chinese language

As title. although there is Simplified Chinese added already, however there is still a slightly difference between two languages.
Wonder will it be better to separate into two in order to get better management and support.

Italian Language Leader

Hi,

I'd like to apply. I'm Italian and fluently speak and write English and Spanish (Spain and Chile variations).

In any case, I'm happy to help with translations.

Cheers
Luca

Turkish Language Leader

Hi. I would like to apply for turkish language leader. I fluently speak turkish and english. And also can speak German.

Support for Slovak language

I would love to help. My time is limited (because of my work and family), but if you need someone for the slovak translations or something other with that i can help. I would try my best because HA is great and you are too.

I have no previous experience. However, I am determined and hardworking.
And I can admit if I couldn't do something to 100% satisfaction.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.