Created
May 11, 2012 04:40
-
-
Save gwang/2657578 to your computer and use it in GitHub Desktop.
Multiplication Bingo in Ruby Using SAPI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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