Created
November 13, 2016 01:25
-
-
Save al2o3cr/9b995747b6a9bafaa77685c0900338f9 to your computer and use it in GitHub Desktop.
A further variation from https://gist.github.com/jamesdabbs/a85fa5553df7dba0ba3dbb25f4cafe4b
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
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