|
@@ -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)
|