class AiTools::DuckSearch
Public Class Methods
do_translate()
click to toggle source
# 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_search()
click to toggle source
Duck Search
# 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_file()
click to toggle source
# 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