Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'thwait'
class Voice
BASELINE = %w( there is no - poop ing - on - the bus - )
VOICES = `say -v '?'`.lines.map { |line| line.split.first }
attr_reader :voice_name, :rate
def initialize(voice_name, rate)
@i = 0
@voice_name = voice_name
@rate = rate
end
def perform
mod = word == "there" ? "[[volm +0.2]] " : ""
Thread.new do
if word != "-"
system "say -r #{rate} -v #{voice_name} \"#{mod}#{word}\""
end
advance
end
end
def advance
@i = (@i + 1) % BASELINE.length
end
def word
BASELINE[@i]
end
end
a1 = Voice.new('Kathy', 400)
a2 = Voice.new('Agnes', 400)
13.times do
(Voice::BASELINE.length * 4).times do
t1 = a1.perform
t2 = a2.perform
t3 = Thread.new do
sleep 0.25
end
ThreadsWait.all_waits(t1, t2, t3)
end
a1.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.