Skip to content

Instantly share code, notes, and snippets.

@youpy
Created October 18, 2013 10:00
Show Gist options
  • Save youpy/7039328 to your computer and use it in GitHub Desktop.
Save youpy/7039328 to your computer and use it in GitHub Desktop.
eathquake.gem plugin to speech tweets
# -*- 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