From 87585c7b20ace497d2497ee916f84d7e8e5e9a8d Mon Sep 17 00:00:00 2001 From: Jezra Date: Fri, 12 Sep 2014 09:24:14 -0700 Subject: Added -p --pass-words flag that will pass the recognized words to the shell command a few print commands were remove too. --- Blather.py | 17 +++++++++++++++-- GtkTrayUI.py | 1 - GtkUI.py | 1 - QtUI.py | 1 - 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Blather.py b/Blather.py index f2a932a..9ad5e14 100755 --- a/Blather.py +++ b/Blather.py @@ -123,6 +123,11 @@ class Blather: #close the file hfile.close() + # Print the cmd and then run the command + def run_command(self, cmd): + print cmd + subprocess.call(cmd, shell=True) + def recognizer_finished(self, recognizer, text): t = text.lower() #is there a matching command? @@ -131,8 +136,12 @@ class Blather: if self.options['valid_sentence_command']: subprocess.call(self.options['valid_sentence_command'], shell=True) cmd = self.commands[t] - print cmd - subprocess.call(cmd, shell=True) + #should we be passing words? + if self.options['pass_words']: + cmd+=" "+t + self.run_command(cmd) + else: + self.run_command(cmd) self.log_history(text) else: #run the invalid_sentence_command if there is a valid sentence command @@ -192,6 +201,10 @@ if __name__ == "__main__": action="store_true", dest="continuous", default=False, help="starts interface with 'continuous' listen enabled") + parser.add_option("-p", "--pass-words", + action="store_true", dest="pass_words", default=False, + help="passes the recognized words as arguments to the shell command") + parser.add_option("-o", "--override", action="store_true", dest="override", default=False, help="override config file with command line options") diff --git a/GtkTrayUI.py b/GtkTrayUI.py index 24e2b57..f0d1c2e 100644 --- a/GtkTrayUI.py +++ b/GtkTrayUI.py @@ -80,7 +80,6 @@ class UI(gobject.GObject): self.emit("command", "quit") def finished(self, text): - print text if not self.menu_continuous.get_active(): self.menu_listen.set_label("Listen") self.statusicon.set_from_icon_name("blather_stopped") diff --git a/GtkUI.py b/GtkUI.py index 71255fc..17c7b50 100644 --- a/GtkUI.py +++ b/GtkUI.py @@ -90,7 +90,6 @@ class UI(gobject.GObject): self.emit("command", "quit") def finished(self, text): - print text #if the continuous isn't pressed if not self.ccheckbox.get_active(): self.lsbutton_stopped() diff --git a/QtUI.py b/QtUI.py index 4b17d9f..728ff80 100644 --- a/QtUI.py +++ b/QtUI.py @@ -93,7 +93,6 @@ class UI(gobject.GObject): self.emit("command", "quit") def finished(self, text): - print text #if the continuous isn't pressed if not self.ccheckbox.isChecked(): self.lsbutton_stopped() -- cgit 1.4.1