This project is a Wi-Fi speech recognition robot that can be controlled using voice commands. It uses an ESP32 board, your laptop's microphone, and a motor driver to control the movement of the robot. The robot can be connected to a Wi-Fi network and controlled using a Python script located in the server folder.
The Python script listens for incoming requests from the robot and uses the Google Cloud Speech-to-Text API to convert the audio to text, through SpeechRecognition. The text is then parsed and executed on the robot using the DDBot.
-
[OPTIONAL STEP] Use a Python virtual environment.
Create a Python virtual environment in the
server
folder.python -m venv .venv
Activate the virtual environment, following the documentation from Python.
-
Install the required Python packages.
python -m pip install -r requirements.txt
-
Configure the Wi-Fi credentials in the
secrets.h
file.To set up the Wi-Fi credentials, create a file named
secrets.h
in theinclude
folder. The file should contain the following code:#define SSID "your_wifi_ssid" #define PASSWORD "your_wifi_password"
Ensure to replace
your_wifi_ssid
andyour_wifi_password
with your Wi-Fi credentials. -
Upload the code to the ESP32 board. It should print the IP address of the board in the serial monitor, but you obviously can't see it once you're running wirelessly. In this case, you can use your router's admin page to find the IP address of the board.
-
Set the IP address and run the Python script.
You need to set the IP address of the ESP32 board as an environment variable named
ESP_IP
.To do so in Windows (no PowerShell), run the following command:
$env:ESP_IP = "your_esp_ip_address"
To do so in Linux, run the following command:
export ESP_IP="your_esp_ip_address"
Ensure to replace
your_esp_ip_address
with the IP address of the ESP32 board.Then, run the Python script.
python main.py
Remember to run this from the
server
folder, and activate the virtual environment if you created one.
The script will listen for speech commands once you press the Enter key. You can say the following commands:
- "Forward"
- "Backward"
- "Left"
- "Right"
- "Stop"
This project is meant to be used with the PlatformIO IDE. However, you can also use the Arduino IDE to upload the code to the ESP32 board. To do this, follow the steps below:
- Install the ESP32 Arduino Core from the board manager, and DDBot from the library manager.
- Create a new project in the Arduino IDE.
- Copy the contents of the
src/main.cpp
file to the new project. This is the main sketch file. - Create a new file named
secrets.h
in the root folder of the project (instead of creating in theinclude
folder), as described in step 3 of the Usage section. - Upload the code to the ESP32 board.