def __init__(self): self.microphone = mic.Mic(lmd='models/lm.lm', dictd='models/dic.dic', lmd_persona='models/waitlm.lm', dictd_persona='models/waitdic.dic') self.THRESHOLD = self.microphone.fetchThreshold() print('Threshold: ' + str(self.THRESHOLD)) self.run_client = False self.client = None
def get_fav_ice_cream(): microphone = mic.Mic(lmd='models/creamlm.lm', dictd='models/creamdic.dic', lmd_persona='models/waitlm.lm', dictd_persona='models/waitdic.dic') while True: fav_cream = microphone.activeListen() if fav_cream != '': break fav_cream = fav_cream.lower().capitalize() return fav_cream
def get_fav_color(): microphone = mic.Mic(lmd='models/colorlm.lm', dictd='models/colordic.dic', lmd_persona='models/waitlm.lm', dictd_persona='models/waitdic.dic') while True: fav_color = microphone.activeListen() if fav_color != '': break fav_color = fav_color.lower().capitalize() return fav_color
def get_age(): microphone = mic.Mic(lmd='models/agelm.lm', dictd='models/agedic.dic', lmd_persona='models/waitlm.lm', dictd_persona='models/waitdic.dic') while True: age = microphone.activeListen() if age != '': break age = age.lower().capitalize() return age
def createMic(ENVIRON, speech): tts_engine_class = tts.get_engine_by_slug(speech) stt_engine = stt.robotAI_stt(ENVIRON) MIC = mic.Mic(tts_engine_class.get_instance(), stt_engine, ENVIRON) return MIC
#!/usr/bin/env python # coding: utf-8 #https://www.cnblogs.com/jokerspace/p/6685388.html import sys import conversation import mic import stt reload(sys) sys.setdefaultencoding('utf-8') if __name__ == '__main__': persona = ['多啦a梦', '哆啦a梦'] profile = [] stt_engine_slug = 'baidu-stt' stt_engine_class = stt.get_engine_by_slug(stt_engine_slug) stt_passive_engine_class = stt_engine_class micphone = mic.Mic(stt_passive_engine_class.get_passive_instance(), stt_engine_class.get_active_instance()) conver_sation = conversation.conversation(persona, micphone, profile) conver_sation.handleForever()