decoder.process_raw(buf, False, False) if DEBUG: words = decoder.hyp().hypstr.split(' ') print len(words) if decoder.hyp() != None and keyword in decoder.hyp().hypstr: print 'Jarvis is ready...' speech = decoder.hyp().hypstr words = speech.split(' ') # only use last ten words spoken if len(words) >= 10: print words command = ' '.join([x for x in words[-10:]]) else: print words command = ' '.join([x for x in words]) print 'running command:', command madalyn_go(command) decoder.end_utt() decoder.start_utt() except KeyboardInterrupt as e: print e RoomControl('D0', 0) sys.exit(0) except Exception as e: print e
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)