예제 #1
0
def main():
    from avs.alexa import Alexa
    from avs.mic import Audio

    logging.basicConfig(level=logging.DEBUG)

    config = None if len(sys.argv) < 2 else sys.argv[1]

    audio = Audio()
    kws = KWS()
    alexa = Alexa(config)

    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()
예제 #2
0
def main():
    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()

    is_quit = threading.Event()

    def signal_handler(signal, frame):
        print('Quit')
        is_quit.set()

    signal.signal(signal.SIGINT, signal_handler)

    while not is_quit.is_set():
        time.sleep(1)

    alexa.stop()
    kws.stop()
    audio.stop()
예제 #3
0
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()