cogibara 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/bin/cogibara-local.rb +68 -0
- data/bin/cogibara-redis.rb +35 -0
- data/cogibara.gemspec +50 -0
- data/lib/cogibara/configuration.rb +84 -0
- data/lib/cogibara/confirmer.rb +30 -0
- data/lib/cogibara/default_config.rb +6 -0
- data/lib/cogibara/dispatcher.rb +125 -0
- data/lib/cogibara/file_handler.rb +44 -0
- data/lib/cogibara/message.rb +20 -0
- data/lib/cogibara/message_handler.rb +153 -0
- data/lib/cogibara/operator_base.rb +39 -0
- data/lib/cogibara/operators/calendar.rb +41 -0
- data/lib/cogibara/operators/chat.rb +22 -0
- data/lib/cogibara/operators/help.rb +13 -0
- data/lib/cogibara/operators/knowledge.rb +55 -0
- data/lib/cogibara/operators/reminder_setter.rb +8 -0
- data/lib/cogibara/operators/soft_parser.rb +48 -0
- data/lib/cogibara/operators/translate.rb +33 -0
- data/lib/cogibara/operators/weather.rb +89 -0
- data/lib/cogibara/operators/wiki/wiki_getter.rb +47 -0
- data/lib/cogibara/operators/wiki.rb +22 -0
- data/lib/cogibara/operators/wolfram_alpha.rb +27 -0
- data/lib/cogibara/responder.rb +24 -0
- data/lib/cogibara/speaker.rb +21 -0
- data/lib/cogibara/text_parser.rb +8 -0
- data/lib/cogibara/transcriber.rb +44 -0
- data/lib/cogibara/version.rb +3 -0
- data/lib/cogibara.rb +73 -0
- metadata +338 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'speech'
|
2
|
+
|
3
|
+
module Cogibara
|
4
|
+
class Transcriber
|
5
|
+
def make_temp_file(file)
|
6
|
+
fname = "tempfile-"+((Time.now.to_f*100000).to_i.to_s)
|
7
|
+
File.open(fname,'wb') {|f| f.write(file)}
|
8
|
+
fname
|
9
|
+
end
|
10
|
+
|
11
|
+
def remove_temp_file(filestring)
|
12
|
+
`rm ./#{filestring}`
|
13
|
+
end
|
14
|
+
|
15
|
+
def transcribe(file)
|
16
|
+
filestring = make_temp_file(file)
|
17
|
+
result = Speech::AudioToText.new(filestring).to_json #(2, "en-US")
|
18
|
+
remove_temp_file filestring
|
19
|
+
# puts result
|
20
|
+
if(result["hypotheses"].first)
|
21
|
+
result["hypotheses"].first.first
|
22
|
+
else
|
23
|
+
# "Sorry, I didn't understand that".to_speech
|
24
|
+
Cogibara::say "Sorry, I didn't understand that"
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def transcribe_lang(file, language)
|
30
|
+
filestring = make_temp_file(file)
|
31
|
+
result = Speech::AudioToText.new(filestring).to_json(2, language)
|
32
|
+
remove_temp_file filestring
|
33
|
+
# puts result
|
34
|
+
if(result["hypotheses"].first)
|
35
|
+
result["hypotheses"].first.first
|
36
|
+
else
|
37
|
+
# "Sorry, I didn't understand that".to_speech
|
38
|
+
Cogibara::say "Sorry, I didn't understand that"
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/lib/cogibara.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require "cogibara/version"
|
2
|
+
|
3
|
+
module Cogibara
|
4
|
+
class << self
|
5
|
+
def setup
|
6
|
+
yield config
|
7
|
+
end
|
8
|
+
|
9
|
+
def setup_dispatcher
|
10
|
+
yield dispatcher
|
11
|
+
end
|
12
|
+
|
13
|
+
def config
|
14
|
+
@config ||= Configuration.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def dispatcher
|
18
|
+
@dispatcher ||= Dispatcher.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def speaker
|
22
|
+
@speaker ||= Speaker.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def responder
|
26
|
+
@responder ||= Responder.new
|
27
|
+
end
|
28
|
+
|
29
|
+
def message_handler
|
30
|
+
@handler ||= MessageHandler.new
|
31
|
+
end
|
32
|
+
|
33
|
+
def file_handler
|
34
|
+
@file_handler ||= FileHandler.new
|
35
|
+
end
|
36
|
+
|
37
|
+
def confirmer
|
38
|
+
@confirmer ||= Confirmer.new
|
39
|
+
end
|
40
|
+
|
41
|
+
def say(message)
|
42
|
+
speak message if config.speak
|
43
|
+
text message if config.text
|
44
|
+
end
|
45
|
+
|
46
|
+
def text(message)
|
47
|
+
responder.send_reply(message.text, message.clientID) if config.use_redis
|
48
|
+
puts message.text if config.local
|
49
|
+
end
|
50
|
+
|
51
|
+
def speak(message)
|
52
|
+
speaker.speak_to_local(message)
|
53
|
+
end
|
54
|
+
|
55
|
+
# def config[entry]
|
56
|
+
# @config ? @config.config[entry] : nil
|
57
|
+
# end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
require 'cogibara/message.rb'
|
62
|
+
require 'cogibara/configuration.rb'
|
63
|
+
require 'cogibara/file_handler.rb'
|
64
|
+
require 'cogibara/text_parser.rb'
|
65
|
+
require 'cogibara/message_handler.rb'
|
66
|
+
require 'cogibara/dispatcher.rb'
|
67
|
+
require 'cogibara/speaker.rb'
|
68
|
+
require 'cogibara/responder.rb'
|
69
|
+
require 'cogibara/transcriber.rb'
|
70
|
+
require 'cogibara/confirmer.rb'
|
71
|
+
require 'cogibara/operator_base.rb'
|
72
|
+
|
73
|
+
|
metadata
ADDED
@@ -0,0 +1,338 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cogibara
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- wstrinz
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: speech2text
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: maluuba_napi2
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: json
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.7.7
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.7.7
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: cleverbot2
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: bing_translator
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: wikipedia-client
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: sanitize
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :runtime
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: uuid
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :runtime
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: redis
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :runtime
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
- !ruby/object:Gem::Dependency
|
191
|
+
name: wolfram
|
192
|
+
requirement: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ! '>='
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
198
|
+
type: :runtime
|
199
|
+
prerelease: false
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - ! '>='
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0'
|
206
|
+
- !ruby/object:Gem::Dependency
|
207
|
+
name: google_calendar
|
208
|
+
requirement: !ruby/object:Gem::Requirement
|
209
|
+
none: false
|
210
|
+
requirements:
|
211
|
+
- - ! '>='
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
type: :runtime
|
215
|
+
prerelease: false
|
216
|
+
version_requirements: !ruby/object:Gem::Requirement
|
217
|
+
none: false
|
218
|
+
requirements:
|
219
|
+
- - ! '>='
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
222
|
+
- !ruby/object:Gem::Dependency
|
223
|
+
name: forecast_io
|
224
|
+
requirement: !ruby/object:Gem::Requirement
|
225
|
+
none: false
|
226
|
+
requirements:
|
227
|
+
- - ! '>='
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :runtime
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
none: false
|
234
|
+
requirements:
|
235
|
+
- - ! '>='
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: '0'
|
238
|
+
- !ruby/object:Gem::Dependency
|
239
|
+
name: geocoder
|
240
|
+
requirement: !ruby/object:Gem::Requirement
|
241
|
+
none: false
|
242
|
+
requirements:
|
243
|
+
- - ! '>='
|
244
|
+
- !ruby/object:Gem::Version
|
245
|
+
version: '0'
|
246
|
+
type: :runtime
|
247
|
+
prerelease: false
|
248
|
+
version_requirements: !ruby/object:Gem::Requirement
|
249
|
+
none: false
|
250
|
+
requirements:
|
251
|
+
- - ! '>='
|
252
|
+
- !ruby/object:Gem::Version
|
253
|
+
version: '0'
|
254
|
+
- !ruby/object:Gem::Dependency
|
255
|
+
name: slop
|
256
|
+
requirement: !ruby/object:Gem::Requirement
|
257
|
+
none: false
|
258
|
+
requirements:
|
259
|
+
- - ! '>='
|
260
|
+
- !ruby/object:Gem::Version
|
261
|
+
version: '0'
|
262
|
+
type: :runtime
|
263
|
+
prerelease: false
|
264
|
+
version_requirements: !ruby/object:Gem::Requirement
|
265
|
+
none: false
|
266
|
+
requirements:
|
267
|
+
- - ! '>='
|
268
|
+
- !ruby/object:Gem::Version
|
269
|
+
version: '0'
|
270
|
+
description: Modular, extensible personal assistant
|
271
|
+
email:
|
272
|
+
- wstrinz@gmail.com
|
273
|
+
executables:
|
274
|
+
- cogibara-local.rb
|
275
|
+
- cogibara-redis.rb
|
276
|
+
extensions: []
|
277
|
+
extra_rdoc_files: []
|
278
|
+
files:
|
279
|
+
- .gitignore
|
280
|
+
- Gemfile
|
281
|
+
- LICENSE.txt
|
282
|
+
- README.md
|
283
|
+
- Rakefile
|
284
|
+
- bin/cogibara-local.rb
|
285
|
+
- bin/cogibara-redis.rb
|
286
|
+
- cogibara.gemspec
|
287
|
+
- lib/cogibara.rb
|
288
|
+
- lib/cogibara/configuration.rb
|
289
|
+
- lib/cogibara/confirmer.rb
|
290
|
+
- lib/cogibara/default_config.rb
|
291
|
+
- lib/cogibara/dispatcher.rb
|
292
|
+
- lib/cogibara/file_handler.rb
|
293
|
+
- lib/cogibara/message.rb
|
294
|
+
- lib/cogibara/message_handler.rb
|
295
|
+
- lib/cogibara/operator_base.rb
|
296
|
+
- lib/cogibara/operators/calendar.rb
|
297
|
+
- lib/cogibara/operators/chat.rb
|
298
|
+
- lib/cogibara/operators/help.rb
|
299
|
+
- lib/cogibara/operators/knowledge.rb
|
300
|
+
- lib/cogibara/operators/reminder_setter.rb
|
301
|
+
- lib/cogibara/operators/soft_parser.rb
|
302
|
+
- lib/cogibara/operators/translate.rb
|
303
|
+
- lib/cogibara/operators/weather.rb
|
304
|
+
- lib/cogibara/operators/wiki.rb
|
305
|
+
- lib/cogibara/operators/wiki/wiki_getter.rb
|
306
|
+
- lib/cogibara/operators/wolfram_alpha.rb
|
307
|
+
- lib/cogibara/responder.rb
|
308
|
+
- lib/cogibara/speaker.rb
|
309
|
+
- lib/cogibara/text_parser.rb
|
310
|
+
- lib/cogibara/transcriber.rb
|
311
|
+
- lib/cogibara/version.rb
|
312
|
+
homepage: ''
|
313
|
+
licenses:
|
314
|
+
- MIT
|
315
|
+
post_install_message:
|
316
|
+
rdoc_options: []
|
317
|
+
require_paths:
|
318
|
+
- lib
|
319
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
320
|
+
none: false
|
321
|
+
requirements:
|
322
|
+
- - ! '>='
|
323
|
+
- !ruby/object:Gem::Version
|
324
|
+
version: '0'
|
325
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
326
|
+
none: false
|
327
|
+
requirements:
|
328
|
+
- - ! '>='
|
329
|
+
- !ruby/object:Gem::Version
|
330
|
+
version: '0'
|
331
|
+
requirements: []
|
332
|
+
rubyforge_project:
|
333
|
+
rubygems_version: 1.8.25
|
334
|
+
signing_key:
|
335
|
+
specification_version: 3
|
336
|
+
summary: Modular, extensible personal assistant
|
337
|
+
test_files: []
|
338
|
+
has_rdoc:
|