Real-time speech recognition using Pocket Sphinx, GStreamer, and Python in Ubuntu 14.04.2
The following is the code for real-time speech recognition using GStreamer:
#!/usr/bin/env python
#The following modules need to import before handling gstreamer API's
import gobject
import sys
import pygst
pygst.require('0.10')
gobject.threads_init()
import gst
#Module to handle keyboard interrupt signal
import signal
#Keyboard signal handling routine
def signal_handle(signal, frame):
print "You pressed Ctrl+C"
sys.exit(0)
#Implementation of Speech recognition class
class Speech_Recog(object):
#Initializing gstreamer pipeline and pocket sphinx element
def __init__(self):
self.init_gst()
#This function will initialize gstreamer pipeline
def init_gst(self):
#The following code create a gstreamer pipeline with pipeline description. The required descriptors needed for the code is given as parameters.
self.pipeline = gst.parse_launch('gconfaudiosrc !audioconvert ! audioresample...