require 'open-uri' require 'feed-normalizer' require 'festivaltts4r' require 'guid' class RSSToSpeech attr_accessor :stories def initialize @stories = [] get_stories get_story_text_from_html read_stories end def get_stories File.open('feeds.txt', 'r').each_line { |f| feed = FeedNormalizer::FeedNormalizer.parse open(f.strip) @stories.push(*feed.entries) } end def get_story_text_from_html @stories.map!{|story| text_for(story) } end def text_for(story) <<-EOF #{story.title} -------------- #{html2txt(story.content)} EOF end def read_stories @stories.each do |story| story.to_speech end end def html2txt(string) guid = Guid.new.hexdigest path = "tmp/#{guid}" File.open(path, "w") do |f| f << string end output = `cat #{path}|python ./html2text.py` `rm #{path}` output end end