Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

revise the leds #386

Open
wants to merge 1 commit into
base: aiyprojects
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/examples/voice/cloudspeech_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,22 @@

import aiy.audio
import aiy.cloudspeech
import aiy.voicehat

from aiy.leds import Leds
from aiy.leds import Pattern
from aiy.leds import RgbLeds

leds = Leds()

"Choose Led colors here."

RED = (0xFF, 0x00, 0x00)
GREEN = (0x00, 0xFF, 0x00)
YELLOW = (0xFF, 0xFF, 0x00)
BLUE = (0x00, 0x00, 0xFF)
PURPLE = (0xFF, 0x00, 0xFF)
CYAN = (0x00, 0xFF, 0xFF)
WHITE = (0xFF, 0xFF, 0xFF)


def main():
Expand All @@ -27,7 +42,6 @@ def main():
recognizer.expect_phrase('blink')

button = aiy.voicehat.get_button()
led = aiy.voicehat.get_led()
aiy.audio.get_recorder().start()

while True:
Expand All @@ -40,11 +54,12 @@ def main():
else:
print('You said "', text, '"')
if 'turn on the light' in text:
led.set_state(aiy.voicehat.LED.ON)
leds.update(Leds.rgb_on(WHITE))
elif 'turn off the light' in text:
led.set_state(aiy.voicehat.LED.OFF)
leds.update(Leds.rgb_off())
elif 'blink' in text:
led.set_state(aiy.voicehat.LED.BLINK)
leds.pattern = Pattern.blink(500)
leds.update(Leds.rgb_pattern(WHITE))
elif 'goodbye' in text:
break

Expand Down