model = sys.argv[1] pwd = os.path.abspath(os.curdir) config = Decoder.default_config() # custom config # hmdir = '/usr/local/share/pocketsphinx/model/en-us/en-us' # lmd = os.path.join(pwd, '{0}.lm'.format(model)) # dictd = os.path.join(pwd, '{0}.dic'.format(model)) # config.set_string('-hmm', hmdir) # config.set_string('-lm', lmd) # config.set_string('-dict', dictd) # copy pasta config MODELDIR = "/usr/local/share/pocketsphinx/model/" config.set_string("-hmm", os.path.join(MODELDIR, "en-us/en-us")) config.set_string("-lm", os.path.join(MODELDIR, "en-us/en-us-phone.lm.bin")) config.set_string("-dict", os.path.join(MODELDIR, "en-us/cmudict-en-us.dict")) log = os.path.join(pwd, "output.log") config.set_string("-logfn", log) decoder = Decoder(config) wavfile = "myfile.wav" print recog(wavfile, decoder)
RATE = 16000 hmdir = '/usr/local/share/pocketsphinx/model/en-us/en-us' lmd = '/srv/madalyn/0844.lm' dictd = '/srv/madalyn/0844.dic' log = '/srv/madalyn/output.log' config = ps.Decoder.default_config() config.set_string('-hmm', hmdir) config.set_string('-lm', lmd) config.set_string('-dict', dictd) # config.set_string('-logfn', log) # config.set_string('-keyphrase', 'jarvis') # config.set_float('-kws_threshold', 1e-40) speechRec = ps.Decoder(config) while True: wavfile = record(2) results = recog(wavfile, speechRec) if results: results = results.lower() print results if 'jarvis' in results or 'madalyn' in results: print 'got cmd start' results = recog(record(3), speechRec) if results: results = results.lower() print results madalyn_go(results)