I use Siri on my phone and watch to create reminders on the go. When I'm in the office I don't want to disturb the quiet by using Siri, so I usually use an Alfred workflow that is integrated with the Reminders app, or use the Reminders app directly.
However, both have a rather clunky interface, and it would be much easier if I could just type at the command line:
$ siri "remind me to check stack overflow for responses to my question in 15 minutes"
macOS Sierra has introduced Siri to the desktop, but so far I have been unable to find a way to interact with Siri in any way other than literally talking out loud, and Spotlight does not match Siri with natural language comprehension.
Apple has announced the Siri SDK, but it seems primarily related to adding functionality to Siri, not for exposing the Siri API.
Does Apple expose any kind of API to Siri on macOS such that one could make Siri requests via the command line, system call, or other executable?
Note: I understand that this question could conceivably find a better home at Ask Different, Super User, or Unix & Linux. In the end, I decided that some programmatic integration with an API or SDK was the most probable solution, and thus Stack Overflow seemed the most appropriate place to post. If mods disagree, please do migrate to whichever community is best.
In the Terminal app on your Mac, press the Up Arrow key. The last command you entered appears on the command line. Continue pressing the Up Arrow key until you see the command you want, then press Return.
This isnt from the command line, but closer... and I haven't tested it, but in High Sierra there's a way to use Accessibility settings to enable you to use your keyboard to ask Siri questions.
Enable Type to Siri
so that a tick appears.Snagged from here: https://www.macworld.co.uk/news/mac-software/how-use-siri-on-mac-3536158/
I was wanting the same feature today - I got it working but could be improved upon: https://youtu.be/VRLGCRrReog
TLDR is use LoopBack by Rogue Amoeba and change Siri’s input Mic to Loopback. Then Use the Say command in Terminal for example.
As mentioned by Brad Parks, you can enable 'Type to Siri' from the Accessibility menu. You can use this to interact with Siri using simulated keypresses.
I've created a simple Python script which behaves like requested in your question when invoked from the command line.
The script uses the keyboard Python module.
#!/usr/bin/python
import sys
import time
import keyboard
def trigger_siri():
keyboard.press('command+space')
time.sleep(0.3)
keyboard.release('command+space')
time.sleep(0.2) # Wait for Siri to load
if __name__=='__main__':
trigger_siri()
keyboard.write(sys.argv[1])
keyboard.send('enter')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With