ESP-ADF-FAQ

ESP_William
Posts: 131
Joined: Tue Apr 24, 2018 5:54 am

ESP-ADF-FAQ

Postby ESP_William » Thu Oct 17, 2024 6:18 am

Before FAQ

We have organized and analyzed GitHub Issues as well as the problems encountered during development. Below is a summary of frequently asked A&Q for your reference. This module will be continuously updated. If you have any suggestions, feel free to start a discussion, and we will review them carefully!

FAQ

1. A: How to resolve the ADF compilation error “Failed to resolve component 'xxx'.”?
Q: After cloning ESP-ADF, you need to update the submodules. Run the following command in the $ADF_PATH (ESP-ADF root directory) to download the submodules:

Code: Select all

git submodule update --init --recursive

2. A: How to read or write data from an element?
Q: There are three methods for reading and writing in an element:
(1) Callback function for reading and writing:
  1. audio_element_set_write_cb(i2s_writer_el, i2s_write_cb, (void *)Input_file);
  2. audio_element_set_read_cb(i2s_reader_el, i2s_read_cb, (void *)Output_file);
  3.    
  4. static int i2s_write_cb(audio_element_handle_t self, char *buffer, int len, TickType_t ticks_to_wait, void *context) {
  5.     memcpy(buffer, YOUR CONTENT, LEN);
  6. }
  7.  
  8. static int i2s_read_cb(audio_element_handle_t self, char *buffer, int len, TickType_t ticks_to_wait, void *context) {
  9.     memcpy(YOUR NEED CONTENT, buffer, LEN);
  10. }
If using a pipeline, you can only add a write callback function to the first element and a read callback function to the last element.
(2) Reading and writing via ringbuf:
Refer to element_wav_amr_sdcard .
  1. ESP_LOGI(TAG, "[3.3] Create a ringbuffer and insert it between i2s_stream_reader and wav_encoder");
  2. ringbuf01 = rb_create(RING_BUFFER_SIZE, 1);
  3. audio_element_set_output_ringbuf(i2s_stream_reader, ringbuf01);
  4. audio_element_set_input_ringbuf(wav_encoder, ringbuf01);
  5.  
  6. ESP_LOGI(TAG, "[3.4] Create a ringbuffer and insert it between wav_encoder and wav_fatfs_stream_writer");
  7. ringbuf02 = rb_create(RING_BUFFER_SIZE, 1);
  8. audio_element_set_output_ringbuf(wav_encoder, ringbuf02);
  9. audio_element_set_input_ringbuf(wav_fatfs_stream_writer, ringbuf02);
(3) Direct read and write:
  1. static audio_element_handle_t create_i2s_stream(int sample_rates, int bits, int channels, audio_stream_type_t type) {
  2.     i2s_stream_cfg_t i2s_cfg = I2S_STREAM_CFG_DEFAULT_WITH_PARA(CODEC_ADC_I2S_PORT, sample_rates, bits, type);
  3.     audio_element_handle_t i2s_stream = i2s_stream_init(&i2s_cfg);
  4.     mem_assert(i2s_stream);
  5.     return i2s_stream;
  6. }
  7.  
  8. ESP_LOGI(TAG, "[ x ] Create and start input key service");
  9. audio_board_handle_t board_handle = audio_board_init();
  10. audio_hal_ctrl_codec(board_handle->audio_hal, AUDIO_HAL_CODEC_MODE_BOTH, AUDIO_HAL_CTRL_START);
  11.  
  12. ESP_LOGI(TAG, "[x] Create i2s stream to write data to codec chip");
  13. audio_element_handle_t i2s_stream_writer = create_i2s_stream(RATE, BITS, CHANNEL, AUDIO_STREAM_WRITER);
  14.  
  15. ESP_LOGI(TAG, "[x] Create i2s stream to read data from codec chip");
  16. audio_element_handle_t i2s_stream_reader = create_i2s_stream(RATE, BITS, CHANNEL, AUDIO_STREAM_READER);
  17.  
  18. int read_bytes = audio_element_input(i2s_stream_reader, (void *)block_buffer, size * sizeof(int16_t));
  19.  
  20. int write_bytes = audio_element_output(i2s_stream_writer, (void *)block_buffer, size * sizeof(int16_t));
3. A: How to adjust microphone gain?
Q:
  1. #define BOARD_PA_GAIN             (20)    //board_def.h
  2.  
  3. audio_hal_set_volume(board_audio_hal, 85);  //local volume control
If using Bluetooth, refer to the AVRC protocol:
AVRC example.

4. A: SR model cannot be found after renaming the wake word?
Q: Please pack the wake word in $ADF_PATH/components/esp-sr/model/pack_model.py. After that, add the corresponding option in Kconfig and make sure to select it in menuconfig before compiling.

5. A: How to run (master) ESP-ADF on ESP32-S3-LCD-EVB2 development board?
Q: Please refer to issues 1215.

6. A: Regarding the VOIP AEC effect, how can we improve the AEC quality?
Q: Ensure that the sound of the speaker has only one forward path to the microphone. The inner cavity of the speaker and the microphone should be in a completely isolated structure. At the same time, add a rubber ring to the microphone to prevent vibration. You can save the original audio, reference audio, and microphone audio for analysis.

7. A: When reading and writing sdcard files, an error "No such file or directory" is reported?
Q: Try setting

Code: Select all

menuconfig > Component config > FAT Filesystem support > Long filename support
which may solve the problem.

8. A: How to add key function in the case?
Q: Please refer to issues 1245.

9. A: There is no sound after hanging up when ESP32 LyraT 4.3 runs VoIP?
Q: Please check if the tone is downloaded to Flash. Refer to voip.

10. A: How to integrate and add the module functions of esp-adf\examples\ in ESP-BOX-S3 development board esp-box\examples?
Q: You can directly use the demo in ADF. We have already supported ESP32-S3-BOX. Select it in

Code: Select all

menuconfig>Audio HAL>Audio board >ESP32-S3-BOX
11. A: How to use audio prompt tone in the daily use of Xiaodu?
Q: Please refer to issues 1264.

12. A: How to solve problems encountered during ESP-ADF compilation?
Q: First try the command

Code: Select all

idf.py fullclean 
or rm -rf build
. If it still fails, delete the ~/.espressif/python_env folder and use the commands

Code: Select all

./install.sh
../export.sh
again in $IDF_PATH and $ADF_PATH.

14. A: When running the VoIP example, it prompts "i2c: CONFLICT! driver_ng is not allowed to be used with this old driver". How to solve it?
Q: Refer to issues 1274.

15. A: How to configure an external microphone on ESP32-Lyrat v4.3 board?
Q: Refer to issues 1282.

16. A: What are the similarities and differences between examples\player\pipeline_a2dp_source_stream and pipeline_bt_source?
Q: pipeline_a2dp_xxx initializes with a2dp_stream_init, which is more flexible in configuration. Both esp_bt_controller and esp_bluedroid in play_bt_music_example can be selectively used;
pipeline_bt_xxx initializes with bluetooth_service_create_stream, directly activating bt and the above selectively used functions.

17. A: How to use ESP-ADF on Arduino?
Q: Currently, we haven't provided this support.

18. A: When using the VoIP function of ESP-ADF, how to eliminate echo when making a call between a mobile phone and an ESP32 device?
Q:
  • Espressif provides an acoustic echo cancellation (AEC) algorithm based on ESP32 and ESP32-S3 chips. You can refer to the algorithm example.
  • It should be noted that the effect of AEC not only depends on software parameter configuration and debugging but also on hardware design. For example, playback cannot be distorted, recording cannot have noise, and the echo reference signal cannot have problems. For this part, it is recommended to refer to the design of Espressif's ESP32-Lyrat-Mini development board and ESP32-S3-Korvo-2 development board.
19. A: Is there a reference example for accessing Baidu voice or a large model?
Q:Please refer to dueros example.

20. A: Does the network phone example provided on Espressif's official website support RTP?
Q:
  • The network phone protocol currently provided by ESP-ADF by default is VoIP implemented based on SIP. The protocol part uses RTP.
21. A: I want to connect a sensor to the I2C of ESP32-LyraT. Is there an example of how to read I2C device data?
Q: Please refer to i2c example.

22. A: How to output 32-bit I2S audio data?
Q: Refer to the following code
  1. i2s_stream_cfg_t i2s_writer_cfg = I2S_STREAM_CFG_DEFAULT();
  2. i2s_writer_cfg.type = AUDIO_STREAM_WRITER;
  3. i2s_writer_cfg.stack_in_ext = true;
  4. i2s_writer_cfg.task_core = 1;
  5. i2s_writer_cfg.need_expand = true;
  6. i2s_writer_cfg.expand_src_bits = 16;
  7. i2s_writer = i2s_stream_init(&i2s_writer_cfg);
23. A: Where can I view the ESP-IDF version supported by the ESP-ADF version?
Q: Please refer to the ESP-IDF version supported by ESP-ADF.

24. A: Will adding DuerOS fully occupy the recording function of the ESP32-LyraT development board?
Q: The current design fully occupies the recording data. However, you can enable the multi_output function of I2S_stream to output the recorded data to the desired place through this channel.

25. A: Does Espressif's voice wake-up solution have certain requirements for environmental noise?
Q: The current Espressif's voice solution can meet the environmental requirements within a signal-to-noise ratio of 5 dB. For some fixed noise scenarios, it can even achieve within 0 dB (optimization for actual products is required).

26. A: When there is AUX input on the ESP32 AI development board, can the MIC no longer pick up sound?
Q:
  • The ESP-ADF development framework can select multiple ways to pick up sound, including MIC input and Line-in.
  • Sound pickup method selection is as follows:
  1. typedef enum {
  2.   AUDIO_HAL_CODEC_MODE_ENCODE = 1, /*! <select adc */      // MIC pickup
  3.   AUDIO_HAL_CODEC_MODE_DECODE, /*! <select dac*/
  4.   AUDIO_HAL_CODEC_MODE_BOTH, /*! <select both adc and dac */   //  MIC + speaker
  5.   AUDIO_HAL_CODEC_MODE_LINE_IN, /*! <set adc channel */,             // microphone pickup
  6. } Audio_hal_codec_mode_t;
  • Sound pickup method configuration is as follows:
  1. audio_board_handle_t board_handle = audio_board_init();
  2. audio_hal_ctrl_codec(board_handle->audio_hal, AUDIO_HAL_CODEC_MODE_DECODE, AUDIO_HAL_CTRL_START);     //If you want to pick up sound with MIC, modify this configuration option.
27. A: How does ESP32 connect to a microphone?
Q:
  • ESP32 supports DAC analog audio output and can be used to play simple audio such as prompt tones.
  • ESP32 supports PWM analog audio output, which has a slightly better effect than DAC. Demonstration code: esp-iot-solution.
  • ESP32 also supports I2S digital audio output. The configurable pins of I2S can be viewed in the peripheral interface and sensor chapter of 《ESP32 Technical Specification》.
28. A: What audio formats does the ESP32 chip support?
Q: The audio formats supported by ESP32 include MP3, AAC, FLAC, WAV, OGG, OPUS, AMR, G.711, etc. For reference, please see the instructions under ESP-ADF SDK.

29. A: Does ESP32 support online speech recognition?
Q: Yes. You can refer to the examples dueros example and speech_recognition example.

30. A: Can Wi-Fi and FFT be used simultaneously?
Q: Wi-Fi and FFT can be used simultaneously. For example, Wi-Fi function can be directly added to the rhythm light example with FFT function.

Who is online

Users browsing this forum: No registered users and 36 guests