Skip to content

Latest commit

 

History

History
130 lines (80 loc) · 2.76 KB

PythonListAllVoiceCommands.md

File metadata and controls

130 lines (80 loc) · 2.76 KB


Lists All Custom Voice Commands




Oh wow.. you have been working hard and adding new commands like crazy huh?
Perhaps your mind is elsewhere sometimes and you forgot how to trigger your commands?
I got you.. Running this python will grab your custom sentences (6th line in all your yaml files)
and send them back to you with an notification.




  • 1: Intent Script

If you dont have it already, create the file intent_script.yaml in the /config dir and fill in the code below.
(dont forget to reference it in configuration.yaml with intent_script: !include intent_script.yaml

  • 2: Custom Sentence

Create a folder called custom_sentences inside your /config dir.
Inside that folder, once again create a folder named with your language code. sv for swedish, en for english.
In that folder you create a file and name it whatever you want, but remember it, cause it will be referencesd later.
I will use IntentName.yaml as an example here, fill this yaml file with the code from below.

  • 3: Shell command

Create the file 'shell_command.yaml' file in your /config dir and paste in the code below. This will allow you to call the script easily later.

  • 4: Python Script

Within your /config dir, create a file called list_all_commands.py
Paste in the code from the bottom of this page.
Dont forget to change to your language code if your not a swetard.



🦆 /config/intent_script.yaml


IntentName:
  action:
    - service: shell_command.list_voice_commands
      data: {}
      response_variable: result
    - service: notify.mobile_app_YOUR_iPHONE
      data:
        message: "{{ result['stdout'] }}"
        title: Voice Commands
        data:
          push:
            sound:
              name: default
              critical: 
  speech:
    text: "{{ result['stdout'] }} "                   



🦆 /custon_sentences/sv/IntentName.yaml


language: "sv"
intents:
  IntentName:
    data:
      - sentences:
          - "vad ska jag säga"
          - "vad kan jag säga"



🦆 /config/shell_command.yaml


  list_voice_commands: "python list_all_commands.py"



🦆 /config/list_all_commands.py


import os
#      Define your language code here \/
directory = "/config/custom_sentences/sv/"

for filename in os.listdir(directory):
    if filename.endswith(".yaml") or filename.endswith(".yml"):
        file_path = os.path.join(directory, filename)
        with open(file_path, 'r') as file:
            lines = file.readlines()
            if len(lines) >= 6:
                print(lines[5].strip())