In this video lesson I show you my solution to the homework assignment I gave in LESSON #10. The assignment was to control an LED using voice commands on the Raspberry Pi. This uses the Speech To Text expertise we developed in the last few lessons, but incorporates them into a real world project. With this basic framework, you are now equipped to make speech part of your future Raspberry Pi projects.
This is the schematic of the circuit we are using for our AI class. We go into great detail on this schematic in LESSON #5 if you want to learn more about it.

Now this is the code we developed in this lesson:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | from fusion_hat.stt import STT from fusion_hat.pin import Pin, Mode from time import sleep redPin = 17 redLED = Pin(redPin,mode=Mode.OUT) stt = STT(language="en-us") while True: print("Voice Assistant At the READY!, Speak at Any Time: ") command = stt.listen(stream=False) command = command.strip() print(command) if command == "on": redLED.high() print("LED ON") if command == "off": redLED.low() print("LED OFF") if command == "quit": break redLED.low() |