Example #1
0
 def do_ASR(self, asr_slug):
     global asr
     if asr_slug == 'xunfei-asr':
         asr = ASR.XunfeiASR()
     elif asr_slug == 'baidu-asr':
         asr = ASR.BaiduASR()
     else:
         asr = ASR.BaiduASR()
     return asr
 def reload(self):
     """ 重新初始化 """
     try:
         self.asr = ASR.get_engine_by_slug(config.get('asr_engine', 'tencent-asr'))
         self.ai = AI.get_robot_by_slug(config.get('robot', 'tuling'))
         self.tts = TTS.get_engine_by_slug(config.get('tts_engine', 'baidu-tts'))
     except Exception as e:
         logger.critical("对话初始化失败:{}".format(e))
Example #3
0
 def converse(self, fp):
     # 播放唤醒后提示音
     global asr,asr_slug
     statistic.active()
     Player.player('static/beep_lo.wav', False)
     asr_slug = ASR.get_engine_by_slug(config.get('/asr_engine'))
     self.do_ASR(asr_slug)
     # 将语音翻译为文本
     query = asr.transcribe(fp)
     self.doResponse(query)
     # 删除临时存在的语音文件
     utils.check_and_delete(fp)
Example #4
0
 def reload(self):
     """ 重新初始化 """
     try:
         self.asr = ASR.get_engine_by_slug(config.get('asr_engine', 'tencent-asr'))
         self.ai = AI.get_robot_by_slug(config.get('robot', 'tuling'))
         self.tts = TTS.get_engine_by_slug(config.get('tts_engine', 'baidu-tts'))
         self.nlu = NLU.get_engine_by_slug(config.get('nlu_engine', 'unit'))
         self.player = None
         self.brain = Brain(self)
         self.brain.printPlugins()
     except Exception as e:
         logger.critical("对话初始化失败:{}".format(e))
Example #5
0
 def reInit(self):
     """重新初始化"""
     try:
         self.asr = ASR.get_engine_by_slug(
             config.get("asr_engine", "tencent-asr"))
         self.ai = AI.get_robot_by_slug(config.get("robot", "tuling"))
         self.tts = TTS.get_engine_by_slug(
             config.get("tts_engine", "baidu-tts"))
         self.nlu = NLU.get_engine_by_slug(config.get("nlu_engine", "unit"))
         self.player = None
         self.brain = Brain(self)
         self.brain.printPlugins()
     except Exception as e:
         logger.critical("对话初始化失败:{}".format(e))
Example #6
0
def init():
    global asr, ai, tts
    config.init()
    asr = ASR.get_engine_by_slug(config.get('asr_engine', 'tencent-asr'))
    ai = AI.get_robot_by_slug(config.get('robot', 'tuling'))
    tts = TTS.get_engine_by_slug(config.get('tts_engine', 'baidu-tts'))
Example #7
0
def audioRecorderCallback(fname):
    global player
    Player.play('static/beep_lo.wav', False)
    print(ASR.transcribe(fname))