Skip to content

Instantly share code, notes, and snippets.

@gwang
Created May 11, 2012 04:40
Show Gist options
  • Save gwang/2657578 to your computer and use it in GitHub Desktop.
Save gwang/2657578 to your computer and use it in GitHub Desktop.
Multiplication Bingo in Ruby Using SAPI
# Using Windows SAPI
require 'win32/sapi5'
include Win32
v = SpVoice.new
data = Hash.new
(0..12).each { |i|
(0..12).each { |j|
p = i*j
data[p] = Array.new if data[p].nil?
data[p] << "#{i} times #{j}"
}
}
while (data.size > 0)
r1 = rand(data.keys.size)
k = data.keys[r1]
r2 = rand(data[k].size)
text = data[k].at(r2)
puts "saying #{text} ..."
v.Speak(text)
data.delete(k)
sleep 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment