When Mac OS Sierra came out, one of the high-profile news was the appearance of Siri. As a caveman, I was very surprised and interested in the ability to control a laptop using voice (yes, this is not innovation, but I personally have never used it with this and considered it to be useless).
After a couple of hours of reading different materials, I was disappointed that it was impossible to quickly expand the capabilities of Siri (among which I found little useful information for myself). I wanted to be able to run some bash script, but the launch methods were not very convenient (for my taste).
But then I suddenly found out about the voice commands that the poppy already knows how long (years?)
First, go to “System Settings” → “Keyboard” (suddenly) → “Dictation” and turn it on. After that, go to "System Settings" → "Universal Access" → "Dictation".
To begin with, we include the dictation key phrases . This is necessary so that speech recognition works all the time, not on demand. Next, open the command. Here you will see many already predefined commands. Personally, I turned them off.
Let's create our own, custom. There are only three settings: command text, context and action. Unfortunately, we still can not run bash scripts, but we can run applications. And what is the application in Mac OS? Only a directory with a specific structure and suffix .app
. The decision suggests itself - to make .app
from a script.
I will not dwell on the structure of the application. Personally, I have long written a ruby-script that turns an arbitrary script into .app
. Here it is .
Actually, that's all. "Run" → "Run process" → "Other" and select our "application".
I can not boast of their little know-how. At my house music is played not from my laptop, but from a separate device connected to speakers on the other side of the room. Previously, it was a phone with a Plex installed on it, but just yesterday I bought a Raspberry Pi and installed mpd
on it.
With the help of my ruby-script, I made applications that perform one command of the form
ssh pi@raspberry 'mpc <command>'
and assigned them to voice control.
Here is a small demo (I apologize for the sound and mess):
upd. altervision reported that instead of .app
you can use .command
files, which should be much more convenient for some small commands.
Source: https://habr.com/ru/post/373043/
All Articles