summary refs log tree commit diff
path: root/recognizer.py
diff options
context:
space:
mode:
authorClayton G. Hobbs <clay@lakeserv.net>2015-12-27 13:57:33 -0500
committerClayton G. Hobbs <clay@lakeserv.net>2015-12-27 13:57:33 -0500
commit0d67d50252849eca6e659f2daf20616542ec2a05 (patch)
treecacc4f1a2f1e41d13d0f3f4aa491f073ae7b19a6 /recognizer.py
parent87c0a1bfe93ffbe7eb67c41ea2b46fd5a7c1ab28 (diff)
Quieter; reorganize gst pipeline code
Removed a bunch of print statements that looked like they were added for
debugging, then never removed.

Reorganized GStreamer pipeline code so that all configuration is done
when the pipeline is created.
Diffstat (limited to 'recognizer.py')
-rwxr-xr-xrecognizer.py16
1 files changed, 9 insertions, 7 deletions
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)