diff options
Diffstat (limited to 'Recognizer.py')
-rwxr-xr-x | Recognizer.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Recognizer.py b/Recognizer.py index 8497839..26ccd80 100755 --- a/Recognizer.py +++ b/Recognizer.py @@ -16,11 +16,16 @@ class Recognizer(gobject.GObject): __gsignals__ = { 'finished' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)) } - def __init__(self, language_file, dictionary_file): + def __init__(self, language_file, dictionary_file, src = None): gobject.GObject.__init__(self) self.commands = {} + if src: + audio_src = 'alsasrc device="hw:%d,0"' % (src) + else: + audio_src = 'autoaudiosrc' + #build the pipeline - cmd = 'autoaudiosrc ! audioconvert ! audioresample ! vader name=vad ! pocketsphinx name=asr ! appsink sync=false' + cmd = audio_src+' ! audioconvert ! audioresample ! vader name=vad ! pocketsphinx name=asr ! appsink sync=false' self.pipeline=gst.parse_launch( cmd ) #get the Auto Speech Recognition piece asr=self.pipeline.get_by_name('asr') @@ -31,10 +36,10 @@ class Recognizer(gobject.GObject): #get the Voice Activity DEtectoR self.vad = self.pipeline.get_by_name('vad') self.vad.set_property('auto-threshold',True) - + def listen(self): self.pipeline.set_state(gst.STATE_PLAYING) - + def pause(self): self.vad.set_property('silent', True) self.pipeline.set_state(gst.STATE_PAUSED) @@ -42,4 +47,4 @@ class Recognizer(gobject.GObject): def result(self, asr, text, uttid): #emit finished self.emit("finished", text) - + |