本文整理汇总了Python中context.Context.getPocketsphinx方法的典型用法代码示例。如果您正苦于以下问题:Python Context.getPocketsphinx方法的具体用法?Python Context.getPocketsphinx怎么用?Python Context.getPocketsphinx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类context.Context
的用法示例。
在下文中一共展示了Context.getPocketsphinx方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import getPocketsphinx [as 别名]
def __init__(self):
# Create and configure decoder
self.config = Decoder.default_config()
self.config.set_string('-hmm', path.join(Analyser.MODELDIR, Analyser.HMM))
self.config.set_string('-lm', path.join(Analyser.MODELDIR, Analyser.HMM, '%s.lm' % Context.getPocketsphinx('dict')))
self.config.set_string('-dict', path.join(Analyser.MODELDIR, Analyser.HMM, '%s.dic' % Context.getPocketsphinx('dict')))
self.config.set_string('-logfn', '/dev/null')
self.decoder = Decoder(self.config)
示例2: int
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import getPocketsphinx [as 别名]
import scikits.audiolab, numpy, subprocess, sys, logging, audioop, time, pycurl, StringIO, os
from context import Context
from pocketsphinx import *
from os import path
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s\t(%(threadName)-10s) %(filename)s:%(lineno)d\t%(message)s')
MODELDIR = Context.getPocketsphinx('model.dir')
HMM = Context.getPocketsphinx('hmm')
THRESHOLD = int(Context.getAudio('threshold'))
SEC2LISTEN = Context.getAudio('sec2listen')
# Create and configure decoder
config = Decoder.default_config()
config.set_string('-hmm', path.join(MODELDIR, HMM))
config.set_string('-lm', path.join(MODELDIR, HMM, '%s.lm' % Context.getPocketsphinx('dict')))
config.set_string('-dict', path.join(MODELDIR, HMM, '%s.dic' % Context.getPocketsphinx('dict')))
config.set_string('-logfn', '/dev/null')
decoder = Decoder(config)
# function run 'arecord' console cmd for 'sec' seconds and gives back it's stdout
def listen(sec):
reccmd = ["arecord", "-D", "plughw:0,0", "-f", "cd", "-c", "1", "-t", "wav", "-d", "%s"%sec, "-q", "-r", Context.getAudio('rate')]
proc = subprocess.Popen(reccmd, stdout=subprocess.PIPE)
return proc.stdout.read()
# function decode data using decoder, and return decoded string or None
def decodeOffline(decoder, data):
decoder.start_utt()
decoder.process_raw(data, False, False)
decoder.end_utt()
if decoder.hyp() is not None and decoder.hyp().hypstr: