Let's add a button to our voice assistant. This momentary push button is connected to pin 2 (BCM numbering) and the LED is connected to pin 3.
Voice Assistant interface setup
- In order to read the button presses, we need to import the Button class from gpiozero:
from gpiozero import Button, OutputDevice
- When a button is pressed, the voice assistant needs to play a beep sound indicating that it is awaiting the user's command. Beep sounds of your choice can be downloaded from www.freesound.org.
- Following the beep sound, the user command is recorded for a duration of 5 seconds. The recorded file is then processed using the ...