In this video lesson you will learn how to train the Raspberry Pi to take voice commands from you. We do this through the Fusion AI+ hat’s microphone, and a Speech to Text (STT) model. Our goal is to develop the ability to interact with our projects through spoken words. We give commands to the project, and then it responds intelligently with words.
Remember these lessons depend on you using the AI Educational OS, a special version of bookworm that has all the libraries, modules, and models already installed for you. See LESSON #2 in this class for instructions on flashing that OS.
Below is the simple demonstration code we developed to give simple voice commands:
1 2 3 4 5 6 7 8 | from fusion_hat.stt import STT stt = STT(language="en-us") while True: print("Say Something: ") command = stt.listen(stream=False) print(command) |
Similar to our Speech to Text example, the first time you run this program you will get a permissions error. You need to open a terminal, and put these commands in one at a time to enable permissions. This only has to be done once, and after that this and all STT programs should run properly.
1 2 3 | sudo mkdir -p /opt/vosk_models sudo chown -R pi:pi /opt/vosk_models sudo chmod -R 755 /opt/vosk_models |
