Created
October 18, 2013 10:00
-
-
Save youpy/7039328 to your computer and use it in GitHub Desktop.
eathquake.gem plugin to speech tweets
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
require 'shellwords' | |
require 'uri' | |
Earthquake.init do | |
output_filter do |item| | |
text = item["text"] | |
if text | |
screen_name = item['user']['screen_name'] | |
text = text. | |
dup. | |
force_encoding("ASCII-8BIT"). | |
gsub(URI.regexp(['http', 'https']), '') | |
system("say -v alex #{screen_name} >/dev/null 2>&1") | |
text.split(/\s+/).each do |str| | |
system("say -r 200 -v #{str =~ /^[\w\d]+$/ ? 'Kathy' : 'kyoko' } #{Shellwords.escape(str)} 2>&1 >/dev/null 2>&1") | |
end | |
end | |
true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment