Class: AiTools::DuckSearch

Inherits:
Object
  • Object
show all
Defined in:
lib/ai_tools.rb

Class Method Summary collapse

Class Method Details

.do_translateObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ai_tools.rb', line 40

def self.do_translate
  print "What do you want me to translate? >> "
  translate_this = gets.chomp
  
  print "What file name do you want me to give it? >> "
  your_name = gets.chomp
  
  translate_file = File.read("data/#{translate_this}")
  
  system("trans -brief -no-auto -t ja+en --output data/#{your_name} #{translate_file}")
end

.duck_searchObject

Duck Search



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ai_tools.rb', line 9

def self.duck_search
  require "duck_duck_go"
  
  print "What shall I look up? >> "
  teach_info = gets.chomp
  
  print "Pick a file name >> "
  file_name = gets.chomp
  
  ddg = DuckDuckGo.new
  zci = ddg.zeroclickinfo(teach_info)
  
  open("data/#{file_name}.txt", "w") { |f|
    f.puts zci.heading
    f.puts zci.abstract_text
    f.puts zci.related_topics["_"][0].text
  }
end

.espeak_fileObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ai_tools.rb', line 28

def self.espeak_file
  require "espeak"
  
  print "Which file do you want me to read? >> "
  file = gets.chomp
  
  read_file = File.read("data/#{file}")
  
  speech = ESpeak::Speech.new( read_file )
  speech.speak
end