class WikipediaReader

Constants

OUTPUT_TYPE

Public Class Methods

new(article_name) click to toggle source
# File lib/tellmeabout/wikipedia_reader.rb, line 6
def initialize(article_name)
  @article_name = article_name
  @rate = 230
  @outfile_path = "#{article_name}.aiff"
end

Public Instance Methods

command(string) click to toggle source
# File lib/tellmeabout/wikipedia_reader.rb, line 44
def command(string)
  "say \"#{string.gsub('"', '\"')}\""
end
outfile_path() click to toggle source
# File lib/tellmeabout/wikipedia_reader.rb, line 52
def outfile_path
  "/Users/luke/Desktop/#{@article_name}.aiff"
end
read() click to toggle source
# File lib/tellmeabout/wikipedia_reader.rb, line 12
def read
  read_wikipedia_article
end
read_wikipedia_article() click to toggle source
# File lib/tellmeabout/wikipedia_reader.rb, line 16
def read_wikipedia_article
  cleaner = WikipediaContentCleaner.new(@article_name)
  cleaner.load_from_wikipedia
  cleaner.delete_silent_substrings

  @cleaned_content = cleaner.content

  case OUTPUT_TYPE
  when 'only to file'
    say_to_file
  when 'only to speakers'
    say_to_speakers
  when 'to both'
    say_to_file
    say_to_speakers
  end

end
say_to_file() click to toggle source
# File lib/tellmeabout/wikipedia_reader.rb, line 35
def say_to_file
  total_command = "#{command(@cleaned_content)} -r #{@rate} -v #{voice} -o #{outfile_path}"
  `#{total_command}`
end
say_to_speakers() click to toggle source
# File lib/tellmeabout/wikipedia_reader.rb, line 40
def say_to_speakers
  `#{command(@cleaned_content)} -r #{@rate} -v #{voice}`
end
voice() click to toggle source
# File lib/tellmeabout/wikipedia_reader.rb, line 48
def voice
  'Vicki'
end