Esempio n. 1
0
 def do_TTS(self, tts_slug):
     global tts
     if tts_slug == 'baidu-tts':
         tts = TTS.BaiduTTS()
     elif tts_slug == 'xunfei-tts':
         tts = TTS.XunfeiTTS()
     else:
         tts = TTS.BaiduTTS()
     return tts
 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))
Esempio n. 3
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))
Esempio n. 4
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))
Esempio n. 5
0
    def say(self, phrase, delete=False):
        """
        播放
        """
        # 实例化播放的方法
        global tts
        # type=1,机器人说的话
        self.appendHistory(1,phrase)
        self.player = Player.SoxPlayer()
        # 实例化语音合成的方法
        tts_slug = TTS.get_engine_by_slug(config.get('/tts_engine'))
        self.do_TTS(tts_slug)
        # 得到需要播放的音频进行播放
        fp = tts.get_speech(phrase)

        self.player.play(fp, True)
Esempio n. 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'))
Esempio n. 7
0
def hello():
    name = config.get('/name')
    phrase = '{}你好,试试对我喊唤醒词唤醒我吧'.format(name)
    tts = TTS.BaiduTTS()
    fp = tts.get_speech(phrase)
    SoxPlayer().play(fp, True)