Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Python Gstreamer PocketSphinx example

By: a guest on Feb 4th, 2011  |  syntax: Python  |  size: 0.75 KB  |  views: 662  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import pygtk,gtk,gobject
  2. gobject.threads_init()
  3. import gst
  4.  
  5. def result(asr, text, uttid): print text
  6.  
  7.  
  8. pipeline=gst.parse_launch('pulsesrc ! audioconvert ! audioresample  ! vader name=vad auto-threshold=true ! pocketsphinx name=asr ! appsink sync=false name=appsink')
  9. #pipeline=gst.parse_launch('pulsesrc  ! tee  name=t ! queue ! audioconvert ! audioresample ! vader name=vad auto-threshold=true ! pocketsphinx name=asr ! appsink    sync=false name=appsink  t. queue ! audioconvert ! audioresample ! wavenc ! filesink location=o.wav')
  10. asr=pipeline.get_by_name('asr')
  11. asr.connect('result', result)
  12. #asr.set_property('lm', '1.lm')
  13. #asr.set_property('dict', '1.dic')
  14. asr.set_property('configured', True)
  15. pipeline.set_state(gst.STATE_PLAYING)
  16. gtk.main()
clone this paste RAW Paste Data