Browse Source

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.
Clara Hobbs 8 years ago
parent
commit
0d67d50252
2 changed files with 9 additions and 11 deletions
  1. 0
    4
      blather.py
  2. 9
    7
      recognizer.py

+ 0
- 4
blather.py View File

@@ -84,21 +84,17 @@ class Blather:
84 84
 
85 85
         self.recognizer.connect('finished', self.recognizer_finished)
86 86
 
87
-        print("Using Options: ", self.options)
88
-
89 87
     def read_commands(self):
90 88
         # Read the commands file
91 89
         file_lines = open(command_file)
92 90
         strings = open(strings_file, "w")
93 91
         for line in file_lines:
94
-            print(line)
95 92
             # Trim the white spaces
96 93
             line = line.strip()
97 94
             # If the line has length and the first char isn't a hash
98 95
             if len(line) and line[0]!="#":
99 96
                 # This is a parsible line
100 97
                 (key, value) = line.split(":", 1)
101
-                print(key, value)
102 98
                 self.commands[key.strip().lower()] = value.strip()
103 99
                 strings.write(key.strip() + "\n")
104 100
         # Close the strings file

+ 9
- 7
recognizer.py View File

@@ -27,7 +27,14 @@ class Recognizer(GObject.GObject):
27 27
             audio_src = 'autoaudiosrc'
28 28
 
29 29
         # Build the pipeline
30
-        cmd = audio_src + ' ! audioconvert ! audioresample ! pocketsphinx name=asr ! appsink sync=false'
30
+        cmd = (
31
+            audio_src +
32
+            ' ! audioconvert' +
33
+            ' ! audioresample' +
34
+            ' ! pocketsphinx lm=' + language_file + ' dict=' +
35
+            dictionary_file + ' configured=true' +
36
+            ' ! appsink sync=false'
37
+        )
31 38
         try:
32 39
             self.pipeline = Gst.parse_launch(cmd)
33 40
         except Exception as e:
@@ -35,15 +42,10 @@ class Recognizer(GObject.GObject):
35 42
             print("You may need to install gstreamer1.0-pocketsphinx")
36 43
             raise e
37 44
 
45
+        # Process results from the pipeline with self.result()
38 46
         bus = self.pipeline.get_bus()
39 47
         bus.add_signal_watch()
40
-
41
-        # Get the Auto Speech Recognition piece
42
-        asr = self.pipeline.get_by_name('asr')
43 48
         bus.connect('message::element', self.result)
44
-        asr.set_property('lm', language_file)
45
-        asr.set_property('dict', dictionary_file)
46
-        asr.set_property('configured', True)
47 49
 
48 50
     def listen(self):
49 51
         self.pipeline.set_state(Gst.State.PLAYING)

Loading…
Cancel
Save