James: your very own voice commanded servant
This week, we’ll have some fun with MacRuby. James is a “Voice commanded servant for OSX” you can write dialogs for. Here’s a lightning talk by Florian Hanke, James’ creator.
For example, you could set up a time dialog to ask James what time it is:
<< James, what time is it?
>> It is currently 10:15.
Of course, that’s a pretty simple example. This week’s challenge is to write the most useful or fun dialog for James. You can do about anything, like asking James to do API requests, reboot your machine, run your tests, or whatever you can think of. A simple dialog is enough, but please remember to keep the code nice and understandable.
Haven’t used MacRuby before? Just really easy to install using the binary installer. Be sure to check out James’ README and have a look through its example directory to get up and running. If you have any questions, Florian is here to help.
As always, put your solution in a Gist and you have one week to get your entry in. Good luck!
Prize
This week’s winner will receive a code for $15 worth of credit for the 6sync hosting platform!
-
Finished in 1st place with a final score of 2.5/5. (View the Gist)README.markdown
Intro
This James script asks the user for the origin and destination stations of the MLO network and reports to him how much time he has before his train passes by.
MLO stands for the Metro Ligero Oeste, the tramway network of the west Madrid area
I have to admit it is not specially useful since recognition of spanish names is not the strongest points of the Mac speech recognition (my metro stop is called Somosaguas Sur and it is barely impossible for James to recognize it). Maybe I could translate the names into english (actually that could be fun! somosaguas becomes wearewaters XDDD)
Usage
James: https://github.com/floere/james
Only for Mac OS X you need macruby to make it work. Easiest way is with rvm:
rvm install macrubyThen make sure you are using it and install the james gem
rvm use macruby gem install jamesdiMLOrb: https://github.com/ariera/diMLOrb
gem install diMLOrbjames_mlo.rbView full entry# MLO stands for the Metro Ligero Oeste, the tramway network for the west area of Madrid # DiMLOrb (https://github.com/ariera/diMLOrb) is a gem to estimate conmutation times in the tramway network # This James script asks the user for the origin and destination stations and informs him # how much time he has before his train passes by. require 'DiMLOrb' James.dialog do hear 'metro' => :metro #Listen for each origin station in the MLO network state :metro do DiMLOrb::STATIONS.keys.each do |station| hear station.to_s => "from_#{station}".to_sym end into {'from?'} end #define one state for each origin station and listen to the destination station DiMLOrb::STATIONS.keys.each do |station| state "from_#{station}".to_sym do DiMLOrb::STATIONS.keys.each do |st| hear st.to_s => "to_#{st}".to_sym end into {@origin = station; "from #{station}, to?"} end end #define one state for each destination station and calculate the time DiMLOrb::STATIONS.keys.each do |station| state "to_#{station.to_s}".to_sym do hear 'again' into do @destination = station d = DiMLOrb::DiMLOrb.new(@origin, @destination) "Next train from #{@origin} to #{@destination} is in #{d.proximo} minutes and then in #{d.siguiente} minutes, Sir." end end end end