james 0.0.4-universal-darwin-10 → 0.0.5-universal-darwin-10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/james/controller.rb +8 -15
- data/lib/james/dialogue_api.rb +1 -1
- data/lib/james/inputs/audio.rb +4 -2
- data/lib/james/inputs/terminal.rb +3 -2
- metadata +6 -6
data/lib/james/controller.rb
CHANGED
@@ -15,6 +15,9 @@ module James
|
|
15
15
|
|
16
16
|
attr_reader :visitor
|
17
17
|
|
18
|
+
# This puts together the core dialogue and the user
|
19
|
+
# ones that are hooked into it.
|
20
|
+
#
|
18
21
|
def initialize
|
19
22
|
user_visitor = initialize_dialogues.visitor
|
20
23
|
system_visitor = Visitor.new CoreDialogue.new.state_for(:awake)
|
@@ -23,16 +26,10 @@ module James
|
|
23
26
|
|
24
27
|
def applicationDidFinishLaunching notification
|
25
28
|
load_voices
|
26
|
-
|
27
29
|
start_output
|
28
30
|
start_input
|
29
|
-
|
30
|
-
visitor.enter { |text| say text }
|
31
|
-
|
32
|
-
@input.listen
|
33
31
|
end
|
34
32
|
def windowWillClose notification
|
35
|
-
puts "James is going to bed."
|
36
33
|
exit
|
37
34
|
end
|
38
35
|
|
@@ -53,11 +50,10 @@ module James
|
|
53
50
|
# male: com.apple.speech.synthesis.voice.Bruce
|
54
51
|
end
|
55
52
|
|
53
|
+
# Initialize and "parse" the
|
54
|
+
# dialogues.
|
55
|
+
#
|
56
56
|
def initialize_dialogues
|
57
|
-
# Create the main dialogue.
|
58
|
-
#
|
59
|
-
# Everybody hooks into this, then.
|
60
|
-
#
|
61
57
|
dialogues = Dialogues.new
|
62
58
|
dialogues.resolve
|
63
59
|
dialogues
|
@@ -66,6 +62,7 @@ module James
|
|
66
62
|
#
|
67
63
|
def start_input
|
68
64
|
@input = Inputs::Audio.new self
|
65
|
+
@input.listen
|
69
66
|
end
|
70
67
|
# Start speaking.
|
71
68
|
#
|
@@ -84,9 +81,7 @@ module James
|
|
84
81
|
end
|
85
82
|
end
|
86
83
|
def expects
|
87
|
-
|
88
|
-
puts "Possibilities:\n #{possibilities.join("\n ")}"
|
89
|
-
possibilities
|
84
|
+
@visitor.expects
|
90
85
|
end
|
91
86
|
|
92
87
|
def listen
|
@@ -112,8 +107,6 @@ module James
|
|
112
107
|
# window.display
|
113
108
|
# window.orderFrontRegardless
|
114
109
|
|
115
|
-
app.delegate.applicationDidFinishLaunching nil
|
116
|
-
|
117
110
|
app.run
|
118
111
|
end
|
119
112
|
# Simply put, if there is a controller, it is listening.
|
data/lib/james/dialogue_api.rb
CHANGED
data/lib/james/inputs/audio.rb
CHANGED
@@ -9,12 +9,12 @@ module James
|
|
9
9
|
@recognizer = NSSpeechRecognizer.alloc.init
|
10
10
|
@recognizer.setBlocksOtherRecognizers true
|
11
11
|
@recognizer.setListensInForegroundOnly false
|
12
|
-
recognize_new_commands
|
13
12
|
@recognizer.setDelegate self
|
14
13
|
end
|
15
14
|
|
16
15
|
def listen
|
17
16
|
@recognizer.startListening
|
17
|
+
recognize_new_commands
|
18
18
|
end
|
19
19
|
def heard command
|
20
20
|
super
|
@@ -30,7 +30,9 @@ module James
|
|
30
30
|
heard command
|
31
31
|
end
|
32
32
|
def recognize_new_commands
|
33
|
-
|
33
|
+
possibilities = controller.expects
|
34
|
+
puts "Possibilities:\n #{possibilities.join("\n ")}"
|
35
|
+
@recognizer.setCommands possibilities
|
34
36
|
end
|
35
37
|
|
36
38
|
end
|
@@ -8,10 +8,11 @@ module James
|
|
8
8
|
|
9
9
|
def listen
|
10
10
|
loop do
|
11
|
-
|
11
|
+
possibilities = controller.expects
|
12
|
+
puts "Possibilities:\n #{possibilities.join("\n ")}"
|
12
13
|
command = gets.chop
|
13
14
|
puts "I heard '#{command}'."
|
14
|
-
heard command if
|
15
|
+
heard command if possibilities.include? command
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
metadata
CHANGED
@@ -5,15 +5,15 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
10
10
|
platform: universal-darwin-10
|
11
11
|
authors:
|
12
12
|
- Florian Hanke
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2011-05-
|
16
|
+
date: 2011-05-10 00:00:00 +10:00
|
17
17
|
default_executable: james
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
@@ -34,8 +34,8 @@ dependencies:
|
|
34
34
|
segments:
|
35
35
|
- 0
|
36
36
|
version: "0"
|
37
|
-
description: Modular Electronic Butler.
|
38
|
-
|
37
|
+
description: Modular Electronic Butler. Using a simple dialogue system where you can
|
38
|
+
easily add more dialogues.
|
39
39
|
email: florian.hanke+james@gmail.com
|
40
40
|
executables:
|
41
41
|
- james
|
@@ -87,7 +87,7 @@ rubyforge_project:
|
|
87
87
|
rubygems_version: 1.3.6
|
88
88
|
signing_key:
|
89
89
|
specification_version: 3
|
90
|
-
summary: 'James: Modular Electronic Butler.'
|
90
|
+
summary: 'James: Modular Electronic Butler with modular Dialogues.'
|
91
91
|
test_files:
|
92
92
|
- spec/aux/james/cli_spec.rb
|
93
93
|
- spec/integration/test_dialogue_spec.rb
|