def test_rec(self): recorder = PulseRecorder(SOURCE, SAMPLERATE, VOLUME) recorder.start_recording(1000) time.sleep(1) recorder.stop_recording() samples = recorder.get_samples() logging.debug(repr(samples)) self.assertGreater(len(samples), 900)
continue user_utt, c = asr.decode(audio, finalize) print("\r%s " % user_utt, end='', flush=True) if finalize: print() intent = utt_map.get(user_utt, None) if intent == Intent.HELLO: resp = "Hello there!" elif intent == Intent.LIGHT: if lights_on: resp = "OK, switching off the lights." else: resp = "OK, switching on the lights." lights_on = not lights_on elif intent == Intent.RADIO: if radio_on: resp = "OK, switching off the radio." else: resp = "OK, switching on the radio." radio_on = not radio_on if not intent: continue rec.stop_recording() print(resp) tts.say(resp) rec.start_recording()
if not audio: continue recording.extend(audio) user_utt, confidence = asr.decode(audio, finalize) print "\r \rYou: %s " % user_utt, if finalize and not user_utt: finalize = False recording = [] logging.info ("conv_user: %s" % user_utt) rec.stop_recording() print # import pdb; pdb.set_trace() ai_utt, score, action = kernal.process_input(ctx, user_utt) print('AI : %s' % ai_utt) logging.info ("conv_ai : %s" % ai_utt) if action: print(' %s' % repr(action)) logging.info ("conv_action: %s" % repr(action)) if ai_utt: tts.say(ai_utt)