diff options
-rwxr-xr-x | blather.py | 4 | ||||
-rwxr-xr-x | recognizer.py | 16 |
2 files changed, 9 insertions, 11 deletions
diff --git a/blather.py b/blather.py index d7fa14b..7cfe276 100755 --- a/blather.py +++ b/blather.py @@ -84,21 +84,17 @@ class Blather: self.recognizer.connect('finished', self.recognizer_finished) - print("Using Options: ", self.options) - def read_commands(self): # Read the commands file file_lines = open(command_file) strings = open(strings_file, "w") for line in file_lines: - print(line) # Trim the white spaces line = line.strip() # If the line has length and the first char isn't a hash if len(line) and line[0]!="#": # This is a parsible line (key, value) = line.split(":", 1) - print(key, value) self.commands[key.strip().lower()] = value.strip() strings.write(key.strip() + "\n") # Close the strings file diff --git a/recognizer.py b/recognizer.py index 02424a8..ac970a0 100755 --- a/recognizer.py +++ b/recognizer.py @@ -27,7 +27,14 @@ class Recognizer(GObject.GObject): audio_src = 'autoaudiosrc' # Build the pipeline - cmd = audio_src + ' ! audioconvert ! audioresample ! pocketsphinx name=asr ! appsink sync=false' + cmd = ( + audio_src + + ' ! audioconvert' + + ' ! audioresample' + + ' ! pocketsphinx lm=' + language_file + ' dict=' + + dictionary_file + ' configured=true' + + ' ! appsink sync=false' + ) try: self.pipeline = Gst.parse_launch(cmd) except Exception as e: @@ -35,15 +42,10 @@ class Recognizer(GObject.GObject): print("You may need to install gstreamer1.0-pocketsphinx") raise e + # Process results from the pipeline with self.result() bus = self.pipeline.get_bus() bus.add_signal_watch() - - # Get the Auto Speech Recognition piece - asr = self.pipeline.get_by_name('asr') bus.connect('message::element', self.result) - asr.set_property('lm', language_file) - asr.set_property('dict', dictionary_file) - asr.set_property('configured', True) def listen(self): self.pipeline.set_state(Gst.State.PLAYING) |