Browse Source

Added -p --pass-words flag that will pass the recognized words to the shell command

a few print commands were remove too.
Jezra 9 years ago
parent
commit
87585c7b20
4 changed files with 15 additions and 5 deletions
  1. 15
    2
      Blather.py
  2. 0
    1
      GtkTrayUI.py
  3. 0
    1
      GtkUI.py
  4. 0
    1
      QtUI.py

+ 15
- 2
Blather.py View File

@@ -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")

+ 0
- 1
GtkTrayUI.py View File

@@ -80,7 +80,6 @@ class UI(gobject.GObject):
80 80
 		self.emit("command", "quit")
81 81
 
82 82
 	def finished(self, text):
83
-		print text
84 83
 		if not self.menu_continuous.get_active():
85 84
 			self.menu_listen.set_label("Listen")
86 85
 			self.statusicon.set_from_icon_name("blather_stopped")

+ 0
- 1
GtkUI.py View File

@@ -90,7 +90,6 @@ class UI(gobject.GObject):
90 90
 		self.emit("command", "quit")
91 91
 
92 92
 	def finished(self, text):
93
-		print text
94 93
 		#if the continuous isn't pressed
95 94
 		if not self.ccheckbox.get_active():
96 95
 			self.lsbutton_stopped()

+ 0
- 1
QtUI.py View File

@@ -93,7 +93,6 @@ class UI(gobject.GObject):
93 93
 		self.emit("command", "quit")
94 94
 
95 95
 	def finished(self, text):
96
-		print text
97 96
 		#if the continuous isn't pressed
98 97
 		if not self.ccheckbox.isChecked():
99 98
 			self.lsbutton_stopped()

Loading…
Cancel
Save