def main(): logging.basicConfig(level=logging.INFO) config = avs.config.DEFAULT_CONFIG_FILE if len( sys.argv) < 2 else sys.argv[1] if not os.path.isfile(config): print('Login amazon alexa or baidu dueros first') avs.auth.auth(None, config) audio = Audio() alexa = Alexa(config) audio.link(alexa) alexa.start() audio.start() is_quit = threading.Event() def signal_handler(sig, frame): print('Quit') is_quit.set() signal.signal(signal.SIGINT, signal_handler) while True: try: input('press ENTER to talk\n') except SyntaxError: pass except NameError: pass if is_quit.is_set(): break alexa.listen() alexa.stop() audio.stop()
def main(): from respeaker.pixel_ring import pixel_ring config = None if len(sys.argv) < 2 else sys.argv[1] audio = Audio(frames_size=1600) kws = KWS() alexa = Alexa(config) def speak(): pixel_ring.speak(10, 0) alexa.state_listener.on_listening = pixel_ring.listen alexa.state_listener.on_thinking = pixel_ring.wait alexa.state_listener.on_speaking = speak alexa.state_listener.on_finished = pixel_ring.off audio.link(kws) kws.link(alexa) def wakeup(keyword): if keyword.find('alexa') >= 0: alexa.listen() kws.set_callback(wakeup) alexa.start() kws.start() audio.start() while True: try: time.sleep(1) except KeyboardInterrupt: break alexa.stop() kws.stop() audio.stop()
def main(): logging.basicConfig(level=logging.INFO) config = None if len(sys.argv) < 2 else sys.argv[1] audio = Audio() alexa = Alexa(config) audio.link(alexa) alexa.start() audio.start() is_quit = threading.Event() def signal_handler(sig, frame): print('Quit') is_quit.set() signal.signal(signal.SIGINT, signal_handler) while True: try: input('press ENTER to talk\n') except SyntaxError: pass except NameError: pass if is_quit.is_set(): break alexa.listen() alexa.stop() audio.stop()