Просмотр исходного кода

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 лет назад
Родитель
Сommit
0d67d50252
2 измененных файлов: 9 добавлений и 11 удалений
  1. 0
    4
      blather.py
  2. 9
    7
      recognizer.py

+ 0
- 4
blather.py Просмотреть файл

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

+ 9
- 7
recognizer.py Просмотреть файл

27
             audio_src = 'autoaudiosrc'
27
             audio_src = 'autoaudiosrc'
28
 
28
 
29
         # Build the pipeline
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
         try:
38
         try:
32
             self.pipeline = Gst.parse_launch(cmd)
39
             self.pipeline = Gst.parse_launch(cmd)
33
         except Exception as e:
40
         except Exception as e:
35
             print("You may need to install gstreamer1.0-pocketsphinx")
42
             print("You may need to install gstreamer1.0-pocketsphinx")
36
             raise e
43
             raise e
37
 
44
 
45
+        # Process results from the pipeline with self.result()
38
         bus = self.pipeline.get_bus()
46
         bus = self.pipeline.get_bus()
39
         bus.add_signal_watch()
47
         bus.add_signal_watch()
40
-
41
-        # Get the Auto Speech Recognition piece
42
-        asr = self.pipeline.get_by_name('asr')
43
         bus.connect('message::element', self.result)
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
     def listen(self):
50
     def listen(self):
49
         self.pipeline.set_state(Gst.State.PLAYING)
51
         self.pipeline.set_state(Gst.State.PLAYING)

Загрузка…
Отмена
Сохранить