Skip to content

Instantly share code, notes, and snippets.

@al2o3cr
Created November 13, 2016 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save al2o3cr/9b995747b6a9bafaa77685c0900338f9 to your computer and use it in GitHub Desktop.
Save al2o3cr/9b995747b6a9bafaa77685c0900338f9 to your computer and use it in GitHub Desktop.
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