What's up forum?
I recently started to play with the built in speech recognition in OS X and a couple of days ago I added commands to it to control Plex.
It is pretty awesome actually, which is why I wanted to share this with the forum.
If you haven't played with the speech recognition yet, here is how you get started:
Open System preferences > speech
- switch "speakable items" on.
- choose microphone (I have mine on internal (I'm on a mbp))
- I have chosen to let it "Listen continuously with keyword"
- keyword is "required before each command"
- keyword: Choose what you want here. For example "Computer". My keyword is "Mac".
- I have also added my own sound that plays "upon recognition". It's a voice saying "yes, master".
If you want that, download the sound from http://www.mediafire.com/?za5bec15yshbf5a and save it to ~/Library/Sounds/. You should then be able to choose it in the speech preferences.
So... what commands can you say? take a look in the folder ~/Library/Speech/Speakable Items/
All files in there are commands. If you say one of the names of the files, the speech recognition will open that file.
To add your own commands, you just need to add a file with your desired command as filename. What I do is create an apple script to do a specific thing and save it as an application a Script using applescript editor.
Here are some of the scripts that I have made.
Pause/Unpause Plex (I have this under three diffrent filenames. "Play television", "Pause television" and "Unpause television"):
do shell script "curl http://localhost:3000/xbmcCmds/xbmcHttp?command=pause"
Stop Plex (saved as "stop television")
do shell script "curl http://localhost:3000/xbmcCmds/xbmcHttp?command=stop"
Play the latest unwatched (the oldest you haven't watched) episode of a specific tv show (saved as "Play the latest episode of *tv show name*" for each tv show)
Try out the app Pleech that i made to install this script for each tv-show in plex! https://github.com/nadangergeo/Pleech
*** I have made a new script that lets the computer ask you what tv show you want to watch.
And it's only ONE file. It only works in OS X Lion. You can get the new script and other scripts for Plex here: https://github.com/nadangergeo/Plex-AppleScripts
You need to download and install this little scripting addon for xml parsing (takes less than a minute): http://www.latenightsw.com/freeware/XMLTools2/
Old script:
This is how it would look for the tv show "The Big Bang Theory"
set tvShowName to "The Big Bang Theory" -- the name of the tv show (case sensitive, include "The"5 set pms to "localhost:32400" -- ip and port to pms set section to "2" -- the number of the tv shows section set computerName to computer name of (system info)– Setup XML
set tvShowsXMLURL to “http://” & pms & “/library/sections/” & section & “/all”
set tvShowsXML to (do shell script "curl " & tvShowsXMLURL) as string
set tvShowsXML to parse XML tvShowsXML encoding “UTF-8”
set tvShows to XML contents of tvShowsXMLrepeat with tvShow in tvShows
if title of XML attributes of tvShow = tvShowName then
set tvShowKey to |ratingKey| of XML attributes of tvShow
exit repeat
end if
end repeat– Setup second XML
set episodesXMLURL to “http://” & pms & “/library/metadata/” & tvShowKey & “/allLeaves?unwatched=1”
set episodesXML to (do shell script "curl " & episodesXMLURL) as string
set episodesXML to parse XML episodesXML encoding “UTF-8”
set episodes to XML contents of episodesXMLif item 1 of episodes is “” then
say “There are no unwatched episodes.”
else
set episodeKey to |key| of XML attributes of item 1 of episodes
set episodePath to “http://” & pms & “/library/metadata/” & tvShowKey & “/allLeaves”set triggerURL to “http://” & pms & “/system/players/” & computerName & “.local/Application/playMedia?path=” & episodePath & “\&key=” & episodeKey
do shell script "curl " & triggerURL
end iftell application “Plex”
activate
end tell
Script to toggle Speakable Items (which you can add to remotebuddy if you use that):
on appIsRunning(appName)
tell application “System Events” to (name of processes) contains appName
end appIsRunningif not appIsRunning(“SpeakableItems”) then
do shell script “open System/Library/Speech/Recognizers/AppleSpeakableItems.SpeechRecognizer/Contents/Resources/SpeakableItems.app”
else
do shell script “killall “SpeakableItems””
end if