Wi-Fi Speech Recognition Robot

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.

Usage

  1. [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.

  2. Install the required Python packages.

    python -m pip install -r requirements.txt
  3. Configure the Wi-Fi credentials in the secrets.h file.

    To set up the Wi-Fi credentials, create a file named secrets.h in the include folder. The file should contain the following code:

    #define SSID "your_wifi_ssid"
    #define PASSWORD "your_wifi_password"

    Ensure to replace your_wifi_ssid and your_wifi_password with your Wi-Fi credentials.

  4. 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.

  5. 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"

Using with Arduino IDE

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:

  1. Install the ESP32 Arduino Core from the board manager, and DDBot from the library manager.
  2. Create a new project in the Arduino IDE.
  3. Copy the contents of the src/main.cpp file to the new project. This is the main sketch file.
  4. Create a new file named secrets.h in the root folder of the project (instead of creating in the include folder), as described in step 3 of the Usage section.
  5. Upload the code to the ESP32 board.