|
@@ -123,6 +123,11 @@ class Blather:
|
123
|
123
|
#close the file
|
124
|
124
|
hfile.close()
|
125
|
125
|
|
|
126
|
+ # Print the cmd and then run the command
|
|
127
|
+ def run_command(self, cmd):
|
|
128
|
+ print cmd
|
|
129
|
+ subprocess.call(cmd, shell=True)
|
|
130
|
+
|
126
|
131
|
def recognizer_finished(self, recognizer, text):
|
127
|
132
|
t = text.lower()
|
128
|
133
|
#is there a matching command?
|
|
@@ -131,8 +136,12 @@ class Blather:
|
131
|
136
|
if self.options['valid_sentence_command']:
|
132
|
137
|
subprocess.call(self.options['valid_sentence_command'], shell=True)
|
133
|
138
|
cmd = self.commands[t]
|
134
|
|
- print cmd
|
135
|
|
- subprocess.call(cmd, shell=True)
|
|
139
|
+ #should we be passing words?
|
|
140
|
+ if self.options['pass_words']:
|
|
141
|
+ cmd+=" "+t
|
|
142
|
+ self.run_command(cmd)
|
|
143
|
+ else:
|
|
144
|
+ self.run_command(cmd)
|
136
|
145
|
self.log_history(text)
|
137
|
146
|
else:
|
138
|
147
|
#run the invalid_sentence_command if there is a valid sentence command
|
|
@@ -192,6 +201,10 @@ if __name__ == "__main__":
|
192
|
201
|
action="store_true", dest="continuous", default=False,
|
193
|
202
|
help="starts interface with 'continuous' listen enabled")
|
194
|
203
|
|
|
204
|
+ parser.add_option("-p", "--pass-words",
|
|
205
|
+ action="store_true", dest="pass_words", default=False,
|
|
206
|
+ help="passes the recognized words as arguments to the shell command")
|
|
207
|
+
|
195
|
208
|
parser.add_option("-o", "--override",
|
196
|
209
|
action="store_true", dest="override", default=False,
|
197
|
210
|
help="override config file with command line options")
|