Skip to content

Commit

Permalink
More small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kha84 committed Sep 3, 2022
1 parent f5818ef commit 8be5e62
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ rm /usr/local/bin/sayit

## Usage notes / troubleshooting

### Make sure to visit main.py to see what commands are there

Given I have a very specific use cases, like I have EmulationStation executed in multi-user.target, you will definitely want to change/delete
couple of commands. The code is very simple and fun to play with, thanks to the original creator.

Whenever you change anything in main.py, make sure to restart the service so your changes will be picked up:
```
systemctl restart voiceassistant.service
```

### Where to see logs

When the voice assistant is installed as service, logs will be collected by journald, and you can see them like this:
Expand Down Expand Up @@ -113,18 +123,22 @@ I had to export XDG_RUNTIME_DIR in that script, otherwise all audio playback too
https://gtts.readthedocs.io/en/latest/module.html#languages-gtts-lang
https://pypi.org/project/SpeechRecognition/

3. Cache mp3 files to /tmp in "sayit"
3. Cache mp3 files to /tmp in "sayit" to avoid extra network hops to google text-to-speech

4. Dialog mode, as an alternative to wake-up word:
- hey orange
- yeah?
- what is the best search engine?
- (no applicable command found => get answer from DDG)

5. Switch from online recognition to Mozilla Deep Speech
5. Switch from online recognition to Mozilla Deep Speech or similar

6. Implement a fallback mechanism in sayit shell file, so if internet is not around (and gTTS won't work) we'll switch to something different

7. Implement some more commands, like "Switch to gaming mode" / "Enough of gaming" with confirmations
7. Implement confirmations for dangerous commands like "Switch to gaming mode" / "Enough of gaming".

8. Restructure the code a bit:
- so it won't be just silly plaintext matching, but using regexp
- add to the same place of config bindings to various functions to call

8. Return the browser manipulation tool back (DISPLAY issue, when X is not started)
9. Return the browser manipulation tool back (DISPLAY issue, when X is not started in multi-user.target)
8 changes: 8 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
phraseAsk = ['what','who','when']
phrasePlay = ["let's play","gaming mode","enought of working"]
phraseWork = ["let's work","working mode","enought of working"]
phraseReboot=["reboot yourself","reboot computer","restart computer"]
###################

listener = sr.Recognizer()
Expand Down Expand Up @@ -93,12 +94,19 @@ def run_alexa():
talk(last_text)
elif any(x in command for x in phraseJoke):
talk(pyjokes.get_joke())
########### dangerous commands ##########
elif any(x in command for x in phrasePlay):
talk("Allright, let's play some games")
# TODO: don't just blindly switch, check if the target is already there and say it if it is
os.system('sudo systemctl isolate multi-user.target')
elif any(x in command for x in phraseWork):
talk("Sure, switching to working mode")
# TODO: don't just blindly switch, check if the target is already there and say it if it is
os.system('sudo systemctl isolate graphical.target')
elif any(x in command for x in phraseReboot):
talk("The machine is going to be rebooted now!")
# TODO: ask for confirmation
os.system('sudo reboot')
elif any(x in command for x in phraseExit):
talk("Bye-bye!")
quit()
Expand Down

0 comments on commit 8be5e62

Please sign in to comment.