Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
In response to @celeenr's (https://twitter.com/celeenr) RubyConf 2016 talk "Rhythmic Recursion"
class Voice
BASELINE = %w( there is no - poop ing - on - the bus - )
VOICES = `say -v '?'`.lines.map { |line| line.split.first }
def initialize &voice
@voice, @i = voice, -1
end
def perform
advance
Thread.new do
@voice.(BASELINE[@i], @i) unless BASELINE[@i] == "-"
end
end
def advance
@i = (@i + 1) % BASELINE.length
end
end
a = Voice.new do |word,_|
system "say -r 250 -v Alice #{word}"
end
b = Voice.new do |word,_|
vol = word == "there" ? 1 : 0.5
system "afplay -v #{vol} /System/Library/Sounds/Tink.aiff"
end
13.times do
(Voice::BASELINE.length * 4).times do
a.perform
b.perform
sleep 0.15
end
a.advance
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.