Пример #1
0
def process_event(event):
    """Pretty prints events.

    Prints all events that occur with two spaces between each new
    conversation and a single space between turns of a conversation.

    Args:
        event(event.Event): The current event to process.
    """
    print("event:" + str(event))

    if event.type == EventType.ON_CONVERSATION_TURN_STARTED:
        subprocess.Popen(
            ["aplay", "/home/pi/piassistant/src/sample-audio/Fb.wav"],
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
        pixel_ring.listen()

    if event.type == EventType.ON_RESPONDING_STARTED:
        pixel_ring.speak()

    if event.type == EventType.ON_RESPONDING_FINISHED or event.type == EventType.ON_CONVERSATION_TURN_TIMEOUT or event.type == EventType.ON_NO_RESPONSE:
        pixel_ring.off()

    if event.type == EventType.ON_END_OF_UTTERANCE:
        pixel_ring.think()

    if (event.type == EventType.ON_CONVERSATION_TURN_FINISHED and event.args
            and not event.args['with_follow_on_turn']):
        pixel_ring.off()

    if event.type == EventType.ON_DEVICE_ACTION:
        for command, params in event.actions:
            print('Do command', command, 'with params', str(params))
Пример #2
0
 def on_handler_audio_start(self, message):
     """Light up LED when speaking, show volume if requested"""
     if self.show_volume:
         pixel_ring.set_volume(int(self.volume * self.num_leds))
     else:
         self.speaking = True
         pixel_ring.set_color_palette(self.main_blue, self.tertiary_blue)
         pixel_ring.speak()
Пример #3
0
 def record_begin_handler(self, message):
     pixel_ring.wakeup()
     time.sleep(2)
     pixel_ring.think()
     time.sleep(2)
     pixel_ring.speak()
     time.sleep(3)
     pixel_ring.off()
     time.sleep(2)
     pixel_ring.off()
Пример #4
0
 def on_message(client, userdata, msg):
     LOGGER.debug(
         "Received '%s' from '%s' topic",
         msg.payload.decode(), msg.topic
         )
     if "sessionStarted" in msg.topic:
         # listening
         LOGGER.debug("Light waking up")
         pixel_ring.wakeup()
     elif "stopListening" in msg.topic:
         # processing
         LOGGER.debug("Light processing...")
         pixel_ring.think()
     elif "intentParsed" in msg.topic:
         # command detected
         LOGGER.debug("Light speaking...")
         pixel_ring.speak()
     elif "sessionEnded" in msg.topic:
         # stop flashing
         LOGGER.debug("Light turning off...")
         pixel_ring.off()
from pixel_ring import pixel_ring
import mraa
import os

en = mraa.Gpio(12)
if os.geteuid() != 0:
    time.sleep(1)

en.dir(mraa.DIR_OUT)
en.write(0)

if __name__ == '__main__':
    while True:

        try:
            pixel_ring.wakeup()
            time.sleep(3)
            pixel_ring.think()
            time.sleep(3)
            pixel_ring.speak()
            time.sleep(6)
            pixel_ring.off()
            time.sleep(3)
        except KeyboardInterrupt:
            break

    pixel_ring.off()
    time.sleep(1)

en.write(1)
Пример #6
0
 def on_speaking():
     global state
     print("===== on_speaking =====\r\n")
     state = 'speaking'
     src.on_speak()
     pixel_ring.speak()
Пример #7
0
 def handler_listener_speak(self, message):
     self.log.info("Pixel Ring: Speak")
     pixel_ring.speak()
Пример #8
0
 def handle_listener_speak(self, message):
     LOG.debug("speak")
     pixel_ring.speak()
Пример #9
0
def waiting():
    pixel_ring.speak()
Пример #10
0
def speak(n):
    time_end = start_LED(n)
    pixel_ring.wakeup()
    pixel_ring.speak()
    time.sleep(n)
    end_LED()
Пример #11
0
 def handler_audio_output_start(self, message):
     # code to excecute when recognizer_loop:audio_output_start message detected...
     self.log.info("speaking")
     pixel_ring.speak()
Пример #12
0
 def on_speaking(self):
     print("===== on_speaking =====")
     self.state = 'speaking'
     pixel_ring.speak()
 def handle_listener_speak(self, message):
     pixel_ring.speak()
Пример #14
0
 def speak(self) -> None:
     """Show speak interaction."""
     pixel_ring.speak()