#!/usr/bin/env ruby require 'rubygems' #Include the FireWatir file. require 'firewatir' #include the FireWatir Module. include FireWatir require "festivaltts4r" site='localhost:3000/' system('stty raw -echo') begin puts "use arrow keys, PgUp and PgDn. Ctrl-C to end" apps=ARGV if apps.empty? apps=["modules"] end puts "running applications: #{apps.join(";")}" aindex=0 system('stty raw -echo') c="" arrow={65=>"up",68=>"backspace",66=>"down",67=>"select"} p ff=Firefox.new ff.goto("http://localhost:3000/#{apps[aindex]}") # loop until Ctrl-C pressed begin inchar=STDIN.getc if inchar and (inchar.to_i==27) b= STDIN.getc c= STDIN.getc if arrow[c] ff.goto("http://#{site}#{apps[aindex]}/#{arrow[c]}") end elsif inchar aindex=(aindex+1)%apps.size ff.goto("http://#{site}#{apps[aindex]}") end page_text=ff.text if page_text =~ /say:"(.+)"/ speak=$1 speak.to_speech end # p page_text page_text=page_text[0..(page_text=~/modules/)+7] apps=page_text.scan(%r{\w+}) p 'running modules: '+apps.join(';') end until inchar.to_i==3 ensure system('stty -raw echo') ff.close unless ff.nil? end