eva-ia-robot 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/eva_ia_robot.gemspec +4 -2
- data/eva_ia_robot/eva-ia-robot.rb +93 -0
- data/eva_ia_robot/libgomp-1.dll +0 -0
- data/eva_ia_robot/libltdl-7.dll +0 -0
- data/eva_ia_robot/libmad.dll +0 -0
- data/eva_ia_robot/libmp3lame.dll +0 -0
- data/eva_ia_robot/play.exe +0 -0
- data/eva_ia_robot/pthreadgc2.dll +0 -0
- data/eva_ia_robot/rec.exe +0 -0
- data/eva_ia_robot/sox.exe +0 -0
- data/eva_ia_robot/wget.exe +0 -0
- data/eva_ia_robot/zlib1.dll +0 -0
- metadata +14 -3
data/eva_ia_robot.gemspec
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "eva-ia-robot"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.1"
|
4
4
|
s.description = "Gem integrada com Google Speech e Google Translate"
|
5
5
|
s.summary = "Command line"
|
6
6
|
s.author = "Henrique Utsch"
|
7
|
-
s.
|
7
|
+
s.email = "henriqueutsch@gmail.com"
|
8
|
+
s.homepage = "https://github.com/henriqueutsch/Eva-IA-Robot"
|
9
|
+
s.files = Dir["{lib/**/*.rb,README.rdoc,test/**/*.rb,eva_ia_robot/*.rb,,eva_ia_robot/*.dll,,eva_ia_robot/*.exe,Rakefile,*.gemspec}"]
|
8
10
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
#!/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
require "cgi"
|
4
|
+
require 'open-uri'
|
5
|
+
require 'json'
|
6
|
+
require 'win32ole'
|
7
|
+
|
8
|
+
require 'rbconfig'
|
9
|
+
require 'fileutils'
|
10
|
+
|
11
|
+
module HelloWorld
|
12
|
+
def self.say
|
13
|
+
"Hello World!"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
shell = WIN32OLE.new('Shell.Application')
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
def pergunta()
|
22
|
+
p 'gravando ...'
|
23
|
+
system('rec.exe -r 16000 test.flac silence -l 1 0.1 1% 1 1.5 1%')
|
24
|
+
p 'Enviando arquivo ...'
|
25
|
+
request = %x(wget.exe -q -U "rate=16000" -O - "http://www.google.com/speech-api/v1/recognize?lang=pt-BR&client=Mozilla/5.0" --post-file test.flac --header="Content-Type: audio/x-flac; rate=16000")
|
26
|
+
resposta = JSON.parse(request)
|
27
|
+
if resposta["status"] == 5
|
28
|
+
resposta("favor repêtir o comando")
|
29
|
+
else
|
30
|
+
resp = resposta["hypotheses"][0]["utterance"]
|
31
|
+
p resp
|
32
|
+
return resp
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def resposta(texto)
|
38
|
+
texto = CGI::escape(texto)
|
39
|
+
url = 'http://translate.google.com/translate_tts?ie=UTF-8&tl=pt&q='+texto
|
40
|
+
open("arquivo.mp3", "wb") do |file|
|
41
|
+
file.write(open(url).read)
|
42
|
+
end
|
43
|
+
system('play.exe arquivo.mp3')
|
44
|
+
end
|
45
|
+
|
46
|
+
def os
|
47
|
+
@os ||= (
|
48
|
+
host_os = RbConfig::CONFIG['host_os']
|
49
|
+
case host_os
|
50
|
+
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
51
|
+
'windows'
|
52
|
+
when /darwin|mac os/
|
53
|
+
'macosx'
|
54
|
+
when /linux/
|
55
|
+
'linux'
|
56
|
+
when /solaris|bsd/
|
57
|
+
'unix'
|
58
|
+
else
|
59
|
+
raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
|
60
|
+
end
|
61
|
+
)
|
62
|
+
end
|
63
|
+
while 1==1 do
|
64
|
+
|
65
|
+
p frase = pergunta()
|
66
|
+
if frase == 'eva'
|
67
|
+
resposta('pois não')
|
68
|
+
end
|
69
|
+
|
70
|
+
if frase == 'abrir chrome'
|
71
|
+
resposta('abrindo chrome')
|
72
|
+
shell.ShellExecute("chrome.exe", "", "", "open", 1)
|
73
|
+
end
|
74
|
+
|
75
|
+
if frase == 'sistema operacional'
|
76
|
+
resposta("seu sistema operacional é #{os()}")
|
77
|
+
end
|
78
|
+
|
79
|
+
if frase == 'listar'
|
80
|
+
resposta("exibindo lista de músicas")
|
81
|
+
listamusicas = Array.new
|
82
|
+
listamusicas = Dir.entries('D:/Musicas')
|
83
|
+
listamusicas.each_with_index{ |musica,indice| p "#{indice} #{musica}"}
|
84
|
+
end
|
85
|
+
|
86
|
+
if frase == 'tocar'
|
87
|
+
resposta("exibindo lista de musicas")
|
88
|
+
listamusicas = Array.new
|
89
|
+
listamusicas = Dir.entries('D:/Musicas')
|
90
|
+
listamusicas.each_with_index{ |musica,indice| p "#{indice} #{musica}"}
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eva-ia-robot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,16 +13,27 @@ date: 2013-12-27 00:00:00.000000000 -02:00
|
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
description: Gem integrada com Google Speech e Google Translate
|
16
|
-
email:
|
16
|
+
email: henriqueutsch@gmail.com
|
17
17
|
executables: []
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
21
|
- test/eva_ia_robot_test.rb
|
22
|
+
- eva_ia_robot/eva-ia-robot.rb
|
23
|
+
- eva_ia_robot/libgomp-1.dll
|
24
|
+
- eva_ia_robot/libltdl-7.dll
|
25
|
+
- eva_ia_robot/libmad.dll
|
26
|
+
- eva_ia_robot/libmp3lame.dll
|
27
|
+
- eva_ia_robot/pthreadgc2.dll
|
28
|
+
- eva_ia_robot/zlib1.dll
|
29
|
+
- eva_ia_robot/play.exe
|
30
|
+
- eva_ia_robot/rec.exe
|
31
|
+
- eva_ia_robot/sox.exe
|
32
|
+
- eva_ia_robot/wget.exe
|
22
33
|
- Rakefile
|
23
34
|
- eva_ia_robot.gemspec
|
24
35
|
has_rdoc: true
|
25
|
-
homepage:
|
36
|
+
homepage: https://github.com/henriqueutsch/Eva-IA-Robot
|
26
37
|
licenses: []
|
27
38
|
post_install_message:
|
28
39
|
rdoc_options: []
|