def main(): # 创建录音设备(平台相关) audio = Audio() # 创建播放器(平台相关) player = Player() dueros = DuerOS(player) dueros.set_directive_listener(directive_listener) audio.link(dueros) dueros.start() audio.start() prompt_tone_player = PromptTone() while True: try: try: print '\n' input('单击[Enter]建,然后发起对话\n') except SyntaxError: pass # 唤醒态提示音 prompt_tone_player.play() dueros.listen() except KeyboardInterrupt: break dueros.stop() audio.stop()
def main(): audio = Audio() player = Player() dueros = DuerOS(player) dueros.set_directive_listener(directive_listener) audio.link(dueros) dueros.start() audio.start() prompt_tone_player = PromptTone() while True: try: try: print '\n' input('input [ENTER] key to start conversation\n') except SyntaxError: pass prompt_tone_player.play() dueros.listen() except KeyboardInterrupt: break dueros.stop() audio.stop()