Now that we’ve got Siri up and running on the RPi I want to start integarting it. Unfortunately I’m waiting for a GPIO connector so I thought I’d play with Siri itself to get a feel for the SiriProxy functionality.
Before running this you should have SiriProxy running, the below posts will explain how to do that:
Customising the Siri Commands
SiriProxy has the ability to create plugins. To save time however I am just going to edit teh SiriProxy config file to add some custom Siri behaviour.
- Log into a terminal on the RPi running SiriProxy
- Ensure SiriProxy is not running
- Enter the following command
sudo nano /root/SiriProxy/plugins/siriproxy-example/lib/siriproxy-example.rb
- This opens the code file that is used top customise Siri commands. This code is written in Ruby as such it is fairly easy to understand, take some time to look at the example commands.
- The example we will create will take a question “Shall we got to the Bluebell for a drink”, generate a random number and then return an answer based upon the random number generated.
- Paste the below code into the file
#Siri 8 Ball listen_for /shall we go to the Bluebell for a drink/i do #create a random number to generate and answer from, between 0 and 4 ans = rand(4) case ans when 0 say "Of course you should go for a drink, why wouldn't you?" request_completed when 1 say "Don't you think you've drank enough? Maybe you should just stay in" request_completed when 2 say "One drink wouldn't hurt anyone, but make sure it's only 1" request_completed when 3 say "What are you doing here?! Why haven't you got your coat on already!" request_completed else say "Sorry I'm unable to decide, it's too difficult" request_completed end end
- Now press Ctrl+x, then y to save and exit
- To include the commands in SiriProxy we must first bundle them together, to do this run the following:
Note you must be in the SiriProxy directory
- Now you can start the SiriProxy, using
rvmsudo siriproxy server
If you have followed by blog entries you will need to be logged in as root and in the SiriProxy directory when you run this.
- Now you can test the new commands:
- You can change and customise these plans as you like, in a later post we’ll look at integrating Siri with the GPIO pins.