def test_tts_espeak(self): config = misc.load_config('.speechrc') tts = TTS(config.get('tts', 'host'), int(config.get('tts', 'port'))) tts.engine = 'espeak' first = True for v, word, ph in ESPEAK_TESTS: tts.locale = v tts.voice = v espeak_ph = tts.gen_ipa(word) self.assertEqual(espeak_ph, ph) wav = tts.synthesize(word) logging.debug('wav len: %d bytes.' % len(wav)) self.assertGreater(len(wav), 100) wav = tts.synthesize(ph, mode='ipa') logging.debug('wav len: %d bytes.' % len(wav)) self.assertGreater(len(wav), 100) if first: tts.say(word) first = False
def test_tts_pico(self): config = misc.load_config('.speechrc') tts = TTS(config.get('tts', 'host'), int(config.get('tts', 'port'))) tts.engine = 'pico' for v, word in PICO_TESTS: tts.locale = v tts.voice = v wav = tts.synthesize(word) logging.debug('wav len: %d bytes.' % len(wav)) self.assertGreater(len(wav), 100) tts.say(word)
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()
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) print
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) print
#!/usr/bin/env python3 from nltools.tts import TTS tts = TTS(engine="espeak", voice="en") tts.say("hello from your pi")