.. _xiaozhi_ai: ============================================== 4.Xiaozhi AI Tutorial ============================================== The Xiaozhi AI solution used in this project is open source and is based on `xiaozhi-esp32 `_. If you only want to use the device, follow the flashing steps in this tutorial. If you want to customize features or continue development, see :ref:`open_source`. .. _xiaozhi_backend_setup: Backend Setup ============================================== First, Register a Xiaozhi Account ------------------------------------------ 1. Visit the AI Chatbot Management System: `Xiaozhi.me `_ 2. Click the "Console" button on the page to enter the console 3. Fill in the registration form: * Select your country and enter your mobile phone number (for receiving verification code) * graphic verification code 4. Then click "Send Code". The system will send a verification code to your phone. enter the verification code to complete registration 5. After registration, you can add a password in the account management in the upper right corner .. figure:: img/sign0.png :align: center .. figure:: img/sign1.png :align: center .. figure:: img/sign2.png :align: center Adding Devices to the Management Backend ------------------------------------------ 1. Create an Agent: * Click the "Create Agent" button * Fill in the agent name and then click Confirm * In the agent card, click Configure Role .. figure:: img/web1.png :align: center :alt: Create Agent Interface .. figure:: img/web2.png :align: center :alt: Configure Agent Parameters .. figure:: img/web3.png :align: center :alt: Add Device Interface 2. Configure Agent Parameters: * Assistant Name: Name your AI assistant * Voice Role: Select your preferred voice style * Language Preference: Set the conversation language * Role Introduction: Define the personality traits of the AI assistant * Language Model: Select the language model to use 3. Set the Role Prompt. It is recommended to use the following template, or you can create your own role prompt: :: I am a virtual assistant called {{assistant_name}}. I communicate exclusively in English with a natural, friendly voice. I provide helpful, accurate information and assist users with their queries while maintaining a conversational tone. I adapt my speaking style to match the user's needs and always aim to deliver clear, concise responses in fluent English. .. figure:: img/web4.png :align: center 4. Click the "Save" button to save the role configuration .. figure:: img/web5.png :align: center .. _firmware_upload: Firmware Upload =============== Online Flashing ------------------- You can also use an online flashing tool. The advantage of this method is that you simply open the webpage, select your device and firmware version, and it requires no configuration. Once flashing is complete, you can start using it right away. .. note:: Online flashing is supported only in Chrome or Edge browsers. .. warning:: Use a USB Type-C cable that supports data transfer. A charging-only cable may power the board but will not work for flashing. .. note:: On Windows, connect the USB Type-C data cable to the ESP32-S3 ``UART`` port on the left side of the board before clicking ``Connect``. On macOS, connect the cable to the ESP32-S3 ``USB`` port on the right side, then press and hold ``BOOT``, press ``RESET`` while still holding ``BOOT``, and enter download mode before clicking ``Connect``. The screen will turn black after the device enters download mode; this is normal. For detailed instructions on using the online flasher, see :ref:`Online Flasher `. Follow these steps: A. Open the `LAFVIN Web Flasher `_ B. Select the following options: - Device: ``ESP32S3 AI Chatbot Kit`` - Firmware: ``Xiaozhi-esp32`` - Version: ``2.2.4`` C. Connect the development board to your computer using the correct USB Type-C port for your operating system, as described in the note above, before clicking ``Connect``. D. Click ``Connect``, then select your device in the browser pop-up window and click ``Connect`` again. E. Click ``Flash`` to start flashing. Wait for the process to complete. F. After flashing is complete, restart the device by pressing the ``RST`` or ``RESET`` button on the ESP32-S3 board. You do not need to unplug the USB cable unless the device does not respond. .. raw:: html
Local Flashing (Alternative) 1. Double-click to open Flash Download Tools, then select the options as shown below: .. list-table:: :widths: 50 :header-rows: 0 * - .. figure:: img/flashtool1.png :width: 100% 2. Follow these steps to upload the firmware: A. Click the "Select File" button to choose your downloaded firmware file (.bin format) B. In the address input box after the bin file selection box, enter ``0 or 0x0`` (indicating that the firmware will be downloaded to the starting position of the development board's memory) C. Select the COM port corresponding to ESP32-S3 from the port selection dropdown menu (refer to the :ref:`install_driver` section for how to check the device manager for the specific port number) D. Set the baud rate (we use 460800 here) E. Click the "START" button to begin downloading the firmware to the ESP32-S3 development board .. figure:: img/flash_xiaozhi1.png :align: center :width: 80% .. figure:: img/flash_xiaozhi2.png :align: center :width: 80% .. raw:: html
.. _xiaozhi_conf: .. note:: The ESP32-S3 supports only 2.4 GHz Wi-Fi networks. Make sure the Wi-Fi network you select is not 5 GHz only. 3. After the firmware is flashed, press the ``RST`` or ``RESET`` button on the development board. The board will restart and enter network configuration mode. 4. Connect your phone to the hotspot named ``Xiaozhi-XXXX``. The configuration page should open automatically. If not, manually enter ``http://192.168.4.1`` in your browser to access the configuration interface. .. image:: img/wificonfig_xiaozhi.png 5. Select your Wi-Fi network, enter the password, and click ``Save``. The device will save the settings and restart automatically. 6. After restarting, the board will connect to your Wi-Fi and announce a 6-digit verification code. If it does not restart within about 30 seconds, press the ``RST`` or ``RESET`` button once. 7. Go to the backend interface and add the device in the Agent you just created: * Click the "Add Device" button * Enter the 6-digit verification code announced by the device .. figure:: img/web6.png :align: center .. image:: img/verify_xiaozhi.png After clicking "Confirm" and restarting the device, you'll see this interface. At that point, just say "Hi, ESP," and you can start the conversation. .. image:: img/main_xiaozhi.png For flashing help, driver troubleshooting, or alternative flashing methods, see :ref:`Online Flasher `.