├── .github └── workflows │ ├── issue_comment.yml │ ├── new_issues.yml │ └── new_prs.yml ├── .gitignore ├── .gitlab-ci.yml ├── LICENSE ├── README.md ├── README_cn.md ├── components ├── hardware_driver │ ├── CMakeLists.txt │ ├── Kconfig.projbuild │ ├── Kconfig.projbuild.new │ ├── boards │ │ ├── esp32-korvo │ │ │ └── bsp_board.c │ │ ├── esp32p4-function-ev-2mic │ │ │ └── bsp_board.c │ │ ├── esp32p4-function-ev │ │ │ └── bsp_board.c │ │ ├── esp32s3-box-3 │ │ │ └── bsp_board.c │ │ ├── esp32s3-box │ │ │ └── bsp_board.c │ │ ├── esp32s3-eye │ │ │ └── bsp_board.c │ │ ├── esp32s3-korvo-1 │ │ │ └── bsp_board.c │ │ ├── esp32s3-korvo-2 │ │ │ └── bsp_board.c │ │ └── include │ │ │ ├── bsp_board.h │ │ │ ├── esp32_korvo_v1_1_board.h │ │ │ ├── esp32_p4_function_ev_2mic_board.h │ │ │ ├── esp32_p4_function_ev_board.h │ │ │ ├── esp32_s3_box_3_board.h │ │ │ ├── esp32_s3_box_board.h │ │ │ ├── esp32_s3_eye_board.h │ │ │ ├── esp32_s3_korvo_1_v4_board.h │ │ │ └── esp32_s3_korvo_2_v3_board.h │ ├── esp_board_init.c │ ├── idf_component.yml │ ├── idf_component.yml.bak │ └── include │ │ └── esp_board_init.h ├── perf_tester │ ├── CMakeLists.txt │ ├── README.md │ ├── idf_component.yml │ ├── mn_perf_tester.c │ ├── mn_perf_tester.h │ ├── perf_tester_cmd.c │ ├── perf_tester_cmd.h │ ├── wn_perf_tester.c │ └── wn_perf_tester.h ├── player │ ├── CMakeLists.txt │ ├── esp_skainet_player.c │ ├── esp_skainet_player.h │ └── esp_tts_wav │ │ ├── wav_decoder.c │ │ ├── wav_decoder.h │ │ ├── wav_encoder.c │ │ └── wav_encoder.h └── sr_ringbuf │ ├── CMakeLists.txt │ ├── EspAudioAlloc.c │ ├── EspAudioAlloc.h │ ├── lock.c │ ├── lock.h │ ├── ringbuf.c │ └── ringbuf.h ├── conftest.py ├── docs ├── _static │ ├── ESP32-S3-Korvo-1_20210914_V05_SystemBlock.png │ ├── esp32-korvo-v1.1-annotated-photo-mainboard.png │ ├── esp32-korvo-v1.1-annotated-photo-mic-back.png │ ├── esp32-korvo-v1.1-annotated-photo-mic-front.png │ ├── esp32-korvo-v1.1-block-diagram.png │ ├── esp32-korvo-v1.1-front-view.png │ ├── esp32-s3-Korvo-1-isometric.png │ ├── esp32-s3-korvo-1-v4-audio-ps.png │ ├── esp32-s3-korvo-1-v4-battery-ps.png │ ├── esp32-s3-korvo-1-v4-marking.png │ ├── esp32-s3-korvo-1-v4-module-ps.png │ ├── esp32-s3-korvo-1-v4-pcb-j1.png │ ├── esp32-s3-korvo-1-v4-usb-ps.png │ ├── esp32-s3-korvo-1-v5-marking.png │ ├── esp32-s3-korvo-1-v5-pcb-j1.png │ ├── esp32-s3-korvo-annotated-photo.png │ ├── esp32-s3-korvo-mic-annotated-btm.png │ ├── esp32-s3-korvo-mic-annotated-top.png │ └── source-graphics │ │ ├── ESP32-S3-KORVO_Mic_callouts.odg │ │ ├── ESP32-S3-KORVO_V4_MB_20210719AE_callouts.odg │ │ └── ESP32-S3-Korvo-1_20210914_V05_SystemBlock.odg ├── en │ └── hw-reference │ │ ├── esp32 │ │ └── user-guide-esp32-korvo-v1.1.md │ │ └── esp32s3 │ │ └── user-guide-korvo-1.md └── zh_CN │ └── hw-reference │ ├── esp32 │ └── user-guide-esp32-korvo-v1.1.md │ └── esp32s3 │ └── user-guide-korvo-1.md ├── examples ├── .build-test-rules.yml ├── README.md ├── README_cn.md ├── chinese_tts │ ├── CMakeLists.txt │ ├── README.md │ ├── esp_tts_voice_data_xiaoxin.dat │ ├── flash_voicedata.sh │ ├── main │ │ ├── CMakeLists.txt │ │ ├── idf_component.yml │ │ ├── include │ │ │ └── tts_urat.h │ │ ├── main.c │ │ └── tts_urat.c │ ├── partitions.csv │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32 │ ├── sdkconfig.defaults.esp32p4 │ ├── sdkconfig.defaults.esp32s3 │ └── sdkconfig.defaults.esp32s3box ├── cn_speech_commands_recognition │ ├── CMakeLists.txt │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── idf_component.yml │ │ ├── include │ │ │ ├── ie_kaiji.h │ │ │ ├── m_0.h │ │ │ ├── m_1.h │ │ │ ├── m_10.h │ │ │ ├── m_11.h │ │ │ ├── m_12.h │ │ │ ├── m_13.h │ │ │ ├── m_14.h │ │ │ ├── m_15.h │ │ │ ├── m_16.h │ │ │ ├── m_17.h │ │ │ ├── m_2.h │ │ │ ├── m_3.h │ │ │ ├── m_4.h │ │ │ ├── m_5.h │ │ │ ├── m_6.h │ │ │ ├── m_7.h │ │ │ ├── m_8.h │ │ │ ├── m_9.h │ │ │ ├── speech_commands_action.h │ │ │ └── wake_up_prompt_tone.h │ │ ├── main.c │ │ └── speech_commands_action.c │ ├── partitions.csv │ ├── partitions_esp32.csv │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32 │ ├── sdkconfig.defaults.esp32p4 │ └── sdkconfig.defaults.esp32s3 ├── deep_noise_suppression │ ├── CMakeLists.txt │ ├── README.md │ ├── README_cn.md │ ├── data │ │ ├── FEED.PCM │ │ ├── FETCH.PCM │ │ ├── ent.wav │ │ └── raw.wav │ ├── main │ │ ├── CMakeLists.txt │ │ ├── idf_component.yml │ │ └── main.c │ ├── partitions.csv │ ├── partitions_esp32.csv │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32 │ ├── sdkconfig.defaults.esp32p4 │ └── sdkconfig.defaults.esp32s3 ├── direction_of_arrival │ ├── CMakeLists.txt │ ├── README.md │ ├── README_cn.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── idf_component.yml │ │ └── main.c │ ├── partitions.csv │ ├── partitions_esp32.csv │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32 │ ├── sdkconfig.defaults.esp32p4 │ └── sdkconfig.defaults.esp32s3 ├── en_speech_commands_recognition │ ├── CMakeLists.txt │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── idf_component.yml │ │ ├── include │ │ │ ├── me_16_degress.h │ │ │ ├── me_17_degrees.h │ │ │ ├── me_18_degrees.h │ │ │ ├── me_19_degrees.h │ │ │ ├── me_20_degrees.h │ │ │ ├── me_21_degrees.h │ │ │ ├── me_22_degrees.h │ │ │ ├── me_23_degrees.h │ │ │ ├── me_24_degrees.h │ │ │ ├── me_25_degrees.h │ │ │ ├── me_26_degrees.h │ │ │ ├── me_decrease_the_volume.h │ │ │ ├── me_green_color.h │ │ │ ├── me_highest_volume.h │ │ │ ├── me_increase_volume.h │ │ │ ├── me_lowest_volume.h │ │ │ ├── me_make_me_a_coffee.h │ │ │ ├── me_make_me_a_tea.h │ │ │ ├── me_play_news_channel.h │ │ │ ├── me_red_color.h │ │ │ ├── me_sing_a_song.h │ │ │ ├── me_tell_me_a_joke.h │ │ │ ├── me_turn_off_all_the_light.h │ │ │ ├── me_turn_off_my_soundbox.h │ │ │ ├── me_turn_off_the_TV.h │ │ │ ├── me_turn_off_the_air_conditioner.h │ │ │ ├── me_turn_off_the_light.h │ │ │ ├── me_turn_on_all_the_light.h │ │ │ ├── me_turn_on_my_soundbox.h │ │ │ ├── me_turn_on_the_TV.h │ │ │ ├── me_turn_on_the_air_conditioner.h │ │ │ ├── me_turn_on_the_light.h │ │ │ ├── speech_commands_action.h │ │ │ └── wake_up_prompt_tone.h │ │ ├── main.c │ │ └── speech_commands_action.c │ ├── partitions.csv │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32p4 │ └── sdkconfig.defaults.esp32s3 ├── sdkconfig.defaults ├── usb_mic_recorder │ ├── CMakeLists.txt │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── Kconfig.projbuild │ │ ├── Kconfig.projbuild.new │ │ ├── idf_component.yml │ │ ├── include │ │ │ ├── tusb_config.h │ │ │ ├── usb_descriptors.h │ │ │ └── usb_mic_recorder.h │ │ ├── main.c │ │ └── src │ │ │ ├── usb_descriptors.c │ │ │ └── usb_mic_recorder.c │ ├── partitions.csv │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32p4 │ └── sdkconfig.defaults.esp32s3 ├── voice_activity_detection │ ├── CMakeLists.txt │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── idf_component.yml │ │ └── main.c │ ├── partitions.csv │ ├── partitions_esp32.csv │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32 │ ├── sdkconfig.defaults.esp32p4 │ └── sdkconfig.defaults.esp32s3 ├── voice_communication │ ├── CMakeLists.txt │ ├── README.md │ ├── README_cn.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── idf_component.yml │ │ └── main.c │ ├── partitions.csv │ ├── partitions_esp32.csv │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32 │ ├── sdkconfig.defaults.esp32p4 │ └── sdkconfig.defaults.esp32s3 └── wake_word_detection │ ├── README.md │ ├── afe │ ├── CMakeLists.txt │ ├── README.md │ ├── README_cn.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── idf_component.yml │ │ └── main.c │ ├── partitions.csv │ ├── partitions_esp32.csv │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32 │ ├── sdkconfig.defaults.esp32p4 │ └── sdkconfig.defaults.esp32s3 │ └── wakenet │ ├── CMakeLists.txt │ ├── README.md │ ├── README_cn.md │ ├── main │ ├── CMakeLists.txt │ ├── hiesp.h │ ├── hilexin.h │ ├── idf_component.yml │ └── main.c │ ├── partitions.csv │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32 │ ├── sdkconfig.defaults.esp32p4 │ └── sdkconfig.defaults.esp32s3 ├── img ├── MicNode.png ├── audio_boards.png ├── esp_afe.png ├── skainet_overview.png ├── skainet_overview2.png ├── specch_commands_config1.png ├── specch_commands_config2.png └── speechs_commands_workflow.png ├── pytest.ini ├── test ├── .build-rules.yml ├── README.md ├── multinet │ ├── CMakeLists.txt │ ├── main │ │ ├── CMakeLists.txt │ │ ├── idf_component.yml │ │ └── multinet_main.c │ ├── partitions.csv │ ├── pytest_multinet6.py │ ├── pytest_multinet7.py │ ├── sdkconfig.ci.hiesp_mn6_en │ ├── sdkconfig.ci.hiesp_mn7_en │ ├── sdkconfig.ci.hilexin_mn6_cn │ ├── sdkconfig.ci.hilexin_mn6_cn_ac │ ├── sdkconfig.ci.p4 │ └── sdkconfig.defaults ├── record_test_set │ ├── README.md │ ├── config.yml │ ├── config_mn.yml │ ├── create_mn_test_json.py │ ├── create_mn_test_set.py │ ├── create_test_set.py │ ├── data │ │ ├── music_set │ │ │ └── music_16k.wav │ │ ├── noise_set │ │ │ ├── cooking │ │ │ │ └── cooking.wav │ │ │ ├── news │ │ │ │ └── NPRnews.wav │ │ │ ├── pink │ │ │ │ └── Pink.wav │ │ │ ├── pub │ │ │ │ └── Pub.wav │ │ │ ├── rock │ │ │ │ └── ETSIRock.wav │ │ │ ├── silence │ │ │ │ └── Silence_60s.wav │ │ │ └── washing │ │ │ │ └── washingmachine.wav │ │ ├── output_set │ │ │ ├── hilexin_0dB_pink_-10dB.wav │ │ │ ├── hilexin_0dB_silence_-10dB.wav │ │ │ └── playback_hilexin_0dB.wav │ │ ├── play_list.csv │ │ └── wake_words │ │ │ ├── hiesp │ │ │ ├── hiesp1.wav │ │ │ ├── hiesp10.wav │ │ │ ├── hiesp2.wav │ │ │ ├── hiesp3.wav │ │ │ ├── hiesp4.wav │ │ │ ├── hiesp5.wav │ │ │ ├── hiesp6.wav │ │ │ ├── hiesp7.wav │ │ │ ├── hiesp8.wav │ │ │ └── hiesp9.wav │ │ │ └── hilexin │ │ │ ├── hilexin1.wav │ │ │ ├── hilexin10.wav │ │ │ ├── hilexin2.wav │ │ │ ├── hilexin3.wav │ │ │ ├── hilexin4.wav │ │ │ ├── hilexin5.wav │ │ │ ├── hilexin6.wav │ │ │ ├── hilexin7.wav │ │ │ ├── hilexin8.wav │ │ │ └── hilexin9.wav │ ├── requirement.txt │ ├── sdcard_recorder │ │ ├── CMakeLists.txt │ │ ├── main │ │ │ ├── CMakeLists.txt │ │ │ ├── idf_component.yml │ │ │ ├── main.c │ │ │ ├── uart.c │ │ │ └── uart.h │ │ ├── partitions.csv │ │ └── sdkconfig.defaults │ └── split_audio.py ├── vad │ ├── CMakeLists.txt │ ├── main │ │ ├── CMakeLists.txt │ │ └── main.c │ ├── partitions.csv │ ├── python │ │ ├── libripaty.py │ │ └── test_vad.py │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32p4 │ └── sdkconfig.defaults.esp32s3 └── wakenet │ ├── CMakeLists.txt │ ├── README.md │ ├── main │ ├── CMakeLists.txt │ ├── idf_component.yml │ └── wakenet_main.c │ ├── partitions.csv │ ├── pytest_wakenet.py │ ├── sdkconfig.ci.hiesp │ ├── sdkconfig.ci.hilexin │ └── sdkconfig.defaults └── tools ├── ci ├── build_apps.py ├── push_to_github.sh └── requirements.txt ├── default_firmware ├── README.md ├── default_firmware_ESP32-S3-Korvo-1 └── esp32_korvo_v1_1_fw_v0_1_20200323.bin └── generate_audio_file ├── README.md ├── alexa.h ├── alexa.wav ├── generate_audio_file.py ├── hijeson.h ├── hijeson.wav ├── hilexin.h ├── hilexin.wav ├── xiaoaitongxue.h └── xiaoaitongxue.wav /.github/workflows/issue_comment.yml: -------------------------------------------------------------------------------- 1 | name: Sync issue comments to JIRA 2 | 3 | # This workflow will be triggered when new issue comment is created (including PR comments) 4 | on: issue_comment 5 | 6 | jobs: 7 | sync_issue_comments_to_jira: 8 | name: Sync Issue Comments to Jira 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@master 12 | - name: Sync issue comments to JIRA 13 | uses: espressif/github-actions/sync_issues_to_jira@master 14 | env: 15 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 16 | JIRA_PASS: ${{ secrets.JIRA_PASS }} 17 | JIRA_PROJECT: AIS 18 | JIRA_URL: ${{ secrets.JIRA_URL }} 19 | JIRA_USER: ${{ secrets.JIRA_USER }} 20 | -------------------------------------------------------------------------------- /.github/workflows/new_issues.yml: -------------------------------------------------------------------------------- 1 | name: Sync issues to Jira 2 | 3 | # This workflow will be triggered when a new issue is opened 4 | on: issues 5 | 6 | jobs: 7 | sync_issues_to_jira: 8 | name: Sync issues to Jira 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@master 12 | - name: Sync GitHub issues to Jira project 13 | uses: espressif/github-actions/sync_issues_to_jira@master 14 | env: 15 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 16 | JIRA_PASS: ${{ secrets.JIRA_PASS }} 17 | JIRA_PROJECT: AIS 18 | JIRA_URL: ${{ secrets.JIRA_URL }} 19 | JIRA_USER: ${{ secrets.JIRA_USER }} 20 | -------------------------------------------------------------------------------- /.github/workflows/new_prs.yml: -------------------------------------------------------------------------------- 1 | name: Sync remain PRs to Jira 2 | 3 | # This workflow will be triggered every hour, to sync remaining PRs (i.e. PRs with zero comment) to Jira project 4 | # Note that, PRs can also get synced when new PR comment is created 5 | on: 6 | schedule: 7 | - cron: "0 * * * *" 8 | 9 | jobs: 10 | sync_prs_to_jira: 11 | name: Sync PRs to Jira 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@master 15 | - name: Sync PRs to Jira project 16 | uses: espressif/github-actions/sync_issues_to_jira@master 17 | with: 18 | cron_job: true 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | JIRA_PASS: ${{ secrets.JIRA_PASS }} 22 | JIRA_PROJECT: AIS 23 | JIRA_URL: ${{ secrets.JIRA_URL }} 24 | JIRA_USER: ${{ secrets.JIRA_USER }} 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | sdkconfig 3 | sdkconfig.old 4 | target 5 | .vscode 6 | managed_components/ 7 | dependencies.lock 8 | test/*/5.0 9 | test/*/4.4 10 | __pycache__ 11 | pytest_log 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ESPRESSIF MIT License 2 | 3 | Copyright (c) 2019 4 | 5 | Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case, 6 | it is free of charge, to any person obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished 10 | to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all copies or 13 | substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /components/hardware_driver/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(CONFIG_ESP32_S3_KORVO_1_V4_0_BOARD) 2 | list(APPEND BSP_BOARD_SRC "./boards/esp32s3-korvo-1") 3 | endif() 4 | 5 | if(CONFIG_ESP32_S3_KORVO_2_V3_0_BOARD) 6 | list(APPEND BSP_BOARD_SRC "./boards/esp32s3-korvo-2") 7 | endif() 8 | 9 | if(CONFIG_ESP32_KORVO_V1_1_BOARD) 10 | list(APPEND BSP_BOARD_SRC "./boards/esp32-korvo") 11 | endif() 12 | 13 | if(CONFIG_ESP32_S3_BOX_BOARD) 14 | list(APPEND BSP_BOARD_SRC "./boards/esp32s3-box") 15 | endif() 16 | 17 | if(CONFIG_ESP32_S3_BOX_3_BOARD) 18 | list(APPEND BSP_BOARD_SRC "./boards/esp32s3-box-3") 19 | endif() 20 | 21 | if(CONFIG_ESP32_S3_EYE_BOARD) 22 | list(APPEND BSP_BOARD_SRC "./boards/esp32s3-eye") 23 | endif() 24 | 25 | if(CONFIG_ESP32_P4_FUNCTION_EV_BOARD) 26 | list(APPEND BSP_BOARD_SRC "./boards/esp32p4-function-ev") 27 | endif() 28 | 29 | 30 | idf_component_register( 31 | SRC_DIRS 32 | ./ 33 | ${BSP_BOARD_SRC} 34 | INCLUDE_DIRS 35 | "include" 36 | "boards/include" 37 | REQUIRES 38 | driver 39 | fatfs 40 | spiffs 41 | ) 42 | 43 | component_compile_options(-w) 44 | target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") 45 | -------------------------------------------------------------------------------- /components/hardware_driver/Kconfig.projbuild: -------------------------------------------------------------------------------- 1 | menu "Audio Media HAL" 2 | 3 | choice AUDIO_BOARD 4 | prompt "Audio hardware board" 5 | default ESP32_S3_KORVO_1_V4_0_BOARD 6 | help 7 | Select an audio board to use 8 | 9 | config ESP32_KORVO_V1_1_BOARD 10 | bool "ESP32-Korvo" 11 | depends on IDF_TARGET_ESP32 12 | config ESP32_S3_BOX_BOARD 13 | bool "ESP32-S3-Box" 14 | depends on IDF_TARGET_ESP32S3 15 | config ESP32_S3_BOX_3_BOARD 16 | bool "ESP32-S3-Box-3" 17 | depends on IDF_TARGET_ESP32S3 18 | config ESP32_S3_KORVO_1_V4_0_BOARD 19 | bool "ESP32-S3-Korvo-1" 20 | depends on IDF_TARGET_ESP32S3 21 | config ESP32_S3_KORVO_2_V3_0_BOARD 22 | bool "ESP32-S3-Korvo-2" 23 | depends on IDF_TARGET_ESP32S3 24 | config ESP32_S3_EYE_BOARD 25 | bool "ESP32-S3-EYE" 26 | depends on IDF_TARGET_ESP32S3 27 | config ESP32_P4_FUNCTION_EV_BOARD 28 | bool "ESP32-P4-Function_Ev" 29 | depends on IDF_TARGET_ESP32P4 30 | endchoice 31 | 32 | endmenu 33 | -------------------------------------------------------------------------------- /components/hardware_driver/Kconfig.projbuild.new: -------------------------------------------------------------------------------- 1 | menu "Audio Media HAL" 2 | 3 | choice AUDIO_BOARD 4 | prompt "Audio hardware board" 5 | default ESP32_S3_KORVO_1_V4_0_BOARD 6 | help 7 | Select an audio board to use 8 | 9 | config ESP32_KORVO_V1_1_BOARD 10 | bool "ESP32-Korvo" 11 | depends on IDF_TARGET_ESP32 12 | config ESP32_S3_BOX_BOARD 13 | bool "ESP32-S3-Box" 14 | depends on IDF_TARGET_ESP32S3 15 | config ESP32_S3_BOX_3_BOARD 16 | bool "ESP32-S3-Box-3" 17 | depends on IDF_TARGET_ESP32S3 18 | config ESP32_S3_KORVO_1_V4_0_BOARD 19 | bool "ESP32-S3-Korvo-1" 20 | depends on IDF_TARGET_ESP32S3 21 | config ESP32_S3_KORVO_2_V3_0_BOARD 22 | bool "ESP32-S3-Korvo-2" 23 | depends on IDF_TARGET_ESP32S3 24 | config ESP32_S3_EYE_BOARD 25 | bool "ESP32-S3-EYE" 26 | depends on IDF_TARGET_ESP32S3 27 | endchoice 28 | 29 | endmenu 30 | -------------------------------------------------------------------------------- /components/hardware_driver/boards/include/esp32_p4_function_ev_board.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | #pragma once 18 | 19 | #include "driver/gpio.h" 20 | #include "esp_idf_version.h" 21 | #include "esp_codec_dev.h" 22 | #include "esp_codec_dev_defaults.h" 23 | #include "esp_codec_dev_os.h" 24 | 25 | /** 26 | * @brief ESP32-P4-FUNCTION-EV I2C GPIO defineation 27 | * 28 | */ 29 | #define FUNC_I2C_EN (1) 30 | #define I2C_NUM (0) 31 | #define I2C_CLK (600000) 32 | #define GPIO_I2C_SCL (GPIO_NUM_8) 33 | #define GPIO_I2C_SDA (GPIO_NUM_7) 34 | 35 | /** 36 | * @brief On-chip LDO channel ID, e.g. set to `4` is the `LDO_VO4` is connected to power the SDMMC IO 37 | * 38 | */ 39 | #define LDO_CHANNEL_ID (4) 40 | #define LDO_CFG_VOL_MV (3300) 41 | 42 | /** 43 | * @brief ESP32-P4-FUNCTION-EV SDMMC GPIO defination 44 | * 45 | * @note Only avaliable when PMOD connected 46 | */ 47 | #define FUNC_SDMMC_EN (1) 48 | #define SDMMC_BUS_WIDTH (4) 49 | #define GPIO_SDMMC_CLK (GPIO_NUM_43) 50 | #define GPIO_SDMMC_CMD (GPIO_NUM_44) 51 | #define GPIO_SDMMC_D0 (GPIO_NUM_39) 52 | #define GPIO_SDMMC_D1 (GPIO_NUM_40) 53 | #define GPIO_SDMMC_D2 (GPIO_NUM_41) 54 | #define GPIO_SDMMC_D3 (GPIO_NUM_42) 55 | #define GPIO_SDMMC_DET (GPIO_NUM_NC) 56 | 57 | /** 58 | * @brief ESP32-P4-FUNCTION-EV SDSPI GPIO definationv 59 | * 60 | */ 61 | #define FUNC_SDSPI_EN (0) 62 | #define SDSPI_HOST (SPI2_HOST) 63 | #define GPIO_SDSPI_CS (GPIO_NUM_NC) 64 | #define GPIO_SDSPI_SCLK (GPIO_NUM_NC) 65 | #define GPIO_SDSPI_MISO (GPIO_NUM_NC) 66 | #define GPIO_SDSPI_MOSI (GPIO_NUM_NC) 67 | 68 | /** 69 | * @brief ESP32-P4-FUNCTION-EV I2S GPIO defination 70 | * 71 | */ 72 | #define FUNC_I2S_EN (1) 73 | #define GPIO_I2S_LRCK (GPIO_NUM_10) 74 | #define GPIO_I2S_MCLK (GPIO_NUM_13) 75 | #define GPIO_I2S_SCLK (GPIO_NUM_12) 76 | #define GPIO_I2S_SDIN (GPIO_NUM_11) 77 | #define GPIO_I2S_DOUT (GPIO_NUM_9) 78 | 79 | /** 80 | * @brief ESP32-P4-FUNCTION-EV I2S GPIO defination 81 | * 82 | */ 83 | #define FUNC_I2S0_EN (0) 84 | #define GPIO_I2S0_LRCK (GPIO_NUM_NC) 85 | #define GPIO_I2S0_MCLK (GPIO_NUM_NC) 86 | #define GPIO_I2S0_SCLK (GPIO_NUM_NC) 87 | #define GPIO_I2S0_SDIN (GPIO_NUM_NC) 88 | #define GPIO_I2S0_DOUT (GPIO_NUM_NC) 89 | 90 | #define RECORD_VOLUME (30.0) 91 | /** 92 | * @brief player configurations 93 | * 94 | */ 95 | #define PLAYER_VOLUME (50) 96 | 97 | /** 98 | * @brief ESP32-S3-HMI-DevKit power control IO 99 | * 100 | * @note Some power control pins might not be listed yet 101 | * 102 | */ 103 | #define FUNC_PWR_CTRL (1) 104 | #define GPIO_PWR_CTRL (GPIO_NUM_53) 105 | #define GPIO_PWR_ON_LEVEL (1) 106 | 107 | #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0) 108 | 109 | #define I2S_CONFIG_DEFAULT(sample_rate, channel_fmt, bits_per_chan) { \ 110 | .clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(16000), \ 111 | .slot_cfg = I2S_STD_PHILIPS_SLOT_DEFAULT_CONFIG(16, I2S_SLOT_MODE_STEREO), \ 112 | .gpio_cfg = { \ 113 | .mclk = GPIO_I2S_MCLK, \ 114 | .bclk = GPIO_I2S_SCLK, \ 115 | .ws = GPIO_I2S_LRCK, \ 116 | .dout = GPIO_I2S_DOUT, \ 117 | .din = GPIO_I2S_SDIN, \ 118 | }, \ 119 | } 120 | #endif 121 | -------------------------------------------------------------------------------- /components/hardware_driver/esp_board_init.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | #include 18 | #include 19 | #include 20 | #include "bsp_board.h" 21 | #include "esp_err.h" 22 | #include "esp_vfs_fat.h" 23 | #include "sdmmc_cmd.h" 24 | #include "esp_board_init.h" 25 | 26 | static const char *TAG = "hardware"; 27 | 28 | esp_err_t esp_board_init(uint32_t sample_rate, int channel_format, int bits_per_chan) 29 | { 30 | return bsp_board_init(sample_rate, channel_format, bits_per_chan); 31 | } 32 | 33 | esp_err_t esp_sdcard_init(char *mount_point, size_t max_files) 34 | { 35 | return bsp_sdcard_init(mount_point, max_files); 36 | } 37 | 38 | esp_err_t esp_sdcard_deinit(char *mount_point) 39 | { 40 | return bsp_sdcard_deinit(mount_point); 41 | } 42 | 43 | esp_err_t esp_get_feed_data(bool is_get_raw_channel, int16_t *buffer, int buffer_len) 44 | { 45 | return bsp_get_feed_data(is_get_raw_channel, buffer, buffer_len); 46 | } 47 | 48 | int esp_get_feed_channel(void) 49 | { 50 | return bsp_get_feed_channel(); 51 | } 52 | 53 | char* esp_get_input_format(void) 54 | { 55 | return bsp_get_input_format(); 56 | } 57 | 58 | esp_err_t esp_audio_play(const int16_t* data, int length, TickType_t ticks_to_wait) 59 | { 60 | return bsp_audio_play(data, length, ticks_to_wait); 61 | } 62 | 63 | esp_err_t esp_audio_set_play_vol(int volume) 64 | { 65 | return bsp_audio_set_play_vol(volume); 66 | } 67 | 68 | esp_err_t esp_audio_get_play_vol(int *volume) 69 | { 70 | return bsp_audio_get_play_vol(volume); 71 | } 72 | 73 | esp_err_t FatfsComboWrite(const void* buffer, int size, int count, FILE* stream) 74 | { 75 | esp_err_t res = ESP_OK; 76 | res = fwrite(buffer, size, count, stream); 77 | res |= fflush(stream); 78 | res |= fsync(fileno(stream)); 79 | 80 | return res; 81 | } -------------------------------------------------------------------------------- /components/hardware_driver/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | esp_codec_dev: ~1.1.0 4 | -------------------------------------------------------------------------------- /components/hardware_driver/idf_component.yml.bak: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | es7210: 4 | version: "^1.0.0" 5 | 6 | esp_codec_dev: 7 | version: ">=1.0.1" 8 | 9 | ## Required IDF version 10 | idf: 11 | version: ">=4.4.0" 12 | # # Put list of dependencies here 13 | # # For components maintained by Espressif: 14 | # component: "~1.0.0" 15 | # # For 3rd party components: 16 | # username/component: ">=1.0.0,<2.0.0" 17 | # username2/component2: 18 | # version: "~1.0.0" 19 | # # For transient dependencies `public` flag can be set. 20 | # # `public` flag doesn't have an effect dependencies of the `main` component. 21 | # # All dependencies of `main` are public by default. 22 | # public: true 23 | -------------------------------------------------------------------------------- /components/hardware_driver/include/esp_board_init.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | #include "esp_err.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * @brief Special config for dev board 29 | * 30 | * @param sample_rate 31 | * @param channel_format 32 | * @param bits_per_chan 33 | * @return 34 | * - ESP_OK: Success 35 | * - Others: Fail 36 | */ 37 | esp_err_t esp_board_init(uint32_t sample_rate, int channel_format, int bits_per_chan); 38 | 39 | /** 40 | * @brief Init SD crad 41 | * 42 | * @param mount_point Path where partition should be registered (e.g. "/sdcard") 43 | * @param max_files Maximum number of files which can be open at the same time 44 | * @return 45 | * - ESP_OK Success 46 | * - ESP_ERR_INVALID_STATE If esp_vfs_fat_register was already called 47 | * - ESP_ERR_NOT_SUPPORTED If dev board not has SDMMC/SDSPI 48 | * - ESP_ERR_NO_MEM If not enough memory or too many VFSes already registered 49 | * - Others Fail 50 | */ 51 | esp_err_t esp_sdcard_init(char *mount_point, size_t max_files); 52 | 53 | /** 54 | * @brief Deinit SD card 55 | * 56 | * @param mount_point Path where partition was registered (e.g. "/sdcard") 57 | * @return 58 | * - ESP_OK: Success 59 | * - Others: Fail 60 | */ 61 | esp_err_t esp_sdcard_deinit(char *mount_point); 62 | 63 | 64 | esp_err_t get_i2s_data(char *buffer, int buffer_len); 65 | 66 | esp_err_t esp_audio_play(const int16_t* data, int length, TickType_t ticks_to_wait); 67 | 68 | /** 69 | * @brief Get the record pcm data. 70 | * 71 | * @param is_get_raw_channel Whether to get the recording data of the original number of channels. 72 | * Otherwise, the corresponding number of channels will be filtered based on the board. 73 | * @param buffer The buffer where the data is stored. 74 | * @param buffer_len The buffer length. 75 | * @return 76 | * - ESP_OK Success 77 | * - Others Fail 78 | */ 79 | esp_err_t esp_get_feed_data(bool is_get_raw_channel, int16_t *buffer, int buffer_len); 80 | 81 | int esp_get_feed_channel(void); 82 | 83 | char* esp_get_input_format(void); 84 | 85 | /** 86 | * @brief Set play volume 87 | * 88 | * @return 89 | * - ESP_OK: Success 90 | * - Others: Fail 91 | */ 92 | esp_err_t esp_audio_set_play_vol(int volume); 93 | 94 | /** 95 | * @brief Get play volume 96 | * 97 | * @return 98 | * - ESP_OK: Success 99 | * - Others: Fail 100 | */ 101 | esp_err_t esp_audio_get_play_vol(int *volume); 102 | 103 | 104 | esp_err_t FatfsComboWrite(const void* buffer, int size, int count, FILE* stream); 105 | 106 | #ifdef __cplusplus 107 | } 108 | #endif 109 | -------------------------------------------------------------------------------- /components/perf_tester/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if((${IDF_TARGET} STREQUAL "esp32s3") OR (${IDF_TARGET} STREQUAL "esp32p4") OR (${IDF_TARGET} STREQUAL "esp32")) 2 | set(srcs 3 | wn_perf_tester.c 4 | mn_perf_tester.c 5 | perf_tester_cmd.c 6 | ) 7 | 8 | set(requires 9 | hardware_driver 10 | player 11 | console 12 | esp-sr 13 | ) 14 | 15 | idf_component_register( 16 | SRCS ${srcs} 17 | INCLUDE_DIRS "." 18 | REQUIRES ${requires}) 19 | 20 | endif() -------------------------------------------------------------------------------- /components/perf_tester/README.md: -------------------------------------------------------------------------------- 1 | Perf tester is used to test esp-skainet performance. Currently, it support wakenet and multinet test. 2 | Perf tester use [console](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/console.html) component to develop an interactive console over serial port. The commands list are as follows: 3 | ``` 4 | help 5 | Print the list of registered commands 6 | 7 | config 8 | Perf Tester Config 9 | Tester mode, fast: fast check all test cases, norm: run complete test cases. 10 | noise type, All: test all noise data, none: do not add any noise 11 | snr, all: test all snr data, none: do not add any noise, 0/5/10: snr number 12 | 13 | start 14 | Start to test 15 | ``` 16 | You can configure and run tests by the following steps: 17 | 18 | ``` 19 | #select pink noise and SNR=5dB, fast test mode 20 | perf_test>config fast pink 5 21 | perf_test>start 22 | 23 | 24 | #select all noise and SNR=5dB, fast test mode 25 | perf_test>config fast all 5 26 | perf_test>start 27 | 28 | #select pub noise and all SNR, fast test mode 29 | perf_test>config fast pub all 30 | perf_test>start 31 | 32 | ``` 33 | 34 | You can refer to [this example](https://github.com/espressif/esp-idf/tree/master/examples/system/console) to register new commands. -------------------------------------------------------------------------------- /components/perf_tester/idf_component.yml: -------------------------------------------------------------------------------- 1 | # ## IDF Component Manager Manifest File 2 | # dependencies: 3 | # esp-sr: 4 | # version: ">=1.1.0,<2.0.0" 5 | # public: true 6 | -------------------------------------------------------------------------------- /components/perf_tester/mn_perf_tester.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "freertos/FreeRTOS.h" 3 | #include "freertos/task.h" 4 | #include "freertos/queue.h" 5 | #include "esp_afe_sr_iface.h" 6 | #include "esp_afe_sr_models.h" 7 | #include "esp_wn_iface.h" 8 | #include "esp_wn_models.h" 9 | #include "esp_mn_iface.h" 10 | #include "esp_mn_models.h" 11 | #include "perf_tester_cmd.h" 12 | 13 | 14 | typedef enum { 15 | TESTER_PCM_3CH = 0, // input 3 channel PCM [mic1, mic2, ref, ...] 16 | TESTER_WAV_3CH = 1, // input 3 channel WAV [mic1, mic2, ref, ...] 17 | TESTER_PCM_1CH = 2, // input 1 channel PCM 18 | TESTER_WAV_1CH = 3, // input 1 channel WAV 19 | } tester_audio_t; 20 | 21 | 22 | /** 23 | * @brief Test multinet, wakenet and AFE pipeline performance,include CPU loading, memory size and trigger times 24 | * 25 | * @param csv_file CSV file path 26 | * @param log_file File name to save test report 27 | * @param afe_handle Handle of speech front end 28 | * @param afe_config Config of afe handle 29 | * @param multinet Handle of multinet 30 | * @param mn_coeff Model name of multinet 31 | * @param audio_type Input audio type, 0: 3channel-PCM; 1: 3channel-WAV 32 | * @param tester_config Perf tester config 33 | */ 34 | void offline_mn_tester(const char *csv_file, 35 | const char *log_file, 36 | const esp_afe_sr_iface_t *afe_handle, 37 | afe_config_t *afe_config, 38 | esp_mn_iface_t *multinet, 39 | char *mn_coeff, 40 | int audio_type, 41 | perf_tester_config_t *config); 42 | 43 | /** 44 | * @brief Test multinet, wakenet and AFE pipeline performance,include CPU loading, memory size and trigger times 45 | * 46 | * @param csv_file CSV file path 47 | * @param log_file File name to save test report 48 | * @param afe_handle Handle of speech front end 49 | * @param afe_config Config of afe handle 50 | * @param audio_type Input audio type, 0: 3channel-PCM; 1: 3channel-WAV 51 | * @param tester_config Perf tester config 52 | */ 53 | void offline_vad_tester(const char *csv_file, 54 | const char *log_file, 55 | const esp_afe_sr_iface_t *afe_handle, 56 | afe_config_t *afe_config, 57 | int audio_type, 58 | perf_tester_config_t *config); -------------------------------------------------------------------------------- /components/perf_tester/perf_tester_cmd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "stdbool.h" 3 | #include "esp_console.h" 4 | #include "argtable3/argtable3.h" 5 | 6 | typedef struct 7 | { 8 | char mode[32]; // mode 9 | char noise[32]; // noise 10 | char snr[32]; // SNR 11 | int flag; // update flag 12 | } perf_tester_config_t; 13 | 14 | 15 | /** 16 | * @brief Register config command to configure perf tester 17 | * config 18 | * Perf Tester Config 19 | * Tester mode, Fast: fast check all test cases, Norm: run complete test cases. 20 | * noise type, All: test all noise data, None: do not add any noise 21 | * snr, All: test all snr data, None: do not add any noise, 0/5/10: snr number 22 | * 23 | */ 24 | void register_perf_tester_config_cmd(void); 25 | 26 | /** 27 | * @brief Register start command to trigger perf tester 28 | * 29 | * @param start_func callback function to trigger perf tester 30 | * typedef int (*esp_console_cmd_func_t)(int argc, char **argv); 31 | */ 32 | void register_perf_tester_start_cmd(esp_console_cmd_func_t start_func); 33 | 34 | 35 | /** 36 | * @brief Get perf tester config 37 | * 38 | * @return perf tester config 39 | */ 40 | perf_tester_config_t* get_perf_tester_config(void); 41 | 42 | /** 43 | * Check noise type of filename 44 | * 45 | * @param filename filename 46 | * @param noise noise type 47 | * 48 | * @return true if match, false if not match 49 | */ 50 | bool check_noise(const char *filename, const char *noise); 51 | 52 | 53 | /** 54 | * Check SNR of filename 55 | * 56 | * @param filename filename 57 | * @param snr SNR number or 'all', 'none' 58 | * 59 | * @return true if match, false if not match 60 | */ 61 | bool check_snr(const char *filename, const char *snr); -------------------------------------------------------------------------------- /components/perf_tester/wn_perf_tester.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "freertos/FreeRTOS.h" 3 | #include "freertos/task.h" 4 | #include "freertos/queue.h" 5 | #include "esp_afe_sr_iface.h" 6 | #include "esp_afe_sr_models.h" 7 | #include "esp_wn_iface.h" 8 | #include "esp_wn_models.h" 9 | #include "perf_tester_cmd.h" 10 | 11 | typedef enum { 12 | TESTER_PCM_3CH = 0, // input 3 channel PCM [mic1, mic2, ref, ...] 13 | TESTER_WAV_3CH = 1, // input 3 channel WAV [mic1, mic2, ref, ...] 14 | TESTER_PCM_1CH = 2, // input 1 channel PCM 15 | TESTER_WAV_1CH = 3, // input 1 channel WAV 16 | } tester_audio_t; 17 | 18 | // typedef void* skainet_perf_tester; 19 | 20 | /** 21 | * @brief Test wakenet and AFE pipeline performance,include CPU loading, memory size and trigger times 22 | * 23 | * @param csv_file CSV file path 24 | * @param log_file File name to save test report 25 | * @param afe_handle Handle of speech front end 26 | * @param afe_config Config of afe handle 27 | * @param audio_type Input audio type, 0: 3channel-PCM; 1: 3channel-WAV 28 | * @param tester_config Perf tester config 29 | */ 30 | void* offline_wn_tester_start(const char *csv_file, 31 | const char *log_file, 32 | const esp_afe_sr_iface_t *afe_handle, 33 | afe_config_t *afe_config, 34 | int audio_type, 35 | perf_tester_config_t *config); 36 | 37 | /** 38 | * @brief Stop test 39 | * 40 | * @param tester tester handle 41 | */ 42 | void offline_wn_tester_stop(void * tester); -------------------------------------------------------------------------------- /components/player/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(srcs 2 | esp_skainet_player.c 3 | ./esp_tts_wav/wav_encoder.c 4 | ./esp_tts_wav/wav_decoder.c 5 | ) 6 | 7 | idf_component_register( 8 | SRCS ${srcs} 9 | INCLUDE_DIRS 10 | "." 11 | "./esp_tts_wav" 12 | REQUIRES 13 | hardware_driver) 14 | 15 | -------------------------------------------------------------------------------- /components/player/esp_skainet_player.h: -------------------------------------------------------------------------------- 1 | #ifndef _ESP_SKAINET_PLAYER_ 2 | #define _ESP_SKAINET_PLAYER_ 3 | 4 | 5 | typedef void* player_handle; 6 | #define FATFS_PATH_LENGTH_MAX 256 7 | 8 | void *esp_skainet_player_create(int ringbuf_size, unsigned int core_num); 9 | void esp_skainet_player_play(void *handle, const char *path); 10 | void esp_skainet_player_pause(void *handle); 11 | void esp_skainet_player_continue(void *handle); 12 | void esp_skainet_player_exit(void *handle); 13 | int esp_skainet_player_get_state(void *handle); 14 | void esp_skainet_player_increase_vol(void *handle); 15 | void esp_skainet_player_decrease_vol(void *handle); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /components/player/esp_tts_wav/wav_decoder.h: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------------------------------ 2 | * Copyright (C) 2009 Martin Storsjo 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 | * express or implied. 14 | * See the License for the specific language governing permissions 15 | * and limitations under the License. 16 | * ------------------------------------------------------------------- 17 | */ 18 | 19 | #ifndef WAV_DECODER_H 20 | #define WAV_DECODER_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | void* wav_decoder_open(const char *filename); 27 | void wav_decoder_close(void* obj); 28 | int wav_decoder_get_header(void* obj, int* format, int* channels, int* sample_rate, int* bits_per_sample, unsigned int* data_length); 29 | int wav_decoder_run(void* obj, unsigned char* data, unsigned int length); 30 | int wav_decoder_get_sample_rate(void* obj); 31 | int wav_decoder_get_channel(void* obj); 32 | int wav_decoder_get_data_length(void* obj); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /components/player/esp_tts_wav/wav_encoder.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------------------------------ 2 | * Copyright (C) 2009 Martin Storsjo 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 | * express or implied. 14 | * See the License for the specific language governing permissions 15 | * and limitations under the License. 16 | * ------------------------------------------------------------------- 17 | */ 18 | 19 | #include "wav_encoder.h" 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | struct wav_encoder { 26 | FILE *wav; 27 | int data_length; 28 | 29 | int sample_rate; 30 | int bits_per_sample; 31 | int channels; 32 | }; 33 | 34 | static void write_string(struct wav_encoder* ww, const char *str) { 35 | fputc(str[0], ww->wav); 36 | fputc(str[1], ww->wav); 37 | fputc(str[2], ww->wav); 38 | fputc(str[3], ww->wav); 39 | } 40 | 41 | static void write_int32(struct wav_encoder* ww, int value) { 42 | fputc((value >> 0) & 0xff, ww->wav); 43 | fputc((value >> 8) & 0xff, ww->wav); 44 | fputc((value >> 16) & 0xff, ww->wav); 45 | fputc((value >> 24) & 0xff, ww->wav); 46 | } 47 | 48 | static void write_int16(struct wav_encoder* ww, int value) { 49 | fputc((value >> 0) & 0xff, ww->wav); 50 | fputc((value >> 8) & 0xff, ww->wav); 51 | } 52 | 53 | static void write_header(struct wav_encoder* ww, int length) { 54 | int bytes_per_frame, bytes_per_sec; 55 | write_string(ww, "RIFF"); 56 | write_int32(ww, 4 + 8 + 16 + 8 + length); 57 | write_string(ww, "WAVE"); 58 | 59 | write_string(ww, "fmt "); 60 | write_int32(ww, 16); 61 | 62 | bytes_per_frame = ww->bits_per_sample/8*ww->channels; 63 | bytes_per_sec = bytes_per_frame*ww->sample_rate; 64 | write_int16(ww, 1); // Format 65 | write_int16(ww, ww->channels); // Channels 66 | write_int32(ww, ww->sample_rate); // Samplerate 67 | write_int32(ww, bytes_per_sec); // Bytes per sec 68 | write_int16(ww, bytes_per_frame); // Bytes per frame 69 | write_int16(ww, ww->bits_per_sample); // Bits per sample 70 | 71 | write_string(ww, "data"); 72 | write_int32(ww, length); 73 | } 74 | 75 | void* wav_encoder_open(const char *filename, int sample_rate, int bits_per_sample, int channels) { 76 | struct wav_encoder* ww = (struct wav_encoder*) malloc(sizeof(*ww)); 77 | memset(ww, 0, sizeof(*ww)); 78 | ww->wav = fopen(filename, "wb"); 79 | if (ww->wav == NULL) { 80 | free(ww); 81 | return NULL; 82 | } 83 | ww->data_length = 0; 84 | ww->sample_rate = sample_rate; 85 | ww->bits_per_sample = bits_per_sample; 86 | ww->channels = channels; 87 | 88 | write_header(ww, ww->data_length); 89 | return ww; 90 | } 91 | 92 | void wav_encoder_close(void* obj) { 93 | struct wav_encoder* ww = (struct wav_encoder*) obj; 94 | if (ww->wav == NULL) { 95 | free(ww); 96 | return; 97 | } 98 | fseek(ww->wav, 0, SEEK_SET); 99 | write_header(ww, ww->data_length); 100 | fclose(ww->wav); 101 | free(ww); 102 | } 103 | 104 | void wav_encoder_run(void* obj, const unsigned char* data, int length) { 105 | struct wav_encoder* ww = (struct wav_encoder*) obj; 106 | if (ww->wav == NULL) 107 | return; 108 | fwrite(data, length, 1, ww->wav); 109 | ww->data_length += length; 110 | } 111 | 112 | -------------------------------------------------------------------------------- /components/player/esp_tts_wav/wav_encoder.h: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------------------------------ 2 | * Copyright (C) 2009 Martin Storsjo 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 | * express or implied. 14 | * See the License for the specific language governing permissions 15 | * and limitations under the License. 16 | * ------------------------------------------------------------------- 17 | */ 18 | 19 | #ifndef WAV_ENCODER_H 20 | #define WAV_ENCODER_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | void* wav_encoder_open(const char *filename, int sample_rate, int bits_per_sample, int channels); 27 | void wav_encoder_close(void* obj); 28 | void wav_encoder_run(void* obj, const unsigned char* data, int length); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /components/sr_ringbuf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(srcs 2 | ringbuf.c 3 | EspAudioAlloc.c 4 | lock.c 5 | ringbuf.c 6 | ) 7 | 8 | set(include_dirs 9 | ./ 10 | ) 11 | 12 | idf_component_register(SRCS ${srcs} 13 | INCLUDE_DIRS ${include_dirs}) 14 | 15 | component_compile_options(-w) 16 | target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") -------------------------------------------------------------------------------- /components/sr_ringbuf/EspAudioAlloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2018 5 | * 6 | * Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case, 7 | * it is free of charge, to any person obtaining a copy of this software and associated 8 | * documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 11 | * to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or 14 | * substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | */ 24 | 25 | #include 26 | #include "string.h" 27 | #include "esp_system.h" 28 | #include "esp_heap_caps.h" 29 | 30 | #include "esp_log.h" 31 | 32 | void *EspAudioAlloc(int n, int size) 33 | { 34 | void *data = NULL; 35 | 36 | 37 | data = heap_caps_malloc(n * size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); 38 | if (data) { 39 | memset(data, 0, n * size); 40 | } 41 | 42 | return data; 43 | } -------------------------------------------------------------------------------- /components/sr_ringbuf/EspAudioAlloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2018 5 | * 6 | * Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case, 7 | * it is free of charge, to any person obtaining a copy of this software and associated 8 | * documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 11 | * to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or 14 | * substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | */ 24 | 25 | #ifndef _ESP_AUDIO_ALLOC_H_ 26 | #define _ESP_AUDIO_ALLOC_H_ 27 | 28 | //#include "esp_log.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | void *EspAudioAlloc(int n, int size); 35 | void *EspAudioAllocInner(int n, int size); 36 | void EspAudioPrintMemory(const char *Tag); 37 | void EspAudioMemoryShow(const char *Tag, const char *Info, int Line); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif //_ESP_AUDIO_ALLOC_H_ 44 | -------------------------------------------------------------------------------- /components/sr_ringbuf/lock.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Espressif Systems (Shanghai) PTE LTD 2 | // All rights reserved. 3 | 4 | #include "freertos/FreeRTOS.h" 5 | #include "freertos/task.h" 6 | #include "freertos/queue.h" 7 | // #include "freertos/semphr.h" 8 | 9 | // #include "lwip/sockets.h" 10 | // #include "lwip/err.h" 11 | // #include "lwip/sys.h" 12 | 13 | #include "esp_log.h" 14 | #include "lock.h" 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #define LOCK_TAG "MUTEX_LOCK" 23 | 24 | 25 | /* @brief: create a new mutex 26 | * @param: 27 | * @return: 0 -- successed; 1 -- failed; 28 | */ 29 | // xSemaphoreHandle mutex_init(void) 30 | // { 31 | // xSemaphoreHandle xReturn = xSemaphoreCreateMutex(); 32 | 33 | // configASSERT(xReturn); 34 | // return xReturn; 35 | // } 36 | /* @brief: create a new Binary 37 | * @param: 38 | * @return: 0 -- successed; 1 -- failed; 39 | */ 40 | // xSemaphoreHandle semaphore_init(void) 41 | // { 42 | // xSemaphoreHandle xReturn = NULL; 43 | // vSemaphoreCreateBinary(xReturn); 44 | 45 | // configASSERT(xReturn); 46 | // return xReturn; 47 | // } 48 | 49 | // /* @brief: lock a mutex 50 | // * @param: mutex -- the mutex to lock 51 | // * @return: none 52 | // */ 53 | // void mutex_lock(xSemaphoreHandle pxMutex) 54 | // { 55 | // // ESP_LOGI(LOCK_TAG, "Taking lock [[[%p]]] %s\r\n", pxMutex, __func__); 56 | // while (xSemaphoreTake(pxMutex, portMAX_DELAY) != pdPASS); 57 | // // ESP_LOGI(LOCK_TAG, "[[[%p]]] taken %s\r\n", pxMutex, __func__); 58 | // } 59 | 60 | // /* @brief: unlock a mutex 61 | // * @param: mutex -- the mutex to unlock 62 | // * @return: none 63 | // */ 64 | // void mutex_unlock(xSemaphoreHandle pxMutex) 65 | // { 66 | // xSemaphoreGive(pxMutex); 67 | // // ESP_LOGI(LOCK_TAG, "Release lock [[[%p]]] %s\r\n", pxMutex, __func__); 68 | // } 69 | 70 | // /* @brief: delete a semaphore 71 | // * @param: mutex -- the mutex to delete 72 | // * @return: none 73 | // */ 74 | // void mutex_destroy(xSemaphoreHandle pxMutex) 75 | // { 76 | // vQueueDelete(pxMutex); 77 | // } 78 | -------------------------------------------------------------------------------- /components/sr_ringbuf/lock.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Espressif Systems (Shanghai) PTE LTD 2 | // All rights reserved. 3 | 4 | #ifndef _LOCK_H_ 5 | #define _LOCK_H_ 6 | 7 | typedef void * xSemaphoreHandle; 8 | 9 | xSemaphoreHandle mutex_init(void); 10 | 11 | xSemaphoreHandle semaphore_init(void); 12 | 13 | void mutex_lock(xSemaphoreHandle pxMutex); 14 | 15 | void mutex_unlock(xSemaphoreHandle pxMutex); 16 | 17 | void mutex_destroy(xSemaphoreHandle pxMutex); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /docs/_static/ESP32-S3-Korvo-1_20210914_V05_SystemBlock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/ESP32-S3-Korvo-1_20210914_V05_SystemBlock.png -------------------------------------------------------------------------------- /docs/_static/esp32-korvo-v1.1-annotated-photo-mainboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-korvo-v1.1-annotated-photo-mainboard.png -------------------------------------------------------------------------------- /docs/_static/esp32-korvo-v1.1-annotated-photo-mic-back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-korvo-v1.1-annotated-photo-mic-back.png -------------------------------------------------------------------------------- /docs/_static/esp32-korvo-v1.1-annotated-photo-mic-front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-korvo-v1.1-annotated-photo-mic-front.png -------------------------------------------------------------------------------- /docs/_static/esp32-korvo-v1.1-block-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-korvo-v1.1-block-diagram.png -------------------------------------------------------------------------------- /docs/_static/esp32-korvo-v1.1-front-view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-korvo-v1.1-front-view.png -------------------------------------------------------------------------------- /docs/_static/esp32-s3-Korvo-1-isometric.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-s3-Korvo-1-isometric.png -------------------------------------------------------------------------------- /docs/_static/esp32-s3-korvo-1-v4-audio-ps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-s3-korvo-1-v4-audio-ps.png -------------------------------------------------------------------------------- /docs/_static/esp32-s3-korvo-1-v4-battery-ps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-s3-korvo-1-v4-battery-ps.png -------------------------------------------------------------------------------- /docs/_static/esp32-s3-korvo-1-v4-marking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-s3-korvo-1-v4-marking.png -------------------------------------------------------------------------------- /docs/_static/esp32-s3-korvo-1-v4-module-ps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-s3-korvo-1-v4-module-ps.png -------------------------------------------------------------------------------- /docs/_static/esp32-s3-korvo-1-v4-pcb-j1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-s3-korvo-1-v4-pcb-j1.png -------------------------------------------------------------------------------- /docs/_static/esp32-s3-korvo-1-v4-usb-ps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-s3-korvo-1-v4-usb-ps.png -------------------------------------------------------------------------------- /docs/_static/esp32-s3-korvo-1-v5-marking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-s3-korvo-1-v5-marking.png -------------------------------------------------------------------------------- /docs/_static/esp32-s3-korvo-1-v5-pcb-j1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-s3-korvo-1-v5-pcb-j1.png -------------------------------------------------------------------------------- /docs/_static/esp32-s3-korvo-annotated-photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-s3-korvo-annotated-photo.png -------------------------------------------------------------------------------- /docs/_static/esp32-s3-korvo-mic-annotated-btm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-s3-korvo-mic-annotated-btm.png -------------------------------------------------------------------------------- /docs/_static/esp32-s3-korvo-mic-annotated-top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/esp32-s3-korvo-mic-annotated-top.png -------------------------------------------------------------------------------- /docs/_static/source-graphics/ESP32-S3-KORVO_Mic_callouts.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/source-graphics/ESP32-S3-KORVO_Mic_callouts.odg -------------------------------------------------------------------------------- /docs/_static/source-graphics/ESP32-S3-KORVO_V4_MB_20210719AE_callouts.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/source-graphics/ESP32-S3-KORVO_V4_MB_20210719AE_callouts.odg -------------------------------------------------------------------------------- /docs/_static/source-graphics/ESP32-S3-Korvo-1_20210914_V05_SystemBlock.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/docs/_static/source-graphics/ESP32-S3-Korvo-1_20210914_V05_SystemBlock.odg -------------------------------------------------------------------------------- /examples/.build-test-rules.yml: -------------------------------------------------------------------------------- 1 | # Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps 2 | 3 | examples/chinese_tts: 4 | enable: 5 | - if: IDF_TARGET in ["esp32", "esp32s3", "esp32p4"] 6 | temporary: false 7 | reason: the other targets are not tested yet 8 | 9 | examples/cn_speech_commands_recognition: 10 | enable: 11 | - if: IDF_TARGET in ["esp32", "esp32s3", "esp32p4"] 12 | temporary: false 13 | reason: the other targets are not tested yet 14 | 15 | examples/en_speech_commands_recognition: 16 | enable: 17 | - if: IDF_TARGET in ["esp32s3", "esp32p4"] 18 | temporary: false 19 | reason: the other targets are not tested yet 20 | 21 | examples/usb_mic_recorder: 22 | enable: 23 | - if: IDF_TARGET == "esp32s3" 24 | temporary: false 25 | reason: the other targets are not tested yet 26 | 27 | examples/voice_communication: 28 | enable: 29 | - if: IDF_TARGET in ["esp32s3", "esp32p4"] 30 | temporary: false 31 | reason: the other targets are not tested yet 32 | 33 | examples/voice_activity_detection: 34 | enable: 35 | - if: IDF_TARGET in ["esp32", "esp32s3", "esp32p4"] 36 | temporary: false 37 | reason: the other targets are not tested yet 38 | 39 | examples/wake_word_detection/afe: 40 | enable: 41 | - if: IDF_TARGET in ["esp32", "esp32s3", "esp32p4"] 42 | temporary: false 43 | reason: the other targets are not tested yet 44 | 45 | examples/wake_word_detection/wakenet: 46 | enable: 47 | - if: IDF_TARGET in ["esp32", "esp32s3", "esp32p4", "esp32c3", "esp32c6", "esp32s2"] 48 | temporary: false 49 | reason: the other targets are not tested yet 50 | 51 | examples/direction_of_arrival: 52 | enable: 53 | - if: IDF_TARGET in ["esp32", "esp32s3", "esp32p4"] 54 | temporary: false 55 | reason: the other targets are not tested yet 56 | 57 | 58 | examples/deep_noise_suppression: 59 | enable: 60 | - if: IDF_TARGET in ["esp32s3", "esp32p4"] 61 | temporary: false 62 | reason: the other targets are not tested yet -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Examples [[中文]](./README_cn.md) 2 | 3 | 4 | 5 | This directory contains a range of examples in ESP-Skainet projects. These examples exist to demonstrate the functionality of ESP-Skainet and to provide the source codes that can be copied and adapted to during the development of your projects. 6 | The ESP32-S3 chip and boards are recommended. New algotithms and models will be deployed on the ESP32-S3 chip first. 7 | 8 | 9 | # Example Layout 10 | 11 | 12 | 13 | The following examples are currently available: 14 | 15 | | Example Name | Latest Models | Supported Board | 16 | | :------------------------------------------------------------------ | :---------------: | :-------------- | 17 | | [cn_speech_commands_recognition](./cn_speech_commands_recognition) | Multinet6 | [ESP32-Korvo](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32/user-guide-esp32-korvo-v1.1.md), [ESP32-S3-Korvo-1](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32s3/user-guide-korvo-1.md), [ESP-BOX](https://github.com/espressif/esp-box), [ESP-S3-Korvo-2](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/user-guide-esp32-s3-korvo-2.html), [ESP32-S3-EYE](https://www.espressif.com/en/products/devkits/esp-s3-eye/overview)| 18 | | [en_speech_commands_recognition](./en_speech_commands_recognition) | Multinet6 | [ESP32-S3-Korvo-1](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32s3/user-guide-korvo-1.md), [ESP-BOX](https://github.com/espressif/esp-box), [ESP-S3-Korvo-2](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/user-guide-esp32-s3-korvo-2.html), [ESP32-S3-EYE](https://www.espressif.com/en/products/devkits/esp-s3-eye/overview)| 19 | | [wake_word_detection](./wake_word_detection) | Wakenet9 | [ESP32-Korvo](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32/user-guide-esp32-korvo-v1.1.md), [ESP32-S3-Korvo-1](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32s3/user-guide-korvo-1.md), [ESP-BOX](https://github.com/espressif/esp-box), [ESP-S3-Korvo-2](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/user-guide-esp32-s3-korvo-2.html), [ESP32-S3-EYE](https://www.espressif.com/en/products/devkits/esp-s3-eye/overview)| 20 | | [chinese_tts](./chinese_tts) | esp-tts-v1.7 | [ESP32-Korvo](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32/user-guide-esp32-korvo-v1.1.md), [ESP32-S3-Korvo-1](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32s3/user-guide-korvo-1.md), [ESP-BOX](https://github.com/espressif/esp-box), [ESP-S3-Korvo-2](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/user-guide-esp32-s3-korvo-2.html)| 21 | | [usb_mic_recorder](./usb_mic_recorder) | | [ESP-BOX](https://github.com/espressif/esp-box), [ESP-S3-Korvo-2](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/user-guide-esp32-s3-korvo-2.html)| 22 | 23 | 24 | # Contributing Examples 25 | If you have any examples you want to share with us or you think may interest us, please check the [Contributions Guide](https://esp-idf.readthedocs.io/en/latest/contribute/index.html) and get in touch with us. -------------------------------------------------------------------------------- /examples/README_cn.md: -------------------------------------------------------------------------------- 1 | # 示例 [[English]](./README.md) 2 | 3 | 这个文件夹包含了 ESP-Skainet 中的所有示例。这些示例的是为了演示 ESP-Skainet 中模型和算法的使用方法,并提供在项目开发过程中可以复用的源代码。 4 | 推荐使用ESP32-S3芯片以及相关开发版.新的算法和模型将优先部署在ESP32-S3上. 5 | 6 | 7 | # 示例设计 8 | 9 | 10 | The following examples are currently available: 11 | 12 | | Example Name | Latest Models | Supported Board | 13 | | :------------------------------------------------------------------ | :---------------: | :-------------- | 14 | | [cn_speech_commands_recognition](./cn_speech_commands_recognition) | Multinet6 | [ESP32-Korvo](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32/user-guide-esp32-korvo-v1.1.md), [ESP32-S3-Korvo-1](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32s3/user-guide-korvo-1.md), [ESP-BOX](https://github.com/espressif/esp-box), [ESP-S3-Korvo-2](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/user-guide-esp32-s3-korvo-2.html), [ESP32-S3-EYE](https://www.espressif.com/en/products/devkits/esp-s3-eye/overview)| 15 | | [en_speech_commands_recognition](./en_speech_commands_recognition) | Multinet6 | [ESP32-S3-Korvo-1](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32s3/user-guide-korvo-1.md), [ESP-BOX](https://github.com/espressif/esp-box), [ESP-S3-Korvo-2](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/user-guide-esp32-s3-korvo-2.html), [ESP32-S3-EYE](https://www.espressif.com/en/products/devkits/esp-s3-eye/overview)| 16 | | [wake_word_detection](./wake_word_detection) | Wakenet9 | [ESP32-Korvo](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32/user-guide-esp32-korvo-v1.1.md), [ESP32-S3-Korvo-1](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32s3/user-guide-korvo-1.md), [ESP-BOX](https://github.com/espressif/esp-box), [ESP-S3-Korvo-2](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/user-guide-esp32-s3-korvo-2.html), [ESP32-S3-EYE](https://www.espressif.com/en/products/devkits/esp-s3-eye/overview)| 17 | | [chinese_tts](./chinese_tts) | esp-tts-v1.7 | [ESP32-Korvo](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32/user-guide-esp32-korvo-v1.1.md), [ESP32-S3-Korvo-1](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32s3/user-guide-korvo-1.md), [ESP-BOX](https://github.com/espressif/esp-box), [ESP-S3-Korvo-2](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/user-guide-esp32-s3-korvo-2.html)| 18 | | [usb_mic_recorder](./usb_mic_recorder) | | [ESP-BOX](https://github.com/espressif/esp-box), [ESP-S3-Korvo-2](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/user-guide-esp32-s3-korvo-2.html)| 19 | 20 | # 贡献示例 21 | 22 | 如果您有任何要与我们分享的示例,或者您认为我们可能感兴趣,请参考 [Contributions Guide](https://esp-idf.readthedocs.io/en/latest/contribute/index.html) 并且联系我们。 23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/chinese_tts/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(EXTRA_COMPONENT_DIRS ../../components) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(chinese_tts) 7 | -------------------------------------------------------------------------------- /examples/chinese_tts/README.md: -------------------------------------------------------------------------------- 1 | # 中文语言合成示例 2 | 3 | 本示例主要用于展示乐鑫中文语音合成库的使用方法。示例可通过URAT串口输入中文文本,回车后播放合成的语音数据。 4 | 参考`components/esp-tts` 目录下的 [README.md](https://github.com/espressif/esp-sr/blob/release/v1.0/esp-tts/README.md) 来获取更多有关乐鑫中文语言合成库的信息。 5 | 6 | 7 | ### 额外硬件需求 8 | 9 | - 一只外接喇叭(4~6 欧姆) 10 | 11 | 12 | ### 编译和烧写 13 | - 参考partition.csv中的第二行添加voice data 14 | ``` 15 | # Name, Type, SubType, Offset, Size 16 | factory, app, factory, 0x010000, 4M 17 | voice_data, data, fat, , 3M 18 | ``` 19 | 20 | - 编译和烧写程序 21 | ``` 22 | # flash app bin and voice_data 23 | idf.py flash monitor 24 | 25 | # only flash app bin 26 | idf.py app-flash monitor 27 | 28 | ``` 29 | 30 | ### 修改voice data 31 | //@todo this section should be updated 32 | 所有可用voice data放置在 `esp-skainet/components/esp-sr/esp-tts/esp_tts_chinese/` 33 | - 方法1. 修改CmakeLists.txt 34 | 修改CmakeLists.txt中 `voice_data_image` 的路径 35 | ``` 36 | set(voice_data_image ${PROJECT_DIR}/../../components/esp-sr/esp-tts/esp_tts_chinese/esp_tts_voice_data_xiaoxin_small.dat) 37 | ``` 38 | 39 | - 方法2. 单独烧写 voice data 40 | 使用该例子提供的 `flash_voicedata.sh` 脚本烧写相应的音频数据 41 | ``` 42 | source flash_voicedata.sh ../../components/esp-sr/esp-tts/esp_tts_chinese/esp_tts_voice_data_xiaoxin_small.dat /dev/ttyUSB0 43 | ``` 44 | 45 | ### 例程输出 46 | 47 | 上电后,开发板会播放提示音:“欢迎使用乐鑫语音合成” 48 | 并输出以下打印: 49 | 50 | ``` 51 | 欢迎使用乐鑫语音合成 52 | I (266) tts_parser: unicode:0x6b22 -> huan1 53 | I (266) tts_parser: unicode:0x8fce -> ying2 54 | I (276) tts_parser: unicode:0x4f7f -> shi3 55 | I (276) tts_parser: unicode:0x7528 -> yong4 56 | I (286) tts_parser: unicode:0x4e50 -> le4 57 | I (286) tts_parser: unicode:0x946b -> xin1 58 | I (296) tts_parser: unicode:0x8bed -> yu3 59 | I (296) tts_parser: unicode:0x97f3 -> yin1 60 | I (306) tts_parser: unicode:0x5408 -> he2 61 | I (306) tts_parser: unicode:0x6210 -> cheng2 62 | 63 | 请输入短语: 64 | ``` 65 | 66 | ### URAT输入 67 | 通过串口工具输入文本,回车播放。 **注意**:部分串口工具不支持中文输入。 68 | 如果使用minicom,运行`minicom -s`进入设置页面, 进行以下设置: 69 | 70 | - Serial port setup -> Serial Device -> /dev/ttyUSB0 (设置串口号) 71 | - Serial port setup -> Hardware Flow Control -> No 72 | - Screen and keyboard -> Local echo -> No 73 | 74 | minicom显示有一些bug,但可以正确输入中文字符, 比如输入: “大家好”,回车出现以下打印: 75 | ``` 76 | uart input: ��大��家��好 77 | tts input:��大��家��好 78 | I (5266) tts_parser: unicode:0x5927 -> da4 79 | I (5266) tts_parser: unicode:0x5bb6 -> jia1 80 | I (5276) tts_parser: unicode:0x597d -> hao3 81 | 82 | ��请��输��入��短��语 83 | ``` 84 | 85 | 如果大家有更好的串口工具,欢迎留言。 86 | -------------------------------------------------------------------------------- /examples/chinese_tts/esp_tts_voice_data_xiaoxin.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/examples/chinese_tts/esp_tts_voice_data_xiaoxin.dat -------------------------------------------------------------------------------- /examples/chinese_tts/flash_voicedata.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | port="/dev/ttyUSB1" 3 | baud=$((2000000)) 4 | file="$1" 5 | 6 | if [ -z "$1" ]; then 7 | echo "Flashes a wave file to the partition for the speech recognition thing to parse it." 8 | echo "Usage: $0 file.wav [/dev/ttyUSB0 [115200]]" 9 | exit 0 10 | fi 11 | 12 | if [ -n "$2" ]; then 13 | port="$2" 14 | fi 15 | if [ -n "$3" ]; then 16 | baud="$3" 17 | fi 18 | 19 | python ${IDF_PATH}/components/esptool_py/esptool/esptool.py \ 20 | --port $port --baud $baud --before default_reset --after hard_reset write_flash \ 21 | --flash_mode dio --flash_freq 40m --flash_size detect 0x410000 "$file" 22 | 23 | -------------------------------------------------------------------------------- /examples/chinese_tts/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(srcs 2 | main.c 3 | tts_urat.c 4 | ) 5 | 6 | set(include_dirs 7 | include 8 | ) 9 | 10 | set(requires 11 | hardware_driver 12 | sr_ringbuf 13 | player 14 | ) 15 | 16 | idf_component_register(SRCS ${srcs} 17 | INCLUDE_DIRS ${include_dirs} 18 | REQUIRES ${requires}) 19 | 20 | add_definitions(-w) 21 | 22 | # Determine whether esp-sr is fetched from component registry or from local path 23 | idf_build_get_property(build_components BUILD_COMPONENTS) 24 | if(esp-sr IN_LIST build_components) 25 | set(esp-sr_name esp-sr) # Local component 26 | else() 27 | set(esp-sr_name espressif__esp-sr) # Managed component 28 | endif() 29 | 30 | # Get path to voice data file 31 | idf_component_get_property(esp-sr_path ${esp-sr_name} COMPONENT_DIR) 32 | set(voice_data_image ${esp-sr_path}/esp-tts/esp_tts_chinese/esp_tts_voice_data_xiaoxin_small.dat) 33 | add_custom_target(voice_data ALL DEPENDS ${voice_data_image}) 34 | add_dependencies(flash voice_data) 35 | 36 | partition_table_get_partition_info(size "--partition-name voice_data" "size") 37 | partition_table_get_partition_info(offset "--partition-name voice_data" "offset") 38 | 39 | if("${size}" AND "${offset}") 40 | esptool_py_flash_to_partition(flash "voice_data" "${voice_data_image}") 41 | else() 42 | set(message "Failed to find model in partition table file" 43 | "Please add a line(Name=voice_data, Type=data, Size=3890K) to the partition file.") 44 | endif() -------------------------------------------------------------------------------- /examples/chinese_tts/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-sr: "^2.0.0-rc.2" 3 | -------------------------------------------------------------------------------- /examples/chinese_tts/main/include/tts_urat.h: -------------------------------------------------------------------------------- 1 | #ifndef _TTS_URAT_H_ 2 | #define _TTS_URAT_H_ 3 | 4 | #define URAT_BUF_LEN 1024 5 | void uartTask(void *arg); 6 | 7 | #endif -------------------------------------------------------------------------------- /examples/chinese_tts/main/tts_urat.c: -------------------------------------------------------------------------------- 1 | #include "tts_urat.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "ringbuf.h" 12 | #include "esp_log.h" 13 | #include "driver/uart.h" 14 | #include "soc/uart_periph.h" 15 | #include "esp_idf_version.h" 16 | 17 | #define TAG "TTS_URAT" 18 | extern ringbuf_handle_t urat_rb; 19 | 20 | void uartTask(void *arg) 21 | { 22 | uart_config_t uart_config = { 23 | .baud_rate = 115200, 24 | .data_bits = UART_DATA_8_BITS, 25 | .parity = UART_PARITY_DISABLE, 26 | .stop_bits = UART_STOP_BITS_1, 27 | .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, 28 | #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) 29 | .source_clk = UART_SCLK_DEFAULT, 30 | #endif 31 | }; 32 | uart_param_config(UART_NUM_0, &uart_config); 33 | uart_driver_install(UART_NUM_0, 2*URAT_BUF_LEN, 0, 0, NULL, 0); 34 | char data[URAT_BUF_LEN]; 35 | int len=0; 36 | 37 | while (1) { 38 | int fd; 39 | 40 | if ((fd = open("/dev/uart/0", O_RDWR)) == -1) { 41 | ESP_LOGE(TAG, "Cannot open UART"); 42 | vTaskDelay(5000 / portTICK_PERIOD_MS); 43 | continue; 44 | } 45 | 46 | // We have a driver now installed so set up the read/write functions to use driver also. 47 | esp_vfs_dev_uart_use_driver(0); 48 | 49 | while (1) { 50 | int s; 51 | fd_set rfds; 52 | struct timeval tv = { 53 | .tv_sec = 5, 54 | .tv_usec = 0, 55 | }; 56 | 57 | FD_ZERO(&rfds); 58 | FD_SET(fd, &rfds); 59 | 60 | s = select(fd + 1, &rfds, NULL, NULL, &tv); 61 | 62 | if (s < 0) { 63 | ESP_LOGE(TAG, "Select failed: errno %d", errno); 64 | break; 65 | } else if (s == 0) { 66 | continue; 67 | } else { 68 | if (FD_ISSET(fd, &rfds)) { 69 | char buf; 70 | if (read(fd, &buf, 1) > 0) { 71 | ESP_LOGI("", "%c", buf); 72 | rb_write(urat_rb, &buf, 1, portMAX_DELAY); 73 | 74 | if (buf=='\n') { 75 | data[len]='\0'; 76 | printf("uart input: %s\n", data); 77 | len=0; 78 | } else { 79 | data[len]=buf; 80 | len++; 81 | } 82 | // Note: Only one character was read even the buffer contains more. The other characters will 83 | // be read one-by-one by subsequent calls to select() which will then return immediately 84 | // without timeout. 85 | } else { 86 | ESP_LOGE(TAG, "UART read error"); 87 | break; 88 | } 89 | } else { 90 | ESP_LOGE(TAG, "No FD has been set in select()"); 91 | break; 92 | } 93 | } 94 | } 95 | 96 | close(fd); 97 | } 98 | 99 | vTaskDelete(NULL); 100 | } -------------------------------------------------------------------------------- /examples/chinese_tts/partitions.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size 2 | factory, app, factory, 0x010000, 4M 3 | voice_data, data, fat, 0x410000, 3890K 4 | -------------------------------------------------------------------------------- /examples/chinese_tts/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_CUSTOM=y 2 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 3 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 4 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 5 | -------------------------------------------------------------------------------- /examples/chinese_tts/sdkconfig.defaults.esp32: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_TARGET="esp32" 2 | CONFIG_IDF_TARGET_ESP32=y 3 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 4 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 5 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 6 | CONFIG_PARTITION_TABLE_CUSTOM=y 7 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 8 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 9 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 10 | CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y 11 | CONFIG_ESP32_SPIRAM_SUPPORT=y 12 | CONFIG_SPIRAM_SPEED_80M=y 13 | CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y 14 | -------------------------------------------------------------------------------- /examples/chinese_tts/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32p4" 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_PARTITION_TABLE_CUSTOM=y 8 | CONFIG_COMPILER_OPTIMIZATION_PERF=y 9 | CONFIG_ESP32P4_REV_MIN_0=y 10 | CONFIG_SPIRAM=y 11 | CONFIG_SPIRAM_SPEED_200M=y 12 | CONFIG_CACHE_L2_CACHE_256KB=y 13 | CONFIG_CACHE_L2_CACHE_LINE_128B=y 14 | CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=n 15 | CONFIG_ESP_INT_WDT=n 16 | CONFIG_ESP_TASK_WDT_EN=n 17 | CONFIG_FREERTOS_HZ=1000 18 | CONFIG_MBEDTLS_CMAC_C=y 19 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y 20 | -------------------------------------------------------------------------------- /examples/chinese_tts/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_TARGET="esp32s3" 2 | CONFIG_IDF_TARGET_ESP32S3=y 3 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 4 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 5 | CONFIG_PARTITION_TABLE_CUSTOM=y 6 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 7 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 8 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 9 | CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y 10 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 11 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 12 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 13 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 14 | CONFIG_SPIRAM_MODE_OCT=y 15 | CONFIG_SPIRAM_SPEED_80M=y 16 | # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set 17 | CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y 18 | # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set 19 | # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set 20 | # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set 21 | CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y 22 | CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y -------------------------------------------------------------------------------- /examples/chinese_tts/sdkconfig.defaults.esp32s3box: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_TARGET="esp32s3" 2 | CONFIG_IDF_TARGET_ESP32S3=y 3 | CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF=y 4 | CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y 5 | CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS=y 6 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 7 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 8 | CONFIG_PARTITION_TABLE_CUSTOM=y 9 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 10 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 11 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 12 | CONFIG_ESP32_S3_BOX_BOARD=y 13 | # CONFIG_MODEL_IN_SDCARD is not set 14 | # CONFIG_USE_WAKENET is not set 15 | # CONFIG_USE_MULTINET is not set 16 | CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y 17 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 18 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 19 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 20 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 21 | CONFIG_SPIRAM_MODE_OCT=y 22 | CONFIG_SPIRAM_SPEED_80M=y 23 | # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set 24 | CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y 25 | # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set 26 | # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set 27 | # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set 28 | CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y 29 | CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y 30 | CONFIG_LV_FONT_FMT_TXT_LARGE=y 31 | CONFIG_LV_USE_QRCODE=y 32 | CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y 33 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 34 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 35 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 36 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 37 | CONFIG_SPIRAM_MODE_OCT=y 38 | CONFIG_SPIRAM_SPEED_80M=y 39 | CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096 40 | CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y 41 | CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=16384 42 | CONFIG_HTTPD_MAX_REQ_HDR_LEN=2048 43 | CONFIG_HTTPD_MAX_URI_LEN=2048 44 | CONFIG_HTTPD_WS_SUPPORT=y 45 | # CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP is not set 46 | CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096 47 | CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y -------------------------------------------------------------------------------- /examples/cn_speech_commands_recognition/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(EXTRA_COMPONENT_DIRS 4 | ../../components 5 | ) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(speech_commands_recognition) 9 | -------------------------------------------------------------------------------- /examples/cn_speech_commands_recognition/README.md: -------------------------------------------------------------------------------- 1 | # 中文语音命令识别 2 | 3 | (参考在上一级的 `examples` 目录下的 [README.md](../README.md) 文件来获取更多信息。) 4 | 5 | ## 如何使用例程 6 | 7 | ### Hardware Required 8 | ### 额外硬件需求 9 | 10 | - 一只外接喇叭(4~6 欧姆) 11 | 12 | ### 配置工程 13 | 14 | * 根据使用的开发板模组选择对应的 `sdkconfig` 15 | 16 | * 进入 `idf.py menuconfig` 17 | 18 | * 通过 `Serial Flasher Options`设置串口信息 19 | 20 | ### 编译和烧写 21 | 22 | 编译并烧写,然后运行终端监控查看打印: 23 | 24 | ``` 25 | idf.py flash monitor 26 | ``` 27 | 28 | (退出窗口,请键入 ``Ctrl-]``.) 29 | 30 | 参考 [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/stable/get-started-cmake/index.html) 来获取更多使用 ESP-IDF 编译项目的细节. 31 | 32 | ### 修改命令词 33 | 34 | 我们推荐使用MultiNet6或更新的模型。 35 | 以下是一个简单的例子展示如何在代码中修改命令词,你也可以通过修改默认的命令词列表文件修改命令,具体请参考:[命令词识别文档](https://docs.espressif.com/projects/esp-sr/zh_CN/latest/esp32s3/speech_command_recognition/README.html). 36 | 37 | ``` 38 | // MultiNet6 39 | // Note: Please create multinet handle before adding speech commands 40 | 41 | esp_mn_commands_clear(); // 清除当前的命令词列表 42 | esp_mn_commands_add(1, "turn on the light"); // 增加一个命令 43 | esp_mn_commands_add(2, "turn off the light"); // 增加一个命令 44 | esp_mn_commands_update(); // 更新命令词列表 45 | multinet->print_active_speech_commands(model_data); // 打印当前正在使用的所有命令词条 46 | ``` 47 | -------------------------------------------------------------------------------- /examples/cn_speech_commands_recognition/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(srcs 2 | main.c 3 | ) 4 | 5 | set(requires 6 | hardware_driver 7 | ) 8 | 9 | idf_component_register(SRCS ${srcs} 10 | INCLUDE_DIRS include 11 | REQUIRES ${requires}) 12 | 13 | component_compile_options(-w) 14 | -------------------------------------------------------------------------------- /examples/cn_speech_commands_recognition/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-sr: "^2.0.0" 3 | espressif/led_strip: "^2.5.0" 4 | -------------------------------------------------------------------------------- /examples/cn_speech_commands_recognition/main/include/speech_commands_action.h: -------------------------------------------------------------------------------- 1 | /* 2 | This example code is in the Public Domain (or CC0 licensed, at your option.) 3 | 4 | Unless required by applicable law or agreed to in writing, this 5 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 6 | CONDITIONS OF ANY KIND, either express or implied. 7 | */ 8 | #ifndef _SPEECH_COMMANDS_ACTION_H_ 9 | #define _SPEECH_COMMANDS_ACTION_H_ 10 | 11 | void led_Task(void *arg); 12 | 13 | void speech_commands_action(int command_id); 14 | 15 | void wake_up_action(void); 16 | #endif 17 | -------------------------------------------------------------------------------- /examples/cn_speech_commands_recognition/partitions.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 2048k 4 | model, data, spiffs, , 5168K, -------------------------------------------------------------------------------- /examples/cn_speech_commands_recognition/partitions_esp32.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 6000k 4 | model, data, spiffs, , 2000K, 5 | -------------------------------------------------------------------------------- /examples/cn_speech_commands_recognition/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_CUSTOM=y 2 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 3 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 4 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 5 | -------------------------------------------------------------------------------- /examples/cn_speech_commands_recognition/sdkconfig.defaults.esp32: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 5 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_PARTITION_TABLE_CUSTOM=y 8 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_esp32.csv" 9 | CONFIG_SR_MN_CN_MULTINET2_SINGLE_RECOGNITION=y 10 | CONFIG_CN_SPEECH_COMMAND_ID8="jie neng mo shi" 11 | CONFIG_CN_SPEECH_COMMAND_ID9="guan bi jie neng mo shi" 12 | CONFIG_CN_SPEECH_COMMAND_ID11="guan bi chu shi mo shi" 13 | CONFIG_CN_SPEECH_COMMAND_ID13="guan bi shui mian mo shi" 14 | CONFIG_CN_SPEECH_COMMAND_ID14="ding shi yi xiao shi" 15 | CONFIG_CN_SPEECH_COMMAND_ID15="ding shi liang xiao shi" 16 | CONFIG_CN_SPEECH_COMMAND_ID16="zui da feng su,zui gao feng su" 17 | CONFIG_CN_SPEECH_COMMAND_ID17="" 18 | CONFIG_CN_SPEECH_COMMAND_ID18="" 19 | CONFIG_CN_SPEECH_COMMAND_ID19="" 20 | CONFIG_SPIRAM=y 21 | CONFIG_SPIRAM_SPEED_80M=y 22 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 23 | -------------------------------------------------------------------------------- /examples/cn_speech_commands_recognition/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32p4" 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_PARTITION_TABLE_CUSTOM=y 8 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 9 | CONFIG_SR_WN_WN9_HILEXIN=y 10 | CONFIG_SR_MN_CN_MULTINET7_QUANT=y 11 | CONFIG_SPIRAM=y 12 | CONFIG_SPIRAM_SPEED_200M=y 13 | CONFIG_CACHE_L2_CACHE_256KB=y 14 | CONFIG_CACHE_L2_CACHE_LINE_128B=y 15 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y -------------------------------------------------------------------------------- /examples/cn_speech_commands_recognition/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32s3" 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_PARTITION_TABLE_CUSTOM=y 8 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 9 | CONFIG_SR_WN_WN9_HIESP=y 10 | SR_MN_CN_MULTINET7_QUANT=y 11 | CONFIG_SPIRAM=y 12 | CONFIG_SPIRAM_MODE_OCT=y 13 | CONFIG_SPIRAM_SPEED_80M=y 14 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 15 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 16 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 17 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 18 | -------------------------------------------------------------------------------- /examples/deep_noise_suppression/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(EXTRA_COMPONENT_DIRS 4 | ../../components 5 | ) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(deep_noise_suppression) 9 | -------------------------------------------------------------------------------- /examples/deep_noise_suppression/README.md: -------------------------------------------------------------------------------- 1 | # Voice Example [[中文]](./README_cn.md) 2 | 3 | 4 | 5 | (See the [README.md](../README.md) file in the upper level 'examples' directory for more information about examples.) 6 | 7 | This example is used to test performance of voice communication. 8 | 9 | 10 | ## How to use this example 11 | 12 | ### Hardware Required 13 | 14 | - This example can be run on the esp32 korvo development board / esp32-s3-korvo development board. For more information about the development board, please refer to [ESP32-Korvo Getting Started Guide](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32/user-guide-esp32-korvo-v1.1.md) or [ESP32-S3-Korvo-1 Getting Started Guide](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32s3/user-guide-korvo-1.md). 15 | 16 | 17 | ##### configure 18 | 19 | * Select the default sdkconfig according to the development board module 20 | 21 | - For example, using ESP32, run `cp sdkconfig.defaults.esp32 sdkconfig` 22 | 23 | - For example, using ESP32-S3, run `cp sdkconfig.defaults.esp32s3 sdkconfig` 24 | 25 | - For example, using ESP32-P4, run `cp sdkconfig.defaults.esp32p4 sdkconfig` 26 | 27 | * Run `idf.py menuconfig` 28 | 29 | * Set serial port information through `Serial Flasher Options` 30 | 31 | ##### build&flash 32 | 33 | Build the project and flash it to the board, then run the monitor tool to view the output via serial port: 34 | 35 | ``` 36 | idf.py -b 2000000 flash monitor -p PORT 37 | ``` 38 | 39 | (To exit the serial monitor, type ``Ctrl-]``.) 40 | 41 | If you want to get more detail of build ESP-IDF, please refer to [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/stable/get-started-cmake/index.html) 42 | 43 | This example is the algorithm processing of voice communication. If you need to see the result of algorithm processing. You can open the macro `DEBUG_SAVE_PCM` in the example, and insert the SD card to save the original audio and processed audio. Then you open it with audio software to view the algorithm effect.In the data directory, there are ​​pre-processed and post-processed audio files​​ available for ​​comparative evaluation of the effects​​. 44 | -------------------------------------------------------------------------------- /examples/deep_noise_suppression/README_cn.md: -------------------------------------------------------------------------------- 1 | # 语音例程 [[English]](./README.md) 2 | 3 | (参考在上一级的 `examples` 目录下的 [README.md](../README.md) 文件来获取更多信息。) 4 | 5 | 在这个示例中,我们演示了语音通话的调用方式 6 | 7 | ## 如何使用例程 8 | 9 | ### 硬件需求 10 | 11 | - 这个示例能够在 ESP32-Korvo 开发板/ESP32-S3-Korvo 开发板上运行,关于开发板更多的信息,请参考 [ESP32-Korvo Getting Started Guide](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32/user-guide-esp32-korvo-v1.1.md) 或者 [ESP32-S3-Korvo-1 Getting Started Guide](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32s3/user-guide-korvo-1.md). 12 | 13 | 14 | ### 配置工程 15 | 16 | * 根据使用的开发板模组选择对应的 `sdkconfig` 17 | 18 | - 比如, 使用 ESP32, 运行 `cp sdkconfig.defaults.esp32 sdkconfig` 19 | 20 | - 比如, 使用 ESP32-S3, 运行 `cp sdkconfig.defaults.esp32s3 sdkconfig` 21 | 22 | - 比如, 使用 ESP32-P4, 运行 `cp sdkconfig.defaults.esp32p4 sdkconfig` 23 | 24 | * 进入 `idf.py menuconfig` 25 | 26 | * 通过 `Serial Flasher Options`设置串口信息 27 | 28 | ### 编译和烧写 29 | 30 | 编译并烧写,然后运行终端监控查看打印: 31 | 32 | ``` 33 | idf.py -b 2000000 flash monitor -p PORT 34 | ``` 35 | 36 | (退出窗口,请键入 ``Ctrl-]``.) 37 | 38 | 参考 [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/stable/get-started-cmake/index.html) 来获取更多使用 ESP-IDF 编译项目的细节. 39 | 40 | 该例程是语音通话的算法处理,需要看算法处理结果的话。可以打开例程中的宏`DEBUG_SAVE_PCM`,插入SD卡,保存原始音频和处理之后的音频,用音频软件打开,即可查看算法效果。data目录下有处理之前和处理之后的音频文件,可以对比查看效果。 -------------------------------------------------------------------------------- /examples/deep_noise_suppression/data/FEED.PCM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/examples/deep_noise_suppression/data/FEED.PCM -------------------------------------------------------------------------------- /examples/deep_noise_suppression/data/FETCH.PCM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/examples/deep_noise_suppression/data/FETCH.PCM -------------------------------------------------------------------------------- /examples/deep_noise_suppression/data/ent.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/examples/deep_noise_suppression/data/ent.wav -------------------------------------------------------------------------------- /examples/deep_noise_suppression/data/raw.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/examples/deep_noise_suppression/data/raw.wav -------------------------------------------------------------------------------- /examples/deep_noise_suppression/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(requires 2 | hardware_driver 3 | sr_ringbuf 4 | ) 5 | 6 | idf_component_register(SRCS main.c 7 | REQUIRES ${requires}) 8 | 9 | -------------------------------------------------------------------------------- /examples/deep_noise_suppression/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-sr: "^2.0.0" 3 | -------------------------------------------------------------------------------- /examples/deep_noise_suppression/partitions.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 2500k 4 | model, data, spiffs, , 5168K, 5 | -------------------------------------------------------------------------------- /examples/deep_noise_suppression/partitions_esp32.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 5120k -------------------------------------------------------------------------------- /examples/deep_noise_suppression/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_CUSTOM=y 2 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 3 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 4 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y -------------------------------------------------------------------------------- /examples/deep_noise_suppression/sdkconfig.defaults.esp32: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_TARGET="esp32" 2 | CONFIG_IDF_TARGET_ESP32=y 3 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 4 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 5 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 6 | CONFIG_PARTITION_TABLE_CUSTOM=y 7 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_esp32.csv" 8 | CONFIG_PARTITION_TABLE_FILENAME="partitions_esp32.csv" 9 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 10 | CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y 11 | CONFIG_ESP32_SPIRAM_SUPPORT=y 12 | CONFIG_SPIRAM_SPEED_80M=y 13 | # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set 14 | CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y 15 | # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set 16 | # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set 17 | # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set 18 | 19 | # CONFIG_MODEL_IN_SDCARD is not set 20 | CONFIG_SR_WN_MODEL_WN5_QUANT=y 21 | CONFIG_SR_WN_WN5_HILEXIN=y 22 | # CONFIG_USE_MULTINET is not set -------------------------------------------------------------------------------- /examples/deep_noise_suppression/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32p4" 5 | CONFIG_SR_NSN_NSNET2=y 6 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 7 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 8 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 9 | CONFIG_PARTITION_TABLE_CUSTOM=y 10 | CONFIG_SPIRAM=y 11 | CONFIG_SPIRAM_SPEED_200M=y 12 | CONFIG_CACHE_L2_CACHE_256KB=y 13 | CONFIG_CACHE_L2_CACHE_LINE_128B=y 14 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y -------------------------------------------------------------------------------- /examples/deep_noise_suppression/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32s3" 5 | CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 6 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 7 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 8 | CONFIG_PARTITION_TABLE_CUSTOM=y 9 | CONFIG_SR_NSN_NSNET2=y 10 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 11 | CONFIG_SPIRAM=y 12 | CONFIG_SPIRAM_MODE_OCT=y 13 | CONFIG_SPIRAM_SPEED_80M=y 14 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 15 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 16 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 17 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 18 | CONFIG_ESP_WIFI_GMAC_SUPPORT=n 19 | CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744 20 | CONFIG_LWIP_TCP_WND_DEFAULT=5744 21 | -------------------------------------------------------------------------------- /examples/direction_of_arrival/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(EXTRA_COMPONENT_DIRS 4 | ../../components 5 | ) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(direction_of_arrival) 9 | -------------------------------------------------------------------------------- /examples/direction_of_arrival/README.md: -------------------------------------------------------------------------------- 1 | # Voice Example [[中文]](./README_cn.md) 2 | 3 | 4 | 5 | (See the [README.md](../README.md) file in the upper level 'examples' directory for more information about examples.) 6 | 7 | This example is used to test performance of direction of arrival estimation. 8 | 9 | 10 | ## How to use this example 11 | 12 | ### Hardware Required 13 | 14 | - This example can be run on the esp32 korvo development board / esp32-s3-korvo development board. For more information about the development board, please refer to [ESP32-Korvo Getting Started Guide](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32/user-guide-esp32-korvo-v1.1.md) or [ESP32-S3-Korvo-1 Getting Started Guide](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32s3/user-guide-korvo-1.md). 15 | 16 | 17 | ##### configure 18 | 19 | * Select the default sdkconfig according to the development board module 20 | 21 | - For example, using ESP32, run `cp sdkconfig.defaults.esp32 sdkconfig` 22 | 23 | - For example, using ESP32-S3, run `cp sdkconfig.defaults.esp32s3 sdkconfig` 24 | 25 | - For example, using ESP32-P4, run `cp sdkconfig.defaults.esp32p4 sdkconfig` 26 | 27 | * Run `idf.py menuconfig` 28 | 29 | * Set serial port information through `Serial Flasher Options` 30 | 31 | ##### build&flash 32 | 33 | Build the project and flash it to the board, then run the monitor tool to view the output via serial port: 34 | 35 | ``` 36 | idf.py -b 2000000 flash monitor -p PORT 37 | ``` 38 | 39 | (To exit the serial monitor, type ``Ctrl-]``.) 40 | 41 | If you want to get more detail of build ESP-IDF, please refer to [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/stable/get-started-cmake/index.html) 42 | 43 | This example is the algorithm processing of direction of arrival estimation. If you need to see the result of algorithm processing. You can open the macro `DEBUG_SAVE_PCM` in the example, and insert the SD card to save the original audio and processed audio. Then you open it with audio software to view the algorithm effect. 44 | -------------------------------------------------------------------------------- /examples/direction_of_arrival/README_cn.md: -------------------------------------------------------------------------------- 1 | # 语音例程 [[English]](./README.md) 2 | 3 | (参考在上一级的 `examples` 目录下的 [README.md](../README.md) 文件来获取更多信息。) 4 | 5 | 在这个示例中,我们演示了方位估计的调用方式 6 | 7 | ## 如何使用例程 8 | 9 | ### 硬件需求 10 | 11 | - 这个示例能够在 ESP32-Korvo 开发板/ESP32-S3-Korvo 开发板上运行,关于开发板更多的信息,请参考 [ESP32-Korvo Getting Started Guide](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32/user-guide-esp32-korvo-v1.1.md) 或者 [ESP32-S3-Korvo-1 Getting Started Guide](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32s3/user-guide-korvo-1.md). 12 | 13 | 14 | ### 配置工程 15 | 16 | * 根据使用的开发板模组选择对应的 `sdkconfig` 17 | 18 | - 比如, 使用 ESP32, 运行 `cp sdkconfig.defaults.esp32 sdkconfig` 19 | 20 | - 比如, 使用 ESP32-S3, 运行 `cp sdkconfig.defaults.esp32s3 sdkconfig` 21 | 22 | - 比如, 使用 ESP32-P4, 运行 `cp sdkconfig.defaults.esp32p4 sdkconfig` 23 | 24 | * 进入 `idf.py menuconfig` 25 | 26 | * 通过 `Serial Flasher Options`设置串口信息 27 | 28 | ### 编译和烧写 29 | 30 | 编译并烧写,然后运行终端监控查看打印: 31 | 32 | ``` 33 | idf.py -b 2000000 flash monitor -p PORT 34 | ``` 35 | 36 | (退出窗口,请键入 ``Ctrl-]``.) 37 | 38 | 参考 [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/stable/get-started-cmake/index.html) 来获取更多使用 ESP-IDF 编译项目的细节. 39 | 40 | 该例程是方位估计的算法处理,需要看算法处理结果的话。可以打开例程中的宏`DEBUG_SAVE_PCM`,插入SD卡,保存原始音频和处理之后的音频,用音频软件打开,即可查看算法效果。 -------------------------------------------------------------------------------- /examples/direction_of_arrival/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(requires 2 | hardware_driver 3 | sr_ringbuf 4 | ) 5 | 6 | idf_component_register(SRCS main.c 7 | REQUIRES ${requires}) 8 | 9 | -------------------------------------------------------------------------------- /examples/direction_of_arrival/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-sr: "^2.0.0" 3 | -------------------------------------------------------------------------------- /examples/direction_of_arrival/partitions.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 2500k 4 | model, data, spiffs, , 5168K, 5 | -------------------------------------------------------------------------------- /examples/direction_of_arrival/partitions_esp32.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 5120k -------------------------------------------------------------------------------- /examples/direction_of_arrival/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_CUSTOM=y 2 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 3 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 4 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y -------------------------------------------------------------------------------- /examples/direction_of_arrival/sdkconfig.defaults.esp32: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_TARGET="esp32" 2 | CONFIG_IDF_TARGET_ESP32=y 3 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 4 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 5 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 6 | CONFIG_PARTITION_TABLE_CUSTOM=y 7 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_esp32.csv" 8 | CONFIG_PARTITION_TABLE_FILENAME="partitions_esp32.csv" 9 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 10 | CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y 11 | CONFIG_ESP32_SPIRAM_SUPPORT=y 12 | CONFIG_SPIRAM_SPEED_80M=y 13 | # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set 14 | CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y 15 | # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set 16 | # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set 17 | # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set 18 | 19 | # CONFIG_MODEL_IN_SDCARD is not set 20 | CONFIG_SR_WN_MODEL_WN5_QUANT=y 21 | CONFIG_SR_WN_WN5_HILEXIN=y 22 | # CONFIG_USE_MULTINET is not set -------------------------------------------------------------------------------- /examples/direction_of_arrival/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32p4" 5 | CONFIG_SR_NSN_NSNET2=y 6 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 7 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 8 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 9 | CONFIG_PARTITION_TABLE_CUSTOM=y 10 | CONFIG_SPIRAM=y 11 | CONFIG_SPIRAM_SPEED_200M=y 12 | CONFIG_CACHE_L2_CACHE_256KB=y 13 | CONFIG_CACHE_L2_CACHE_LINE_128B=y 14 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y -------------------------------------------------------------------------------- /examples/direction_of_arrival/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32s3" 5 | CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 6 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 7 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 8 | CONFIG_PARTITION_TABLE_CUSTOM=y 9 | CONFIG_SR_NSN_NSNET2=y 10 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 11 | CONFIG_SPIRAM=y 12 | CONFIG_SPIRAM_MODE_OCT=y 13 | CONFIG_SPIRAM_SPEED_80M=y 14 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 15 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 16 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 17 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 18 | CONFIG_ESP_WIFI_GMAC_SUPPORT=n 19 | CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744 20 | CONFIG_LWIP_TCP_WND_DEFAULT=5744 21 | -------------------------------------------------------------------------------- /examples/en_speech_commands_recognition/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(EXTRA_COMPONENT_DIRS 4 | ../../components 5 | ) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(speech_commands_recognition) 9 | -------------------------------------------------------------------------------- /examples/en_speech_commands_recognition/README.md: -------------------------------------------------------------------------------- 1 | # English Speech Commands Recognition 2 | 3 | 4 | 5 | (See the [README.md](../README.md) file in the upper level 'examples' directory for more information about examples.) 6 | 7 | ## How to use this example 8 | 9 | 10 | ### Additional Hardware Required 11 | 12 | \- A Speaker 13 | 14 | ### Configure, Build and Flash 15 | 16 | 17 | ##### set-target 18 | 19 | ``` 20 | idf.py set-target esp32s3 21 | ``` 22 | 23 | ##### configure 24 | 25 | Select the default sdkconfig according to the development board module 26 | 27 | For example: 28 | 29 | ``` 30 | cp sdkconfig.defaults.esp32s3 sdkconfig 31 | ``` 32 | 33 | ##### build&flash 34 | 35 | Build the project and flash it to the board, then run the monitor tool to view the output via serial port: 36 | 37 | ``` 38 | idf.py -b 2000000 flash monitor 39 | ``` 40 | 41 | (To exit the serial monitor, type ``Ctrl-]``.) 42 | 43 | ### Modify speech commands 44 | 45 | We recommend using MultiNet6 or newer models. 46 | Here's a simple example to modify speech commands in the code. 47 | You can also modify the default command list, please refer to [document](https://docs.espressif.com/projects/esp-sr/en/latest/esp32s3/speech_command_recognition/README.html) for more details. 48 | 49 | ``` 50 | // MultiNet6 51 | // Note: Please create multinet handle before adding speech commands 52 | 53 | esp_mn_commands_clear(); // Clear commands that already exist 54 | esp_mn_commands_add(1, "turn on the light"); // add a command 55 | esp_mn_commands_add(2, "turn off the light"); // add a command 56 | esp_mn_commands_update(); // update commands 57 | multinet->print_active_speech_commands(model_data); // print active commands 58 | ``` 59 | -------------------------------------------------------------------------------- /examples/en_speech_commands_recognition/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(srcs 2 | main.c 3 | speech_commands_action.c 4 | ) 5 | 6 | set(requires 7 | hardware_driver 8 | ) 9 | 10 | idf_component_register(SRCS ${srcs} 11 | INCLUDE_DIRS include 12 | REQUIRES ${requires}) 13 | 14 | component_compile_options(-w) -------------------------------------------------------------------------------- /examples/en_speech_commands_recognition/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-sr: "^2.0.0" 3 | espressif/led_strip: "^2.5.0" 4 | -------------------------------------------------------------------------------- /examples/en_speech_commands_recognition/main/include/speech_commands_action.h: -------------------------------------------------------------------------------- 1 | /* 2 | This example code is in the Public Domain (or CC0 licensed, at your option.) 3 | 4 | Unless required by applicable law or agreed to in writing, this 5 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 6 | CONDITIONS OF ANY KIND, either express or implied. 7 | */ 8 | #ifndef _SPEECH_COMMANDS_ACTION_H_ 9 | #define _SPEECH_COMMANDS_ACTION_H_ 10 | 11 | void led_Task(void *arg); 12 | 13 | void speech_commands_action(int command_id); 14 | 15 | void wake_up_action(void); 16 | #endif -------------------------------------------------------------------------------- /examples/en_speech_commands_recognition/partitions.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 2048k 4 | model, data, spiffs, , 5168K, -------------------------------------------------------------------------------- /examples/en_speech_commands_recognition/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_CUSTOM=y 2 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 3 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 4 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 5 | -------------------------------------------------------------------------------- /examples/en_speech_commands_recognition/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.5.0 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32p4" 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_PARTITION_TABLE_CUSTOM=y 8 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 9 | CONFIG_SR_WN_WN9_HIESP=y 10 | CONFIG_SR_MN_EN_MULTINET7_QUANT=y 11 | CONFIG_SPIRAM=y 12 | CONFIG_SPIRAM_SPEED_200M=y 13 | CONFIG_CACHE_L2_CACHE_256KB=y 14 | CONFIG_CACHE_L2_CACHE_LINE_128B=y 15 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y 16 | -------------------------------------------------------------------------------- /examples/en_speech_commands_recognition/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32s3" 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_PARTITION_TABLE_CUSTOM=y 8 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 9 | CONFIG_SR_WN_WN9_HIESP=y 10 | CONFIG_SR_MN_EN_MULTINET5_SINGLE_RECOGNITION_QUANT8=y 11 | CONFIG_SPIRAM=y 12 | CONFIG_SPIRAM_MODE_OCT=y 13 | CONFIG_SPIRAM_SPEED_80M=y 14 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 15 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 16 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 17 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 18 | -------------------------------------------------------------------------------- /examples/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_CUSTOM=y 2 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 3 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 4 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 5 | -------------------------------------------------------------------------------- /examples/usb_mic_recorder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(EXTRA_COMPONENT_DIRS 4 | ../../components 5 | ) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(usb_uac_mic_example) -------------------------------------------------------------------------------- /examples/usb_mic_recorder/README.md: -------------------------------------------------------------------------------- 1 | ## Overview 2 | 3 | This project is to transfer the on-board microphone data to the computer via the USB audio device function. 4 | 5 | Supported Development Boards 6 | 7 | * ESP-BOX 8 | * ESP32-S3-Korvo-2: You need to remove the 0-ohm resistors (R181,R182) at USB_DM and USB_DP and add two 0-ohm resistors (R394,R395) at ESP_USB_DM and ESP_USB_DP. [Hardware Schematic](https://dl.espressif.com/dl/schematics/SCH_ESP32-S3-KORVO-2_V3_0_20210918.pdf) 9 | 10 | ## How To USE 11 | 12 | ### 1. compile and flash project 13 | ``` 14 | idf.py set-target esp32s3 15 | idf.py flash 16 | ``` 17 | 18 | **Note**: After you flash this project, the device will act as a USB sound card. If you want to flash other projects by USB again, Please hold down `Boot` and then press `Reset` to initiates firmware-download-mode. 19 | 20 | ### 2. select sound card device 21 | 22 | When you plug the usb port into your computer(**Linux only**), it will display the MicNode sound card device. Please select MicNode sound card device. 23 | ![MicNode](../../img/MicNode.png) 24 | 25 | ### 3. Recording by arecord 26 | 27 | ```bash 28 | # Install arecord 29 | sudo apt-get install alsa-utils alsa-tools alsa-tools-gui alsamixergui -y 30 | 31 | # Show the list of CAPTURE hardware devices 32 | arecord -l 33 | 34 | # Start to record 35 | arecord -Dhw:1,0 -d 60 -f cd -r 16000 -c 2 -t wav voice.wav 36 | #-D, --device=NAME select CAPTURE hardware device, hw:1,0 means card 1 and device 0 37 | #-d, --duration=# interrupt after # seconds 38 | #-f, --format=FORMAT sample format, cd: 16 bit little endian, stereo) 39 | #-r, --rate=# sample rate 40 | #-c, --channels=# channels 41 | #-t, --file-type TYPE file type (voc, wav, raw or au) 42 | 43 | # Print help info 44 | arecord -h 45 | ``` -------------------------------------------------------------------------------- /examples/usb_mic_recorder/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS main.c src/usb_mic_recorder.c src/usb_descriptors.c 2 | INCLUDE_DIRS include) 3 | 4 | idf_component_get_property(tusb_lib leeebo__tinyusb_src COMPONENT_LIB) 5 | cmake_policy(SET CMP0079 NEW) 6 | target_link_libraries(${tusb_lib} PRIVATE ${COMPONENT_LIB}) -------------------------------------------------------------------------------- /examples/usb_mic_recorder/main/Kconfig.projbuild: -------------------------------------------------------------------------------- 1 | menu "USB MIC Configuration" 2 | 3 | choice 4 | prompt "Num Of Channel" 5 | default THREE_CHANNEL 6 | 7 | config ONE_CHANNEL 8 | bool "One Channel config" 9 | config TWO_CHANNEL 10 | bool "Two Channels config" 11 | config THREE_CHANNEL 12 | bool "THREE Channels config" 13 | config FOUR_CHANNEL 14 | bool "Four Channels config" 15 | endchoice 16 | 17 | 18 | choice 19 | prompt "Mic Bit Depth" 20 | default BIT_DEPTH_16 21 | 22 | config BIT_DEPTH_16 23 | bool "16 bits" 24 | 25 | endchoice 26 | 27 | choice 28 | prompt "Mic Sampling Rate" 29 | default SAMPLING_RATE_16K 30 | 31 | config SAMPLING_RATE_16K 32 | bool "16000 sampling rate" 33 | 34 | config SAMPLING_RATE_48K 35 | bool "48000 sampling rate" 36 | 37 | endchoice 38 | 39 | config TINYUSB_DEBUG_LEVEL 40 | int "Tinyusb debug level" 41 | default 0 42 | range 0 3 43 | help 44 | Tinyusb debug level. 45 | 46 | endmenu -------------------------------------------------------------------------------- /examples/usb_mic_recorder/main/Kconfig.projbuild.new: -------------------------------------------------------------------------------- 1 | menu "USB MIC Configuration" 2 | 3 | choice 4 | prompt "Num Of Channel" 5 | default THREE_CHANNEL 6 | 7 | config ONE_CHANNEL 8 | bool "One Channel config" 9 | config TWO_CHANNEL 10 | bool "Two Channels config" 11 | config THREE_CHANNEL 12 | bool "THREE Channels config" 13 | config FOUR_CHANNEL 14 | bool "Four Channels config" 15 | endchoice 16 | 17 | 18 | choice 19 | prompt "Mic Bit Depth" 20 | default BIT_DEPTH_16 21 | 22 | config BIT_DEPTH_16 23 | bool "16 bits" 24 | 25 | endchoice 26 | 27 | choice 28 | prompt "Mic Sampling Rate" 29 | default SAMPLING_RATE_16K 30 | 31 | config SAMPLING_RATE_16K 32 | bool "16000 sampling rate" 33 | 34 | config SAMPLING_RATE_48K 35 | bool "48000 sampling rate" 36 | 37 | endchoice 38 | 39 | config TINYUSB_DEBUG_LEVEL 40 | int "Tinyusb debug level" 41 | default 0 42 | range 0 3 43 | help 44 | Tinyusb debug level. 45 | 46 | endmenu -------------------------------------------------------------------------------- /examples/usb_mic_recorder/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | idf: ">=4.4" 4 | leeebo/tinyusb_src: "0.0.4" 5 | espressif/esp-sr: "^2.0.0" 6 | 7 | -------------------------------------------------------------------------------- /examples/usb_mic_recorder/main/include/usb_mic_recorder.h: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD 2 | * 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | #pragma once 6 | 7 | #ifndef __USB_MIC_RECORDER_H 8 | #define __USB_MIC_RECORDER_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #include "esp_err.h" 15 | #include "ringbuf.h" 16 | 17 | /** 18 | * @brief Initializing the USB MIC function 19 | * 20 | * @return ringbuf_handle_t 21 | */ 22 | ringbuf_handle_t mic_recorder_init(); 23 | 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif // __USB_MIC_RECORDEr_H -------------------------------------------------------------------------------- /examples/usb_mic_recorder/main/main.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD 2 | * 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | #include 6 | #include "freertos/FreeRTOS.h" 7 | #include "freertos/task.h" 8 | #include "esp_wn_iface.h" 9 | #include "esp_wn_models.h" 10 | #include "dl_lib_coefgetter_if.h" 11 | #include "esp_afe_sr_models.h" 12 | #include "esp_mn_iface.h" 13 | #include "esp_mn_models.h" 14 | #include "esp_board_init.h" 15 | #include "model_path.h" 16 | #include "usb_mic_recorder.h" 17 | 18 | static ringbuf_handle_t rb_debug = NULL; 19 | 20 | int detect_flag = 0; 21 | static esp_afe_sr_iface_t *afe_handle = NULL; 22 | static volatile int task_flag = 0; 23 | 24 | void feed_Task(void *arg) 25 | { 26 | esp_afe_sr_data_t *afe_data = arg; 27 | int audio_chunksize = afe_handle->get_feed_chunksize(afe_data); 28 | int nch = afe_handle->get_feed_channel_num(afe_data); 29 | int feed_channel = esp_get_feed_channel(); 30 | assert(nch == feed_channel); 31 | int16_t *i2s_buff = malloc(audio_chunksize * sizeof(int16_t) * feed_channel); 32 | char *destry_buff = malloc(audio_chunksize * sizeof(int16_t) * feed_channel); 33 | assert(i2s_buff); 34 | assert(destry_buff); 35 | 36 | while (task_flag) { 37 | esp_get_feed_data(true, i2s_buff, audio_chunksize * sizeof(int16_t) * feed_channel); 38 | 39 | afe_handle->feed(afe_data, i2s_buff); 40 | 41 | // Write data to ringbuffer and overwrite old data if it is full. 42 | if (rb_bytes_available(rb_debug) < audio_chunksize * nch * sizeof(int16_t)) { 43 | rb_read(rb_debug, (char *) destry_buff, audio_chunksize * nch * sizeof(int16_t), 0); 44 | } 45 | rb_write(rb_debug, (char *)i2s_buff, audio_chunksize * nch * sizeof(int16_t), 0); 46 | 47 | } 48 | if (i2s_buff) { 49 | free(i2s_buff); 50 | i2s_buff = NULL; 51 | } 52 | vTaskDelete(NULL); 53 | } 54 | 55 | void detect_Task(void *arg) 56 | { 57 | esp_afe_sr_data_t *afe_data = arg; 58 | int afe_chunksize = afe_handle->get_fetch_chunksize(afe_data); 59 | int16_t *buff = malloc(afe_chunksize * sizeof(int16_t)); 60 | assert(buff); 61 | printf("------------detect start------------\n"); 62 | 63 | while (task_flag) { 64 | afe_fetch_result_t *res = afe_handle->fetch(afe_data); 65 | if (res && res->ret_value != ESP_FAIL) { 66 | memcpy(buff, res->data, afe_chunksize * sizeof(int16_t)); 67 | } 68 | } 69 | if (buff) { 70 | free(buff); 71 | buff = NULL; 72 | } 73 | vTaskDelete(NULL); 74 | } 75 | 76 | void app_main() 77 | { 78 | ESP_ERROR_CHECK(esp_board_init(16000, 1, 16)); 79 | 80 | afe_config_t *afe_config = afe_config_init(esp_get_input_format(), NULL, AFE_TYPE_VC, AFE_MODE_LOW_COST); 81 | afe_handle = esp_afe_handle_from_config(afe_config); 82 | esp_afe_sr_data_t * afe_data = afe_handle->create_from_config(afe_config); 83 | afe_config_free(afe_config); 84 | rb_debug = mic_recorder_init(); 85 | 86 | task_flag = 1; 87 | xTaskCreatePinnedToCore(&feed_Task, "feed", 8 * 1024, (void *)afe_data, 5, NULL, 0); 88 | xTaskCreatePinnedToCore(&detect_Task, "detect", 8 * 1024, (void *)afe_data, 5, NULL, 1); 89 | 90 | // You can call afe_handle->destroy to destroy AFE. 91 | // task_flag = 0; 92 | 93 | // printf("destroy\n"); 94 | // afe_handle->destroy(afe_data); 95 | // afe_data = NULL; 96 | // printf("successful\n"); 97 | } 98 | -------------------------------------------------------------------------------- /examples/usb_mic_recorder/partitions.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 2048k 4 | model, data, spiffs, , 5168K, -------------------------------------------------------------------------------- /examples/usb_mic_recorder/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration 3 | # 4 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 5 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 6 | CONFIG_ESP_CONSOLE_UART_CUSTOM=y 7 | CONFIG_ESP_CONSOLE_SECONDARY_NONE=y 8 | CONFIG_FREERTOS_HZ=1000 9 | 10 | CONFIG_PARTITION_TABLE_CUSTOM=y 11 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 12 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 13 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 14 | 15 | CONFIG_ESP32_S3_BOX_BOARD=y 16 | -------------------------------------------------------------------------------- /examples/usb_mic_recorder/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32p4" 5 | CONFIG_SR_NSN_NSNET2=y 6 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 7 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 8 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 9 | CONFIG_PARTITION_TABLE_CUSTOM=y 10 | CONFIG_SPIRAM=y 11 | CONFIG_SPIRAM_SPEED_200M=y 12 | CONFIG_CACHE_L2_CACHE_256KB=y 13 | CONFIG_CACHE_L2_CACHE_LINE_128B=y 14 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y -------------------------------------------------------------------------------- /examples/usb_mic_recorder/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32s3" 5 | CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 6 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 7 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 8 | CONFIG_PARTITION_TABLE_CUSTOM=y 9 | CONFIG_SR_NSN_NSNET2=y 10 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 11 | CONFIG_SPIRAM=y 12 | CONFIG_SPIRAM_MODE_OCT=y 13 | CONFIG_SPIRAM_SPEED_80M=y 14 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 15 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 16 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 17 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 18 | CONFIG_ESP_WIFI_GMAC_SUPPORT=n 19 | CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744 20 | CONFIG_LWIP_TCP_WND_DEFAULT=5744 21 | -------------------------------------------------------------------------------- /examples/voice_activity_detection/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(EXTRA_COMPONENT_DIRS 4 | ../../components 5 | ) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(wake_word_detection) 9 | -------------------------------------------------------------------------------- /examples/voice_activity_detection/README.md: -------------------------------------------------------------------------------- 1 | # Voice Activaty Detection 2 | 3 | 4 | This example is used to test VAD (Voice Activaty Detection). Now two types of VAD are supported: WebRTC VAD and Espressif's vadnet1. You can select the desired version through menuconfig. Compared to WebRTC noise, vadnet1 can filter out more noise, but it also consumes more CPU resources. 5 | 6 | 7 | ### Configure 8 | 9 | Select board and wake words 10 | ``` 11 | idf.py set-target esp32s3 12 | idf.py menuconfig 13 | 14 | # Select audio board 15 | Audio Media HAL -> Audio hardware board -> ESP32-S3-Korvo-1 16 | 17 | # Load vadnet1 model 18 | ESP Speech Recognition -> Select voice activity detection -> voice activity detection (vadnet1 medium) 19 | ``` 20 | 21 | ### Setting 22 | 23 | You can set the following parameters in the config file: 24 | ``` 25 | vad_init; // Whether to init vad 26 | vad_mode; // The value can be: VAD_MODE_0, VAD_MODE_1, VAD_MODE_2, VAD_MODE_3, VAD_MODE_4 27 | // The larger the mode, the higher the speech trigger probability. 28 | 29 | vad_model_name; // The model name of vad, If it is null, WebRTC VAD will be used. 30 | vad_min_speech_ms; // The minimum duration of speech in ms. It should be bigger than 32 ms, default: 128 ms 31 | vad_min_noise_ms; // The minimum duration of noise or silence in ms. It should be bigger than 64 ms, default: 1000 ms 32 | vad_delay_ms; // The delay of the first speech frame in ms, default: 128 ms 33 | // If you find vad cache can not cover all speech, please increase this value. 34 | ``` 35 | 36 | There are two issues in the VAD settings that can cause a delay in the first frame trigger of speech. 37 | 1. The inherent delay of the VAD algorithm itself. VAD cannot accurately trigger speech on the first frame and may delay by 1 to 3 frames. 38 | 2. To avoid false triggers, the VAD is triggered when the continuous trigger duration reaches the `vad_min_speech_ms` parameter in AFE configuation. 39 | Due to the above two reasons, directly using the first frame trigger of VAD may cause the first word to be truncated. 40 | To avoid this situation, AFE V2.0 has added a VAD cache. You can determine whether a VAD cache needs to be saved by checking the vad_cache_size 41 | 42 | ### build&flash 43 | 44 | Build the project and flash it to the board, then run the monitor tool to view the output via serial port: 45 | 46 | ``` 47 | idf.py flash monitor 48 | ``` 49 | 50 | (To exit the serial monitor, type ``Ctrl-]``.) 51 | 52 | 53 | -------------------------------------------------------------------------------- /examples/voice_activity_detection/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(requires 2 | hardware_driver 3 | player 4 | ) 5 | 6 | idf_component_register(SRCS main.c 7 | REQUIRES ${requires}) 8 | 9 | -------------------------------------------------------------------------------- /examples/voice_activity_detection/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-sr: "^2.0.0" 3 | -------------------------------------------------------------------------------- /examples/voice_activity_detection/partitions.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 2500k 4 | model, data, spiffs, , 5168K, 5 | -------------------------------------------------------------------------------- /examples/voice_activity_detection/partitions_esp32.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 5120k -------------------------------------------------------------------------------- /examples/voice_activity_detection/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_CUSTOM=y 2 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 3 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 4 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 5 | -------------------------------------------------------------------------------- /examples/voice_activity_detection/sdkconfig.defaults.esp32: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 5 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_PARTITION_TABLE_CUSTOM=y 8 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_esp32.csv" 9 | CONFIG_SPIRAM=y 10 | CONFIG_SPIRAM_SPEED_80M=y 11 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 12 | -------------------------------------------------------------------------------- /examples/voice_activity_detection/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32p4" 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 8 | CONFIG_SR_WN_WN9_HILEXIN=y 9 | CONFIG_CACHE_L2_CACHE_256KB=y 10 | CONFIG_CACHE_L2_CACHE_LINE_128B=y 11 | -------------------------------------------------------------------------------- /examples/voice_activity_detection/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32s3" 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_PARTITION_TABLE_CUSTOM=y 8 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 9 | CONFIG_SR_WN_WN9_HILEXIN=y 10 | CONFIG_SPIRAM=y 11 | CONFIG_SPIRAM_MODE_OCT=y 12 | CONFIG_SPIRAM_SPEED_80M=y 13 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 14 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 15 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 16 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 17 | -------------------------------------------------------------------------------- /examples/voice_communication/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(EXTRA_COMPONENT_DIRS 4 | ../../components 5 | ) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(wake_word_detection) 9 | -------------------------------------------------------------------------------- /examples/voice_communication/README.md: -------------------------------------------------------------------------------- 1 | # Voice Example [[中文]](./README_cn.md) 2 | 3 | 4 | 5 | (See the [README.md](../README.md) file in the upper level 'examples' directory for more information about examples.) 6 | 7 | This example is used to test performance of voice communication. 8 | 9 | 10 | ## How to use this example 11 | 12 | ### Hardware Required 13 | 14 | - This example can be run on the esp32 korvo development board / esp32-s3-korvo development board. For more information about the development board, please refer to [ESP32-Korvo Getting Started Guide](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32/user-guide-esp32-korvo-v1.1.md) or [ESP32-S3-Korvo-1 Getting Started Guide](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32s3/user-guide-korvo-1.md). 15 | 16 | 17 | ##### configure 18 | 19 | * Select the default sdkconfig according to the development board module 20 | 21 | - For example, using ESP32, run `cp sdkconfig.defaults.esp32 sdkconfig` 22 | 23 | - For example, using ESP32-S3, run `cp sdkconfig.defaults.esp32s3 sdkconfig` 24 | 25 | - For example, using ESP32-P4, run `cp sdkconfig.defaults.esp32p4 sdkconfig` 26 | 27 | * Run `idf.py menuconfig` 28 | 29 | * Set serial port information through `Serial Flasher Options` 30 | 31 | ##### build&flash 32 | 33 | Build the project and flash it to the board, then run the monitor tool to view the output via serial port: 34 | 35 | ``` 36 | idf.py -b 2000000 flash monitor -p PORT 37 | ``` 38 | 39 | (To exit the serial monitor, type ``Ctrl-]``.) 40 | 41 | If you want to get more detail of build ESP-IDF, please refer to [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/stable/get-started-cmake/index.html) 42 | 43 | This example is the algorithm processing of voice communication. If you need to see the result of algorithm processing. You can open the macro `DEBUG_SAVE_PCM` in the example, and insert the SD card to save the original audio and processed audio. Then you open it with audio software to view the algorithm effect. 44 | -------------------------------------------------------------------------------- /examples/voice_communication/README_cn.md: -------------------------------------------------------------------------------- 1 | # 语音例程 [[English]](./README.md) 2 | 3 | (参考在上一级的 `examples` 目录下的 [README.md](../README.md) 文件来获取更多信息。) 4 | 5 | 在这个示例中,我们演示了语音通话的调用方式 6 | 7 | ## 如何使用例程 8 | 9 | ### 硬件需求 10 | 11 | - 这个示例能够在 ESP32-Korvo 开发板/ESP32-S3-Korvo 开发板上运行,关于开发板更多的信息,请参考 [ESP32-Korvo Getting Started Guide](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32/user-guide-esp32-korvo-v1.1.md) 或者 [ESP32-S3-Korvo-1 Getting Started Guide](https://github.com/espressif/esp-skainet/blob/master/docs/en/hw-reference/esp32s3/user-guide-korvo-1.md). 12 | 13 | 14 | ### 配置工程 15 | 16 | * 根据使用的开发板模组选择对应的 `sdkconfig` 17 | 18 | - 比如, 使用 ESP32, 运行 `cp sdkconfig.defaults.esp32 sdkconfig` 19 | 20 | - 比如, 使用 ESP32-S3, 运行 `cp sdkconfig.defaults.esp32s3 sdkconfig` 21 | 22 | - 比如, 使用 ESP32-P4, 运行 `cp sdkconfig.defaults.esp32p4 sdkconfig` 23 | 24 | * 进入 `idf.py menuconfig` 25 | 26 | * 通过 `Serial Flasher Options`设置串口信息 27 | 28 | ### 编译和烧写 29 | 30 | 编译并烧写,然后运行终端监控查看打印: 31 | 32 | ``` 33 | idf.py -b 2000000 flash monitor -p PORT 34 | ``` 35 | 36 | (退出窗口,请键入 ``Ctrl-]``.) 37 | 38 | 参考 [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/stable/get-started-cmake/index.html) 来获取更多使用 ESP-IDF 编译项目的细节. 39 | 40 | 该例程是语音通话的算法处理,需要看算法处理结果的话。可以打开例程中的宏`DEBUG_SAVE_PCM`,插入SD卡,保存原始音频和处理之后的音频,用音频软件打开,即可查看算法效果。 -------------------------------------------------------------------------------- /examples/voice_communication/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(requires 2 | hardware_driver 3 | sr_ringbuf 4 | ) 5 | 6 | idf_component_register(SRCS main.c 7 | REQUIRES ${requires}) 8 | 9 | -------------------------------------------------------------------------------- /examples/voice_communication/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-sr: "^2.0.0" 3 | -------------------------------------------------------------------------------- /examples/voice_communication/partitions.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 2500k 4 | model, data, spiffs, , 5168K, 5 | -------------------------------------------------------------------------------- /examples/voice_communication/partitions_esp32.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 5120k -------------------------------------------------------------------------------- /examples/voice_communication/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_CUSTOM=y 2 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 3 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 4 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y -------------------------------------------------------------------------------- /examples/voice_communication/sdkconfig.defaults.esp32: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_TARGET="esp32" 2 | CONFIG_IDF_TARGET_ESP32=y 3 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 4 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 5 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 6 | CONFIG_PARTITION_TABLE_CUSTOM=y 7 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_esp32.csv" 8 | CONFIG_PARTITION_TABLE_FILENAME="partitions_esp32.csv" 9 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 10 | CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y 11 | CONFIG_ESP32_SPIRAM_SUPPORT=y 12 | CONFIG_SPIRAM_SPEED_80M=y 13 | # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set 14 | CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y 15 | # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set 16 | # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set 17 | # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set 18 | 19 | # CONFIG_MODEL_IN_SDCARD is not set 20 | CONFIG_SR_WN_MODEL_WN5_QUANT=y 21 | CONFIG_SR_WN_WN5_HILEXIN=y 22 | # CONFIG_USE_MULTINET is not set -------------------------------------------------------------------------------- /examples/voice_communication/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32p4" 5 | CONFIG_SR_NSN_NSNET2=y 6 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 7 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 8 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 9 | CONFIG_PARTITION_TABLE_CUSTOM=y 10 | CONFIG_SPIRAM=y 11 | CONFIG_SPIRAM_SPEED_200M=y 12 | CONFIG_CACHE_L2_CACHE_256KB=y 13 | CONFIG_CACHE_L2_CACHE_LINE_128B=y 14 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y -------------------------------------------------------------------------------- /examples/voice_communication/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32s3" 5 | CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 6 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 7 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 8 | CONFIG_PARTITION_TABLE_CUSTOM=y 9 | CONFIG_SR_NSN_NSNET2=y 10 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 11 | CONFIG_SPIRAM=y 12 | CONFIG_SPIRAM_MODE_OCT=y 13 | CONFIG_SPIRAM_SPEED_80M=y 14 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 15 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 16 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 17 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 18 | CONFIG_ESP_WIFI_GMAC_SUPPORT=n 19 | CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744 20 | CONFIG_LWIP_TCP_WND_DEFAULT=5744 21 | -------------------------------------------------------------------------------- /examples/wake_word_detection/README.md: -------------------------------------------------------------------------------- 1 | # Wake Word Detection 2 | 3 | ## `wake_word_detection/wakenet` 4 | 5 | | Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-P4 | ESP32-C3 | ESP32-C5 | ESP32-C6 | 6 | | ----------------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | 7 | 8 | This example shows how to use the Wakenet interface directly. If you are using a single microphone and only need to use WakeNet, and you want to reduce memory and CPU resource consumption, this example is recommended. 9 | 10 | 11 | ## `wake_word_detection/afe` 12 | 13 | | Supported Targets | ESP32 | ESP32-S3 | ESP32-P4 | 14 | | ----------------- | -------- | -------- | -------- | 15 | 16 | This example shows how to use WakeNet through the AFE interface. If you are using a dual-microphone or require more speech enhancement algorithms, this example is recommended. 17 | -------------------------------------------------------------------------------- /examples/wake_word_detection/afe/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(EXTRA_COMPONENT_DIRS 4 | ../../../components 5 | ) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(wake_word_detection) 9 | -------------------------------------------------------------------------------- /examples/wake_word_detection/afe/README.md: -------------------------------------------------------------------------------- 1 | # Wake Word Detection 2 | 3 | 4 | 5 | (See the [README.md](../README.md) file in the upper level 'examples' directory for more information about examples.) 6 | 7 | | Supported Targets | ESP32 | ESP32-S3 | ESP32-P4 | 8 | | ----------------- | -------- | -------- | -------- | 9 | 10 | This example is used to test performance of wakenet.(the word word engine of Espressif). 11 | This example can load multiple models, but can only run two models at the same time 12 | 13 | 14 | ### Configure 15 | 16 | Select board and wake words 17 | ``` 18 | idf.py set-target esp32s3 19 | idf.py menuconfig 20 | 21 | # Select audio board 22 | Audio Media HAL -> Audio hardware board -> ESP32-S3-Korvo-1 23 | 24 | # Load one wakenet model 25 | ESP Speech Recognition -> Select wake words -> Hi,Lexin (wn9_hilexin) 26 | 27 | # Load multiple wakenet models 28 | ESP Speech Recognition -> Select wake words -> Hi,Lexin (wn9_hilexin) -> Load Multiple Wake Words 29 | ESP Speech Recognition -> Load Multiple Wake Words -> Hi,Lexin (wn9_hilexin) 30 | -> Hi,ESP (wn9_hiesp) 31 | ``` 32 | 33 | ### build&flash 34 | 35 | Build the project and flash it to the board, then run the monitor tool to view the output via serial port: 36 | 37 | ``` 38 | idf.py flash monitor 39 | ``` 40 | 41 | (To exit the serial monitor, type ``Ctrl-]``.) 42 | 43 | 44 | ### modify detection threshold 45 | 46 | The default detection threshold is defined in `_MODEL_INFO_` file, and it will be printed when model is created. 47 | 48 | For example, [`wakenet9_v1h24_嗨,乐鑫_3_0.608_0.615`](https://github.com/espressif/esp-sr/blob/master/model/wakenet_model/wn9_hilexin/_MODEL_INFO_) has a detection threshold range from 0.608 to 0.615. 49 | You can modify threshold in the following ways: 50 | 51 | - modify the threshold in `_MODEL_INFO_` file 52 | 53 | - modify the threshold in code 54 | 55 | ``` 56 | afe_handle->set_wakenet_threshold(afe_handle, model_index, threshold); // currently AFE support to load two model. model_index is 1 or 2 57 | afe_handle->reset_wakenet_threshold(afe_handle, model_index); // reset threshold to default 58 | ``` 59 | 60 | **Note**: This API is supported from esp-sr v2.1.3 -------------------------------------------------------------------------------- /examples/wake_word_detection/afe/README_cn.md: -------------------------------------------------------------------------------- 1 | # 唤醒词检测 [[English]](./README.md) 2 | 3 | (参考在上一级的 `examples` 目录下的 [README.md](../README.md) 文件来获取更多信息。) 4 | 5 | | Supported Targets | ESP32 | ESP32-S3 | ESP32-P4 | 6 | | ----------------- | -------- | -------- | -------- | 7 | 8 | 该示例用于展示如何使用 WakeNet 进行唤醒词检测。示例支持同时加载多个 wakenet 模型,但最多选择两个模型进行识别。 9 | 10 | ### 编译和烧写 11 | 12 | 开发板和唤醒词配置 13 | 14 | ``` 15 | idf.py set-target esp32s3 16 | idf.py menuconfig 17 | 18 | # 选择开发板 19 | Audio Media HAL -> Audio hardware board -> ESP32-S3-Korvo-1 20 | 21 | # 加载一个唤醒词 22 | ESP Speech Recognition -> Select wake words -> Hi,Lexin (wn9_hilexin) 23 | 24 | # 加载多个唤醒词 25 | ESP Speech Recognition -> Select wake words -> Hi,Lexin (wn9_hilexin) -> Load Multiple Wake Words 26 | ESP Speech Recognition -> Load Multiple Wake Words -> Hi,Lexin (wn9_hilexin) 27 | -> Hi,ESP (wn9_hiesp) 28 | ``` 29 | 30 | 31 | 编译并烧写,然后运行终端监控查看打印: 32 | 33 | ``` 34 | idf.py flash monitor 35 | ``` 36 | 37 | (退出窗口,请键入 ``Ctrl-]``.) 38 | 39 | 参考 [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/stable/get-started-cmake/index.html) 来获取更多使用 ESP-IDF 编译项目的细节. 40 | 41 | 42 | ### 修改检测阈值 43 | 44 | 默认的检测阈值定义在 `_MODEL_INFO_` 文件中,创建模型时将打印该阈值。 45 | 46 | 比如,[`wakenet9_v1h24_嗨,乐鑫_3_0.608_0.615`](https://github.com/espressif/esp-sr/blob/master/model/wakenet_model/wn9_hilexin/_MODEL_INFO_) 的检测阈值范围是 0.608 到 0.615。 47 | 有两种修改方式: 48 | 49 | - 修改 `_MODEL_INFO_` 文件 50 | 51 | - 在代码中修改 52 | ``` 53 | afe_handle->set_wakenet_threshold(afe_handle, model_index, threshold); // currently AFE support to load two model. model_index is 1 or 2 54 | afe_handle->reset_wakenet_threshold(afe_handle, model_index); // reset threshold to default 55 | ``` 56 | 57 | **注意**:以下API在esp-sr v2.1.3及以后才支持 58 | -------------------------------------------------------------------------------- /examples/wake_word_detection/afe/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(requires 2 | hardware_driver 3 | player 4 | ) 5 | 6 | idf_component_register(SRCS main.c 7 | REQUIRES ${requires}) 8 | 9 | -------------------------------------------------------------------------------- /examples/wake_word_detection/afe/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-sr: "^2.1.3" 3 | -------------------------------------------------------------------------------- /examples/wake_word_detection/afe/main/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | This example code is in the Public Domain (or CC0 licensed, at your option.) 3 | 4 | Unless required by applicable law or agreed to in writing, this 5 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 6 | CONDITIONS OF ANY KIND, either express or implied. 7 | */ 8 | #include 9 | #include 10 | #include "freertos/FreeRTOS.h" 11 | #include "freertos/task.h" 12 | #include "esp_wn_iface.h" 13 | #include "esp_wn_models.h" 14 | #include "esp_afe_sr_models.h" 15 | #include "esp_mn_iface.h" 16 | #include "esp_mn_models.h" 17 | #include "esp_board_init.h" 18 | #include "model_path.h" 19 | #include "string.h" 20 | 21 | int detect_flag = 0; 22 | static esp_afe_sr_iface_t *afe_handle = NULL; 23 | static volatile int task_flag = 0; 24 | 25 | void feed_Task(void *arg) 26 | { 27 | esp_afe_sr_data_t *afe_data = arg; 28 | int audio_chunksize = afe_handle->get_feed_chunksize(afe_data); 29 | int nch = afe_handle->get_feed_channel_num(afe_data); 30 | int feed_channel = esp_get_feed_channel(); 31 | assert(nch==feed_channel); 32 | int16_t *i2s_buff = malloc(audio_chunksize * sizeof(int16_t) * feed_channel); 33 | assert(i2s_buff); 34 | 35 | while (task_flag) { 36 | esp_get_feed_data(true, i2s_buff, audio_chunksize * sizeof(int16_t) * feed_channel); 37 | 38 | afe_handle->feed(afe_data, i2s_buff); 39 | } 40 | if (i2s_buff) { 41 | free(i2s_buff); 42 | i2s_buff = NULL; 43 | } 44 | vTaskDelete(NULL); 45 | } 46 | 47 | void detect_Task(void *arg) 48 | { 49 | esp_afe_sr_data_t *afe_data = arg; 50 | int afe_chunksize = afe_handle->get_fetch_chunksize(afe_data); 51 | int16_t *buff = malloc(afe_chunksize * sizeof(int16_t)); 52 | assert(buff); 53 | printf("------------detect start------------\n"); 54 | 55 | // modify wakenet detection threshold 56 | afe_handle->set_wakenet_threshold(afe_data, 1, 0.6); // set model1's threshold to 0.6 57 | afe_handle->set_wakenet_threshold(afe_data, 2, 0.6); // set model2's threshold to 0.6 58 | afe_handle->reset_wakenet_threshold(afe_data, 1); // reset model1's threshold to default 59 | afe_handle->reset_wakenet_threshold(afe_data, 2); // reset model2's threshold to default 60 | 61 | while (task_flag) { 62 | afe_fetch_result_t* res = afe_handle->fetch(afe_data); 63 | if (!res || res->ret_value == ESP_FAIL) { 64 | printf("fetch error!\n"); 65 | break; 66 | } 67 | // printf("vad state: %d\n", res->vad_state); 68 | 69 | if (res->wakeup_state == WAKENET_DETECTED) { 70 | printf("wakeword detected\n"); 71 | printf("model index:%d, word index:%d\n", res->wakenet_model_index, res->wake_word_index); 72 | printf("-----------LISTENING-----------\n"); 73 | } 74 | } 75 | if (buff) { 76 | free(buff); 77 | buff = NULL; 78 | } 79 | vTaskDelete(NULL); 80 | } 81 | 82 | void app_main() 83 | { 84 | ESP_ERROR_CHECK(esp_board_init(16000, 1, 16)); 85 | // ESP_ERROR_CHECK(esp_sdcard_init("/sdcard", 10)); 86 | 87 | srmodel_list_t *models = esp_srmodel_init("model"); 88 | if (models) { 89 | for (int i=0; inum; i++) { 90 | if (strstr(models->model_name[i], ESP_WN_PREFIX) != NULL) { 91 | printf("wakenet model in flash: %s\n", models->model_name[i]); 92 | } 93 | } 94 | } 95 | 96 | afe_config_t *afe_config = afe_config_init(esp_get_input_format(), models, AFE_TYPE_SR, AFE_MODE_LOW_COST); 97 | 98 | // print/modify wake word model. 99 | if (afe_config->wakenet_model_name) { 100 | printf("wakeword model in AFE config: %s\n", afe_config->wakenet_model_name); 101 | } 102 | if (afe_config->wakenet_model_name_2) { 103 | printf("wakeword model in AFE config: %s\n", afe_config->wakenet_model_name_2); 104 | } 105 | 106 | afe_handle = esp_afe_handle_from_config(afe_config); 107 | esp_afe_sr_data_t *afe_data = afe_handle->create_from_config(afe_config); 108 | 109 | 110 | // 111 | afe_config_free(afe_config); 112 | 113 | task_flag = 1; 114 | xTaskCreatePinnedToCore(&feed_Task, "feed", 8 * 1024, (void*)afe_data, 5, NULL, 0); 115 | xTaskCreatePinnedToCore(&detect_Task, "detect", 4 * 1024, (void*)afe_data, 5, NULL, 1); 116 | } 117 | -------------------------------------------------------------------------------- /examples/wake_word_detection/afe/partitions.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 2500k 4 | model, data, spiffs, , 5168K, 5 | -------------------------------------------------------------------------------- /examples/wake_word_detection/afe/partitions_esp32.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 5120k -------------------------------------------------------------------------------- /examples/wake_word_detection/afe/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_CUSTOM=y 2 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 3 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 4 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 5 | -------------------------------------------------------------------------------- /examples/wake_word_detection/afe/sdkconfig.defaults.esp32: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 5 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_PARTITION_TABLE_CUSTOM=y 8 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_esp32.csv" 9 | CONFIG_SPIRAM=y 10 | CONFIG_SPIRAM_SPEED_80M=y 11 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 12 | -------------------------------------------------------------------------------- /examples/wake_word_detection/afe/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32p4" 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 8 | CONFIG_SR_WN_WN9_HILEXIN=y 9 | CONFIG_CACHE_L2_CACHE_256KB=y 10 | CONFIG_CACHE_L2_CACHE_LINE_128B=y 11 | CONFIG_SPIRAM=y 12 | CONFIG_SPIRAM_SPEED_200M=y 13 | CONFIG_CACHE_L2_CACHE_256KB=y 14 | CONFIG_CACHE_L2_CACHE_LINE_128B=y 15 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y -------------------------------------------------------------------------------- /examples/wake_word_detection/afe/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32s3" 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_PARTITION_TABLE_CUSTOM=y 8 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 9 | CONFIG_SR_WN_WN9_HILEXIN=y 10 | CONFIG_SPIRAM=y 11 | CONFIG_SPIRAM_MODE_OCT=y 12 | CONFIG_SPIRAM_SPEED_80M=y 13 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 14 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 15 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 16 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 17 | -------------------------------------------------------------------------------- /examples/wake_word_detection/wakenet/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(EXTRA_COMPONENT_DIRS 4 | ../../../components 5 | ) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(wake_word_detection) 9 | -------------------------------------------------------------------------------- /examples/wake_word_detection/wakenet/README.md: -------------------------------------------------------------------------------- 1 | # Wake Word Detection 2 | 3 | | Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-P4 | ESP32-C3 | ESP32-C5 | ESP32-C6 | 4 | | ----------------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | 5 | 6 | (See the [README.md](../README.md) file in the upper level 'examples' directory for more information about examples.) 7 | 8 | This example is used to test performance of wakenet.(the word word engine of Espressif). 9 | This example can load multiple models, but can only run two models at the same time 10 | 11 | 12 | ### Configure 13 | 14 | Select board and wake words 15 | ``` 16 | idf.py set-target esp32s3 17 | idf.py menuconfig 18 | 19 | # Select audio board 20 | Audio Media HAL -> Audio hardware board -> ESP32-S3-Korvo-1 21 | 22 | # Load one wakenet model 23 | ESP Speech Recognition -> Select wake words -> Hi,Lexin (wn9_hilexin) 24 | 25 | # Load multiple wakenet models 26 | ESP Speech Recognition -> Select wake words -> Hi,Lexin (wn9_hilexin) -> Load Multiple Wake Words 27 | ESP Speech Recognition -> Load Multiple Wake Words -> Hi,Lexin (wn9_hilexin) 28 | -> Hi,ESP (wn9_hiesp) 29 | ``` 30 | 31 | ### build&flash 32 | 33 | Build the project and flash it to the board, then run the monitor tool to view the output via serial port: 34 | 35 | ``` 36 | idf.py flash monitor 37 | ``` 38 | 39 | (To exit the serial monitor, type ``Ctrl-]``.) 40 | 41 | 42 | -------------------------------------------------------------------------------- /examples/wake_word_detection/wakenet/README_cn.md: -------------------------------------------------------------------------------- 1 | # 唤醒词检测 [[English]](./README.md) 2 | 3 | (参考在上一级的 `examples` 目录下的 [README.md](../README.md) 文件来获取更多信息。) 4 | 5 | | Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-P4 | ESP32-C3 | ESP32-C5 | ESP32-C6 | 6 | | ----------------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | 7 | 8 | 该示例用于展示如何使用 WakeNet 进行唤醒词检测。示例支持同时加载多个 wakenet 模型,但最多选择两个模型进行识别。 9 | 10 | ### 编译和烧写 11 | 12 | 开发板和唤醒词配置 13 | 14 | ``` 15 | idf.py set-target esp32s3 16 | idf.py menuconfig 17 | 18 | # 选择开发板 19 | Audio Media HAL -> Audio hardware board -> ESP32-S3-Korvo-1 20 | 21 | # 加载一个唤醒词 22 | ESP Speech Recognition -> Select wake words -> Hi,Lexin (wn9_hilexin) 23 | 24 | # 加载多个唤醒词 25 | ESP Speech Recognition -> Select wake words -> Hi,Lexin (wn9_hilexin) -> Load Multiple Wake Words 26 | ESP Speech Recognition -> Load Multiple Wake Words -> Hi,Lexin (wn9_hilexin) 27 | -> Hi,ESP (wn9_hiesp) 28 | ``` 29 | 30 | 31 | 编译并烧写,然后运行终端监控查看打印: 32 | 33 | ``` 34 | idf.py flash monitor 35 | ``` 36 | 37 | (退出窗口,请键入 ``Ctrl-]``.) 38 | 39 | 参考 [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/stable/get-started-cmake/index.html) 来获取更多使用 ESP-IDF 编译项目的细节. 40 | -------------------------------------------------------------------------------- /examples/wake_word_detection/wakenet/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(requires 2 | hardware_driver 3 | player 4 | ) 5 | 6 | idf_component_register(SRCS main.c 7 | REQUIRES ${requires}) 8 | 9 | -------------------------------------------------------------------------------- /examples/wake_word_detection/wakenet/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-sr: "^2.1.0" 3 | -------------------------------------------------------------------------------- /examples/wake_word_detection/wakenet/main/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | This example code is in the Public Domain (or CC0 licensed, at your option.) 3 | 4 | Unless required by applicable law or agreed to in writing, this 5 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 6 | CONDITIONS OF ANY KIND, either express or implied. 7 | */ 8 | #include 9 | #include 10 | #include "freertos/FreeRTOS.h" 11 | #include "freertos/task.h" 12 | #include "esp_wn_iface.h" 13 | #include "esp_wn_models.h" 14 | #include "model_path.h" 15 | #include "string.h" 16 | #include "hiesp.h" 17 | #include "hilexin.h" 18 | 19 | void app_main(void *arg) 20 | { 21 | srmodel_list_t *models = esp_srmodel_init("model"); 22 | char *model_name = esp_srmodel_filter(models, ESP_WN_PREFIX, "hilexin"); 23 | esp_wn_iface_t *wakenet = (esp_wn_iface_t*)esp_wn_handle_from_name(model_name); 24 | model_iface_data_t *model_data = wakenet->create(model_name, DET_MODE_95); 25 | 26 | int audio_chunksize = wakenet->get_samp_chunksize(model_data) * sizeof(int16_t); 27 | int16_t *buffer = (int16_t *) malloc(audio_chunksize); 28 | unsigned char* data = NULL; 29 | size_t data_size = 0; 30 | int chunks = 0; 31 | if (strstr(model_name, "hiesp") != NULL) { 32 | data = (unsigned char*)hiesp; 33 | data_size = sizeof(hiesp); 34 | printf("wake word: %s, size:%d\n", "hiesp", data_size); 35 | } else if(strstr(model_name, "hilexin") != NULL) { 36 | data = (unsigned char*)hilexin; 37 | data_size = sizeof(hilexin); 38 | printf("wake word: %s, size:%d\n", "hilexin", data_size); 39 | } 40 | 41 | while (1) { 42 | if ((chunks + 1)*audio_chunksize <= data_size) { 43 | memcpy(buffer, data + chunks * audio_chunksize, audio_chunksize); 44 | } else { 45 | break; 46 | } 47 | 48 | wakenet_state_t state = wakenet->detect(model_data, buffer); 49 | if (state == WAKENET_DETECTED) { 50 | printf("Detected\n"); 51 | } 52 | chunks ++; 53 | } 54 | 55 | wakenet->destroy(model_data); 56 | vTaskDelete(NULL); 57 | } 58 | 59 | -------------------------------------------------------------------------------- /examples/wake_word_detection/wakenet/partitions.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 1000k 4 | model, data, spiffs, , 600K, 5 | -------------------------------------------------------------------------------- /examples/wake_word_detection/wakenet/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.4.1 Project Minimal Configuration 3 | # 4 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 5 | CONFIG_PARTITION_TABLE_CUSTOM=y 6 | CONFIG_SR_WN_WN9S_HILEXIN=y 7 | CONFIG_SR_WN_WN9S_HIESP=y 8 | -------------------------------------------------------------------------------- /examples/wake_word_detection/wakenet/sdkconfig.defaults.esp32: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 5 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_PARTITION_TABLE_CUSTOM=y 8 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 9 | CONFIG_SPIRAM=y 10 | CONFIG_SPIRAM_SPEED_80M=y 11 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 12 | CONFIG_SR_WN_WN9_HILEXIN=y -------------------------------------------------------------------------------- /examples/wake_word_detection/wakenet/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32p4" 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 8 | CONFIG_SR_WN_WN9_HILEXIN=y 9 | CONFIG_CACHE_L2_CACHE_256KB=y 10 | CONFIG_CACHE_L2_CACHE_LINE_128B=y 11 | CONFIG_SPIRAM=y 12 | CONFIG_SPIRAM_SPEED_200M=y 13 | CONFIG_CACHE_L2_CACHE_256KB=y 14 | CONFIG_CACHE_L2_CACHE_LINE_128B=y 15 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y -------------------------------------------------------------------------------- /examples/wake_word_detection/wakenet/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32s3" 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_PARTITION_TABLE_CUSTOM=y 8 | CONFIG_SR_VADN_VADNET1_MEDIUM=y 9 | CONFIG_SR_WN_WN9_HILEXIN=y 10 | CONFIG_SPIRAM=y 11 | CONFIG_SPIRAM_MODE_OCT=y 12 | CONFIG_SPIRAM_SPEED_80M=y 13 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 14 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 15 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 16 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 17 | -------------------------------------------------------------------------------- /img/MicNode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/img/MicNode.png -------------------------------------------------------------------------------- /img/audio_boards.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/img/audio_boards.png -------------------------------------------------------------------------------- /img/esp_afe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/img/esp_afe.png -------------------------------------------------------------------------------- /img/skainet_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/img/skainet_overview.png -------------------------------------------------------------------------------- /img/skainet_overview2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/img/skainet_overview2.png -------------------------------------------------------------------------------- /img/specch_commands_config1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/img/specch_commands_config1.png -------------------------------------------------------------------------------- /img/specch_commands_config2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/img/specch_commands_config2.png -------------------------------------------------------------------------------- /img/speechs_commands_workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/img/speechs_commands_workflow.png -------------------------------------------------------------------------------- /pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | # exclude examples/ota/simple_ota_example/pytest_simple_ota.py 3 | norecursedirs = examples/ota/* 4 | # only the files with prefix `pytest_` would be recognized as pytest test scripts. 5 | python_files = pytest_*.py 6 | 7 | # set traceback to "short" to prevent the overwhelming tracebacks 8 | addopts = 9 | -s 10 | --embedded-services esp,idf 11 | --tb short 12 | --skip-check-coredump y 13 | 14 | # ignore PytestExperimentalApiWarning for record_xml_attribute 15 | filterwarnings = 16 | ignore::_pytest.warning_types.PytestExperimentalApiWarning 17 | 18 | 19 | markers = 20 | # target markers 21 | target: target chip name (--target) 22 | # env markers 23 | env: target test env name (--env) 24 | # config markers 25 | config: choose specific bins built by `sdkconfig.ci.` 26 | # app_path markers 27 | app_path: choose specific app_path, [/build_xxx] 28 | 29 | 30 | # log related 31 | log_cli = True 32 | log_cli_level = INFO 33 | log_cli_format = %(asctime)s %(levelname)s %(message)s 34 | log_cli_date_format = %Y-%m-%d %H:%M:%S 35 | 36 | # junit related 37 | junit_family = xunit1 38 | 39 | 40 | ## log all to `system-out` when case fail 41 | junit_logging = stdout 42 | junit_log_passing_tests = False 43 | -------------------------------------------------------------------------------- /test/.build-rules.yml: -------------------------------------------------------------------------------- 1 | test/wakenet: 2 | enable: 3 | - if: IDF_TARGET in ["esp32s3"] 4 | temporary: false -------------------------------------------------------------------------------- /test/README.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | This part is used to test the performance of esp-skainet, include wakenet, multinet and AFE modules. 4 | 5 | ## Get Started 6 | 7 | ## 1. record test set 8 | Please refer to [test/record_test_set](./record_test_set/README.md) to record your test case. 9 | 10 | ## 2. build test app and run all test set 11 | Please refer to [test/wakenet](./wakenet/README.md) to run test cases. 12 | 13 | 14 | 15 | ## How to use it in CI 16 | ### 1. build all test app 17 | ``` 18 | pip install -r tools/ci/requirement.txt 19 | 20 | python tools/ci/build_apps.py ./test -t esp32s3 -vv 21 | ``` 22 | 23 | This script will build all apps in the `esp-skainet/test`, and generate different bins according to different sdkconfig.ci.***. 24 | For example, there are `sdkconfig.ci.hilexin` and `sdkconfig.ci.hiesp` in `esp-skainet/test/wakenet`. So after running the above script, `esp-skainet/test/wakenet/IDF_VERSION/build_esp32s3_hilexin` and `esp-skainet/test/wakenet/IDF_VERSION/build_esp32s3_hiesp` will be generated. IDF_VERSION is your idf verison. 25 | 26 | build rules are determined in `esp-skainet/test/.build-relus.yml`. You can modify this yaml file to set which targets should be build. 27 | 28 | ### 2. run and report 29 | 30 | ``` 31 | # test wakenet performance 32 | 33 | pytest ./test/wakenet --target esp32s3 --config hilexin --noise all|pink|pub|none --snr all|0|5 34 | ``` 35 | The test report will be generated in `./pytest_log/`. 36 | 37 | ## How to add a test case 38 | 39 | ### 1. record test set 40 | Please refer to esp-skainet/tools/record_test_set to record your test case. 41 | ### 2. add a test app 42 | Please refer to esp-skainet/test/wakenet to add your test app. 43 | 44 | ### 3. add a pytest script 45 | Please refer to esp-skainet/test/wakenet/pytest_wakenet.py to add your pytest script. 46 | The more details about pytest you can find [here](https://espressif-docs.readthedocs-hosted.com/projects/pytest-embedded/en/latest/index.html). 47 | ### 4. add a ci pipeline 48 | Please refer to the following template to add your test case in .gitlab-ci.yml: 49 | ``` 50 | test_wakenet: 51 | extends: 52 | - .pytest_template 53 | needs: 54 | - job: "build_all_tests" 55 | artifacts: true 56 | optional: true 57 | tags: 58 | - 'korvo-2' 59 | image: $DOCKER_TARGET_TEST_v5_0_ENV_IMAGE 60 | variables: 61 | TEST_TARGET: 'esp32s3' 62 | TEST_FOLDER: './test/wakenet' 63 | TEST_ENV: 'korvo-2' 64 | IDF_VERSION: "5.0" 65 | ``` -------------------------------------------------------------------------------- /test/multinet/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(EXTRA_COMPONENT_DIRS 4 | ../../components 5 | ) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(multinet) 9 | -------------------------------------------------------------------------------- /test/multinet/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(srcs 2 | multinet_main.c 3 | ) 4 | 5 | set(requires 6 | perf_tester 7 | ) 8 | 9 | idf_component_register(SRCS ${srcs} 10 | INCLUDE_DIRS . 11 | REQUIRES ${requires}) 12 | 13 | -------------------------------------------------------------------------------- /test/multinet/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-sr: "==1.5.1" 3 | -------------------------------------------------------------------------------- /test/multinet/main/multinet_main.c: -------------------------------------------------------------------------------- 1 | #include "mn_perf_tester.h" 2 | #include "model_path.h" 3 | #include "esp_board_init.h" 4 | #include "esp_mn_speech_commands.h" 5 | #include "esp_process_sdkconfig.h" 6 | 7 | static int start_multinet_test(int argc, char **argv) 8 | { 9 | printf("Start to test MultiNet:\n"); 10 | 11 | srmodel_list_t *models = esp_srmodel_init("model"); 12 | char *wn_name = esp_srmodel_filter(models, ESP_WN_PREFIX, NULL); 13 | char *mn_name = esp_srmodel_filter(models, ESP_MN_PREFIX, NULL); 14 | char csv_file[128]; 15 | char log_file[128]; 16 | sprintf(csv_file, "/sdcard/%s.csv", mn_name); 17 | sprintf(log_file, "/sdcard/%s.log", mn_name); 18 | printf("test:%s, log:%s\n", csv_file, log_file); 19 | 20 | // Select speech enhancement pipeline 21 | afe_config_t afe_config = AFE_CONFIG_DEFAULT(); 22 | afe_config.wakenet_model_name = wn_name; 23 | afe_config.wakenet_mode = DET_MODE_3CH_90; 24 | 25 | // Multinet 26 | esp_mn_iface_t *multinet = esp_mn_handle_from_name(mn_name); 27 | 28 | perf_tester_config_t *tester_config = get_perf_tester_config(); 29 | offline_mn_tester(csv_file, log_file, &ESP_AFE_SR_HANDLE, &afe_config, 30 | multinet, mn_name, TESTER_WAV_3CH, tester_config); 31 | return 0; 32 | } 33 | 34 | void app_main() 35 | { 36 | ESP_ERROR_CHECK(esp_board_init(16000, 1, 16)); 37 | ESP_ERROR_CHECK(esp_sdcard_init("/sdcard", 10)); 38 | heap_caps_print_heap_info(MALLOC_CAP_8BIT); 39 | 40 | // Init console repl 41 | esp_console_repl_t *repl = NULL; 42 | esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT(); 43 | repl_config.prompt = "perf_tester>"; 44 | esp_console_dev_uart_config_t uart_config = ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT(); 45 | ESP_ERROR_CHECK(esp_console_new_repl_uart(&uart_config, &repl_config, &repl)); 46 | 47 | // Register cmd 48 | esp_console_register_help_command(); 49 | register_perf_tester_config_cmd(); 50 | register_perf_tester_start_cmd(&start_multinet_test); 51 | 52 | // Start console repl 53 | ESP_ERROR_CHECK(esp_console_start_repl(repl)); 54 | } -------------------------------------------------------------------------------- /test/multinet/partitions.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 2500k 4 | model, data, spiffs, , 5168K, 5 | -------------------------------------------------------------------------------- /test/multinet/sdkconfig.ci.hiesp_mn6_en: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_TARGET="esp32s3" 2 | CONFIG_IDF_TARGET_ESP32S3=y 3 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 4 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 5 | CONFIG_PARTITION_TABLE_CUSTOM=y 6 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 7 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 8 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 9 | CONFIG_ESP32_S3_KORVO_2_V3_0_BOARD=y 10 | CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y 11 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 12 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 13 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 14 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 15 | CONFIG_SPIRAM_MODE_OCT=y 16 | CONFIG_SPIRAM_SPEED_80M=y 17 | # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set 18 | CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y 19 | # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set 20 | # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set 21 | # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set 22 | CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y 23 | CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y 24 | CONFIG_ESP_MAIN_TASK_STACK_SIZE=5000 25 | CONFIG_FATFS_LFN_HEAP=y 26 | 27 | CONFIG_MODEL_IN_SPIFFS=y 28 | # CONFIG_MODEL_IN_SDCARD is not set 29 | CONFIG_USE_WAKENET=y 30 | # CONFIG_SR_WN_WN9_HILEXIN is not set 31 | # CONFIG_SR_WN_WN9_XIAOAITONGXUE is not set 32 | # CONFIG_SR_WN_WN9_ALEXA is not set 33 | CONFIG_SR_WN_WN9_HIESP=y 34 | # CONFIG_SR_WN_WN9_NIHAOXIAOZHI is not set 35 | # CONFIG_SR_WN_WN9_CUSTOMWORD is not set 36 | # CONFIG_SR_WN_LOAD_MULIT_WORD is not set 37 | CONFIG_USE_MULTINET=y 38 | CONFIG_SR_MN_CN_NONE=y 39 | # CONFIG_SR_MN_CN_MULTINET6_QUANT is not set 40 | # CONFIG_SR_MN_CN_MULTINET6_AC_QUANT is not set 41 | # CONFIG_SR_MN_EN_NONE is not set 42 | CONFIG_SR_MN_EN_MULTINET6_QUANT=y 43 | # end of ESP Speech Recognition -------------------------------------------------------------------------------- /test/multinet/sdkconfig.ci.hiesp_mn7_en: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_TARGET="esp32s3" 2 | CONFIG_IDF_TARGET_ESP32S3=y 3 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 4 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 5 | CONFIG_PARTITION_TABLE_CUSTOM=y 6 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 7 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 8 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 9 | CONFIG_ESP32_S3_KORVO_2_V3_0_BOARD=y 10 | CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y 11 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 12 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 13 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 14 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 15 | CONFIG_SPIRAM_MODE_OCT=y 16 | CONFIG_SPIRAM_SPEED_80M=y 17 | # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set 18 | CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y 19 | # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set 20 | # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set 21 | # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set 22 | CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y 23 | CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y 24 | CONFIG_ESP_MAIN_TASK_STACK_SIZE=5000 25 | CONFIG_FATFS_LFN_HEAP=y 26 | 27 | CONFIG_MODEL_IN_SPIFFS=y 28 | # CONFIG_MODEL_IN_SDCARD is not set 29 | CONFIG_USE_WAKENET=y 30 | # CONFIG_SR_WN_WN9_HILEXIN is not set 31 | # CONFIG_SR_WN_WN9_XIAOAITONGXUE is not set 32 | # CONFIG_SR_WN_WN9_ALEXA is not set 33 | CONFIG_SR_WN_WN9_HIESP=y 34 | # CONFIG_SR_WN_WN9_NIHAOXIAOZHI is not set 35 | # CONFIG_SR_WN_WN9_CUSTOMWORD is not set 36 | # CONFIG_SR_WN_LOAD_MULIT_WORD is not set 37 | CONFIG_USE_MULTINET=y 38 | CONFIG_SR_MN_CN_NONE=y 39 | # CONFIG_SR_MN_CN_MULTINET6_QUANT is not set 40 | # CONFIG_SR_MN_CN_MULTINET6_AC_QUANT is not set 41 | # CONFIG_SR_MN_EN_NONE is not set 42 | # CONFIG_SR_MN_EN_MULTINET6_QUANT is not set 43 | CONFIG_SR_MN_EN_MULTINET7_QUANT=y 44 | # end of ESP Speech Recognition -------------------------------------------------------------------------------- /test/multinet/sdkconfig.ci.hilexin_mn6_cn: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_TARGET="esp32s3" 2 | CONFIG_IDF_TARGET_ESP32S3=y 3 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 4 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 5 | CONFIG_PARTITION_TABLE_CUSTOM=y 6 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 7 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 8 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 9 | CONFIG_ESP32_S3_KORVO_2_V3_0_BOARD=y 10 | CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y 11 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 12 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 13 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 14 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 15 | CONFIG_SPIRAM_MODE_OCT=y 16 | CONFIG_SPIRAM_SPEED_80M=y 17 | # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set 18 | CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y 19 | # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set 20 | # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set 21 | # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set 22 | CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y 23 | CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y 24 | CONFIG_ESP_MAIN_TASK_STACK_SIZE=5000 25 | CONFIG_FATFS_LFN_HEAP=y 26 | 27 | CONFIG_MODEL_IN_SPIFFS=y 28 | # CONFIG_MODEL_IN_SDCARD is not set 29 | CONFIG_USE_WAKENET=y 30 | CONFIG_SR_WN_WN9_HILEXIN=y 31 | # CONFIG_SR_WN_WN9_XIAOAITONGXUE is not set 32 | # CONFIG_SR_WN_WN9_ALEXA is not set 33 | # CONFIG_SR_WN_WN9_HIESP is not set 34 | # CONFIG_SR_WN_WN9_NIHAOXIAOZHI is not set 35 | # CONFIG_SR_WN_WN9_CUSTOMWORD is not set 36 | # CONFIG_SR_WN_LOAD_MULIT_WORD is not set 37 | CONFIG_USE_MULTINET=y 38 | CONFIG_SR_MN_CN_MULTINET6_QUANT=y 39 | # CONFIG_SR_MN_CN_MULTINET6_AC_QUANT is not set 40 | CONFIG_SR_MN_EN_NONE=y 41 | # CONFIG_SR_MN_EN_MULTINET6_QUANT is not set 42 | # end of ESP Speech Recognition -------------------------------------------------------------------------------- /test/multinet/sdkconfig.ci.hilexin_mn6_cn_ac: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_TARGET="esp32s3" 2 | CONFIG_IDF_TARGET_ESP32S3=y 3 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 4 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 5 | CONFIG_PARTITION_TABLE_CUSTOM=y 6 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 7 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 8 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 9 | CONFIG_ESP32_S3_KORVO_2_V3_0_BOARD=y 10 | CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y 11 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 12 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 13 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 14 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 15 | CONFIG_SPIRAM_MODE_OCT=y 16 | CONFIG_SPIRAM_SPEED_80M=y 17 | # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set 18 | CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y 19 | # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set 20 | # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set 21 | # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set 22 | CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y 23 | CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y 24 | CONFIG_ESP_MAIN_TASK_STACK_SIZE=5000 25 | CONFIG_FATFS_LFN_HEAP=y 26 | 27 | CONFIG_MODEL_IN_SPIFFS=y 28 | # CONFIG_MODEL_IN_SDCARD is not set 29 | CONFIG_USE_WAKENET=y 30 | CONFIG_SR_WN_WN9_HILEXIN=y 31 | # CONFIG_SR_WN_WN9_XIAOAITONGXUE is not set 32 | # CONFIG_SR_WN_WN9_ALEXA is not set 33 | # CONFIG_SR_WN_WN9_HIESP is not set 34 | # CONFIG_SR_WN_WN9_NIHAOXIAOZHI is not set 35 | # CONFIG_SR_WN_WN9_CUSTOMWORD is not set 36 | # CONFIG_SR_WN_LOAD_MULIT_WORD is not set 37 | CONFIG_USE_MULTINET=y 38 | # CONFIG_SR_MN_CN_MULTINET6_QUANT is not set 39 | CONFIG_SR_MN_CN_MULTINET6_AC_QUANT=y 40 | CONFIG_SR_MN_EN_NONE=y 41 | # CONFIG_SR_MN_EN_MULTINET6_QUANT is not set 42 | # end of ESP Speech Recognition -------------------------------------------------------------------------------- /test/multinet/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_TARGET="esp32s3" 2 | CONFIG_IDF_TARGET_ESP32S3=y 3 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 4 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 5 | CONFIG_PARTITION_TABLE_CUSTOM=y 6 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 7 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 8 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 9 | CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y 10 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 11 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 12 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 13 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 14 | CONFIG_SPIRAM_MODE_OCT=y 15 | CONFIG_SPIRAM_SPEED_80M=y 16 | # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set 17 | CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y 18 | # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set 19 | # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set 20 | # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set 21 | CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y 22 | CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y 23 | CONFIG_ESP_MAIN_TASK_STACK_SIZE=5000 24 | CONFIG_FATFS_LFN_HEAP=y 25 | 26 | CONFIG_MODEL_IN_SPIFFS=y 27 | # CONFIG_MODEL_IN_SDCARD is not set 28 | CONFIG_USE_WAKENET=y 29 | CONFIG_SR_WN_WN9_HILEXIN=y 30 | # CONFIG_SR_WN_WN9_XIAOAITONGXUE is not set 31 | # CONFIG_SR_WN_WN9_ALEXA is not set 32 | # CONFIG_SR_WN_WN9_HIESP is not set 33 | # CONFIG_SR_WN_WN9_NIHAOXIAOZHI is not set 34 | # CONFIG_SR_WN_WN9_CUSTOMWORD is not set 35 | # CONFIG_SR_WN_LOAD_MULIT_WORD is not set 36 | CONFIG_USE_MULTINET=y 37 | CONFIG_SR_MN_CN_NONE=y 38 | # CONFIG_SR_MN_CN_MULTINET6_QUANT is not set 39 | # CONFIG_SR_MN_CN_MULTINET6_AC_QUANT is not set 40 | # CONFIG_SR_MN_EN_NONE is not set 41 | # CONFIG_SR_MN_EN_MULTINET6_QUANT is not set 42 | # end of ESP Speech Recognition -------------------------------------------------------------------------------- /test/record_test_set/config.yml: -------------------------------------------------------------------------------- 1 | clean_set: 2 | paths: 3 | - "./data/wake_words/hey_lepro" 4 | normalization: true 5 | target_dB: -36 6 | music_set: 7 | paths: 8 | - "./data/music_set" 9 | normalization: true 10 | target_dB: -20 11 | noise_set: 12 | paths: 13 | - "./data/noise_set/silence" 14 | - "./data/noise_set/pink" 15 | - "./data/noise_set/pub" 16 | - "./data/noise_set/news" 17 | - "./data/noise_set/cooking" 18 | - "./data/noise_set/washing" 19 | normalization: true 20 | target_dB: -36 21 | output_set: 22 | path: "./data/output_set" 23 | overwrite: false 24 | noise_snr: 25 | - snr_dB: 10 26 | clean_gain_dB: 0 27 | - snr_dB: 5 28 | clean_gain_dB: 0 29 | - snr_dB: 0 30 | clean_gain_dB: 5 31 | playback_snr: 32 | - snr_dB: -10 33 | clean_gain_dB: 0 34 | - snr_dB: 0 35 | clean_gain_dB: 10 36 | 37 | player: 38 | play_output: true -------------------------------------------------------------------------------- /test/record_test_set/config_mn.yml: -------------------------------------------------------------------------------- 1 | clean_set: 2 | wake_words_paths: 3 | # - "/home/projects/pipeline-test/hiesp" 4 | - "/home/projects/pipeline-test/hilexin" 5 | commands_paths: 6 | # - "/home/projects/pipeline-test/clean_norm" 7 | - "/home/projects/pipeline-test/CN-TEST-S" 8 | filelists_paths: 9 | # - "/home/projects/pipeline-test/en_test.json" 10 | - "/home/projects/pipeline-test/cn_test.json" 11 | normalization: True 12 | target_dB: -36 13 | noise_set: 14 | paths: 15 | - "/home/datasets/_noise_korvo" 16 | normalization: True 17 | target_dB: -36 18 | output_set: 19 | path: "/home/datasets/pipeline-test/test" 20 | remove_old_files: true 21 | snr: 22 | - snr_dB: 10 23 | clean_gain_dB: 0 24 | - snr_dB: 5 25 | clean_gain_dB: 0 26 | - snr_dB: 0 27 | clean_gain_dB: 5 28 | player: 29 | play_output: true 30 | -------------------------------------------------------------------------------- /test/record_test_set/create_mn_test_json.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | # This Python script is an example for creating the JSON file required by `create_mn_test_set.py` 4 | 5 | import argparse 6 | import json 7 | import random 8 | from pathlib import Path 9 | 10 | import torchaudio 11 | 12 | 13 | if __name__ == '__main__': 14 | parser = argparse.ArgumentParser() 15 | parser.add_argument( 16 | "--wake-word-dir", 17 | type=str, 18 | help="directory of wake word recordings" 19 | ) 20 | parser.add_argument( 21 | "--command-dir", 22 | type=str, 23 | help="directory of command recordings" 24 | ) 25 | parser.add_argument( 26 | "--out-file", 27 | type=str, 28 | help="output filename" 29 | ) 30 | args = parser.parse_args() 31 | 32 | wakewords = list(Path(args.wake_word_dir).glob("*.wav")) 33 | commands = list(Path(args.command_dir).glob("*.wav")) 34 | 35 | output = [] 36 | 37 | for wakeword in wakewords: 38 | data, sr = torchaudio.load(wakeword) 39 | assert sr == 16000, sr 40 | block = { 41 | "wake_word_fname": wakeword.name, 42 | "size": data.shape[1], 43 | "wake_word_tailing_silence_ms": 100, 44 | "commands": [], 45 | "between_command_length_ms": 5000, 46 | } 47 | num_command = random.randint(1, 5) 48 | block_commands = random.sample(commands, num_command) 49 | for command in block_commands: 50 | data, sr = torchaudio.load(wakeword) 51 | assert sr == 16000, sr 52 | block["commands"].append( 53 | { 54 | "command_fname": command.name, 55 | "size": data.shape[1] 56 | } 57 | ) 58 | output.append(block) 59 | 60 | with open(args.out_file, "wt") as f: 61 | json.dump(output, f) -------------------------------------------------------------------------------- /test/record_test_set/data/music_set/music_16k.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/music_set/music_16k.wav -------------------------------------------------------------------------------- /test/record_test_set/data/noise_set/cooking/cooking.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/noise_set/cooking/cooking.wav -------------------------------------------------------------------------------- /test/record_test_set/data/noise_set/news/NPRnews.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/noise_set/news/NPRnews.wav -------------------------------------------------------------------------------- /test/record_test_set/data/noise_set/pink/Pink.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/noise_set/pink/Pink.wav -------------------------------------------------------------------------------- /test/record_test_set/data/noise_set/pub/Pub.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/noise_set/pub/Pub.wav -------------------------------------------------------------------------------- /test/record_test_set/data/noise_set/rock/ETSIRock.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/noise_set/rock/ETSIRock.wav -------------------------------------------------------------------------------- /test/record_test_set/data/noise_set/silence/Silence_60s.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/noise_set/silence/Silence_60s.wav -------------------------------------------------------------------------------- /test/record_test_set/data/noise_set/washing/washingmachine.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/noise_set/washing/washingmachine.wav -------------------------------------------------------------------------------- /test/record_test_set/data/output_set/hilexin_0dB_pink_-10dB.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/output_set/hilexin_0dB_pink_-10dB.wav -------------------------------------------------------------------------------- /test/record_test_set/data/output_set/hilexin_0dB_silence_-10dB.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/output_set/hilexin_0dB_silence_-10dB.wav -------------------------------------------------------------------------------- /test/record_test_set/data/output_set/playback_hilexin_0dB.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/output_set/playback_hilexin_0dB.wav -------------------------------------------------------------------------------- /test/record_test_set/data/play_list.csv: -------------------------------------------------------------------------------- 1 | wav_filename,start,end 2 | ./data/output_set/hilexin_0dB_pink_-10dB.wav,1746775810.401411,1746775857.6376245 3 | ./data/output_set/playback_hilexin_0dB.wav,1746775867.6476395,1746775914.9096024 4 | ./data/output_set/hilexin_0dB_silence_-10dB.wav,1746775919.9115725,1746775967.039825 5 | -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hiesp/hiesp1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hiesp/hiesp1.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hiesp/hiesp10.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hiesp/hiesp10.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hiesp/hiesp2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hiesp/hiesp2.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hiesp/hiesp3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hiesp/hiesp3.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hiesp/hiesp4.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hiesp/hiesp4.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hiesp/hiesp5.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hiesp/hiesp5.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hiesp/hiesp6.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hiesp/hiesp6.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hiesp/hiesp7.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hiesp/hiesp7.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hiesp/hiesp8.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hiesp/hiesp8.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hiesp/hiesp9.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hiesp/hiesp9.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hilexin/hilexin1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hilexin/hilexin1.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hilexin/hilexin10.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hilexin/hilexin10.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hilexin/hilexin2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hilexin/hilexin2.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hilexin/hilexin3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hilexin/hilexin3.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hilexin/hilexin4.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hilexin/hilexin4.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hilexin/hilexin5.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hilexin/hilexin5.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hilexin/hilexin6.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hilexin/hilexin6.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hilexin/hilexin7.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hilexin/hilexin7.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hilexin/hilexin8.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hilexin/hilexin8.wav -------------------------------------------------------------------------------- /test/record_test_set/data/wake_words/hilexin/hilexin9.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/record_test_set/data/wake_words/hilexin/hilexin9.wav -------------------------------------------------------------------------------- /test/record_test_set/requirement.txt: -------------------------------------------------------------------------------- 1 | numpy<2.0.0 2 | pydub 3 | pyyaml 4 | pyserial 5 | playsound 6 | -------------------------------------------------------------------------------- /test/record_test_set/sdcard_recorder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(EXTRA_COMPONENT_DIRS 4 | ../../../components 5 | ) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(sdcard_recorder) 9 | -------------------------------------------------------------------------------- /test/record_test_set/sdcard_recorder/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(requires 2 | hardware_driver 3 | sr_ringbuf 4 | player 5 | ) 6 | 7 | idf_component_register(SRCS main.c uart.c 8 | INCLUDE_DIRS . 9 | REQUIRES ${requires}) 10 | 11 | add_definitions(-w) -------------------------------------------------------------------------------- /test/record_test_set/sdcard_recorder/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-sr: ">=2.0.0" 3 | -------------------------------------------------------------------------------- /test/record_test_set/sdcard_recorder/main/uart.c: -------------------------------------------------------------------------------- 1 | #include "uart.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "ringbuf.h" 12 | #include "esp_log.h" 13 | #include "driver/uart.h" 14 | #include "soc/uart_periph.h" 15 | #include "esp_idf_version.h" 16 | #include "esp_vfs_dev.h" 17 | #include "driver/uart_vfs.h" 18 | #define TAG "TTS_UART" 19 | 20 | void uart_read_task(void *arg) 21 | { 22 | ringbuf_handle_t uart_rb = (ringbuf_handle_t) arg; 23 | uart_config_t uart_config = { 24 | .baud_rate = 115200, 25 | .data_bits = UART_DATA_8_BITS, 26 | .parity = UART_PARITY_DISABLE, 27 | .stop_bits = UART_STOP_BITS_1, 28 | .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, 29 | #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) 30 | .source_clk = UART_SCLK_DEFAULT, 31 | #endif 32 | }; 33 | uart_param_config(UART_NUM_0, &uart_config); 34 | uart_driver_install(UART_NUM_0, 2*UART_BUF_LEN, 0, 0, NULL, 0); 35 | char data[UART_BUF_LEN]; 36 | int len=0; 37 | 38 | while (1) { 39 | int fd; 40 | 41 | if ((fd = open("/dev/uart/0", O_RDWR)) == -1) { 42 | ESP_LOGE(TAG, "Cannot open UART"); 43 | vTaskDelay(5000 / portTICK_PERIOD_MS); 44 | continue; 45 | } 46 | 47 | // We have a driver now installed so set up the read/write functions to use driver also. 48 | // esp_vfs_dev_uart_use_driver(0); 49 | uart_vfs_dev_use_driver(0); 50 | 51 | while (1) { 52 | int s; 53 | fd_set rfds; 54 | struct timeval tv = { 55 | .tv_sec = 5, 56 | .tv_usec = 0, 57 | }; 58 | 59 | FD_ZERO(&rfds); 60 | FD_SET(fd, &rfds); 61 | 62 | s = select(fd + 1, &rfds, NULL, NULL, &tv); 63 | 64 | if (s < 0) { 65 | ESP_LOGE(TAG, "Select failed: errno %d", errno); 66 | break; 67 | } else if (s == 0) { 68 | continue; 69 | } else { 70 | if (FD_ISSET(fd, &rfds)) { 71 | char buf; 72 | if (read(fd, &buf, 1) > 0) { 73 | rb_write(uart_rb, &buf, 1, portMAX_DELAY); 74 | 75 | if (buf=='\n') { 76 | data[len]='\0'; 77 | printf("uart input: %s\n", data); 78 | len=0; 79 | } else { 80 | data[len]=buf; 81 | len++; 82 | } 83 | // Note: Only one character was read even the buffer contains more. The other characters will 84 | // be read one-by-one by subsequent calls to select() which will then return immediately 85 | // without timeout. 86 | } else { 87 | ESP_LOGE(TAG, "UART read error"); 88 | break; 89 | } 90 | } else { 91 | ESP_LOGE(TAG, "No FD has been set in select()"); 92 | break; 93 | } 94 | } 95 | } 96 | 97 | close(fd); 98 | } 99 | 100 | vTaskDelete(NULL); 101 | } -------------------------------------------------------------------------------- /test/record_test_set/sdcard_recorder/main/uart.h: -------------------------------------------------------------------------------- 1 | #ifndef _TTS_URAT_H_ 2 | #define _TTS_URAT_H_ 3 | 4 | #define UART_BUF_LEN 1024 5 | void uart_read_task(void *arg); 6 | 7 | #endif -------------------------------------------------------------------------------- /test/record_test_set/sdcard_recorder/partitions.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 2500k 4 | model, data, spiffs, , 5168K, 5 | -------------------------------------------------------------------------------- /test/record_test_set/sdcard_recorder/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_TARGET="esp32s3" 2 | CONFIG_IDF_TARGET_ESP32S3=y 3 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 4 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 5 | CONFIG_PARTITION_TABLE_CUSTOM=y 6 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 7 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 8 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 9 | CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y 10 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 11 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 12 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 13 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 14 | CONFIG_SPIRAM_MODE_OCT=y 15 | CONFIG_SPIRAM_SPEED_80M=y 16 | # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set 17 | CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y 18 | # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set 19 | # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set 20 | # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set 21 | CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y 22 | CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y 23 | 24 | CONFIG_MODEL_IN_SPIFFS=y 25 | # CONFIG_MODEL_IN_SDCARD is not set 26 | CONFIG_USE_WAKENET=y 27 | CONFIG_SR_WN_MODEL_WN7_QUANT8=y 28 | CONFIG_SR_WN_WN7_HILEXIN=y 29 | # CONFIG_USE_MULTINET is not set 30 | CONFIG_FATFS_LFN_HEAP=y 31 | -------------------------------------------------------------------------------- /test/record_test_set/split_audio.py: -------------------------------------------------------------------------------- 1 | 2 | from fileinput import filename 3 | import os 4 | import time 5 | from pydub import AudioSegment 6 | from pydub.generators import Sine 7 | from playsound import playsound 8 | import csv 9 | import argparse 10 | import yaml 11 | import pandas 12 | import shutil 13 | import serial 14 | from serial.tools import list_ports 15 | import numpy as np 16 | import scipy 17 | import fnmatch 18 | from create_test_set import AudioTools 19 | 20 | 21 | def align_sine_wave(sine_wav=None, sine_freq=1000, sample_rate=16000, nfft=512): 22 | f,t,X = scipy.signal.stft(sine_wav, fs=sample_rate, nperseg=nfft, nfft=nfft) 23 | X = np.abs(X).transpose() 24 | sine_freq_index = int(sine_freq/sample_rate*nfft) 25 | sine_num = int((sample_rate-1000)/sine_freq/2) 26 | count = 0 27 | for idx, item in enumerate(X): 28 | energy = np.sum(item) + 1.0 29 | energy_sine = 0 30 | for i in range(sine_num): 31 | freq = sine_freq_index * (2 ** i) 32 | energy_sine += np.sum(item[freq-1:freq+2]) 33 | if energy_sine/energy > 0.5: 34 | count += 1 35 | else: 36 | count = 0 37 | 38 | if count > 10: 39 | idx = idx - 12 40 | return idx*16 41 | return None 42 | 43 | #split recording audio file by csv file 44 | def split_audio(input_path, output_path, sine_pos=2000, tail=100): 45 | os.makedirs(output_path, exist_ok=True) 46 | ratio = 1 + 800/555817 47 | 48 | for root, _, files in os.walk(input_path): 49 | for filename in fnmatch.filter(files,'*.wav'): 50 | wav_file = os.path.join(root, filename) 51 | csv_file = wav_file.replace('.wav', '.csv') 52 | if not os.path.exists(csv_file): 53 | print(f"{csv_file} not found") 54 | continue 55 | audio_data = AudioTools.read_audio_file(wav_file) 56 | file_data = pandas.read_csv(csv_file).values 57 | sine_time = align_sine_wave(audio_data.get_array_of_samples(), sine_freq=2000) 58 | offset = sine_time - sine_pos 59 | if sine_time == None: 60 | print(f"sine header not found in {wav_file}") 61 | continue 62 | print(filename, sine_time) 63 | 64 | for item in file_data: 65 | start = int((item[1] + offset - 32) * ratio) 66 | end = int((item[2] + offset + tail) * ratio) 67 | clip_data = audio_data[start:end] 68 | out_file = os.path.join(output_path, "record_"+item[0]) 69 | clip_data.export(out_file, format="wav") 70 | 71 | 72 | if __name__ == "__main__": 73 | 74 | parser = argparse.ArgumentParser() 75 | parser.add_argument( 76 | '-i', 77 | '--input_path', 78 | type=str, 79 | default=None, 80 | help='Input path of all speech samples' 81 | ) 82 | parser.add_argument( 83 | '-o', 84 | '--output_path', 85 | type=str, 86 | default='./data', 87 | help='Output path to save clips' 88 | ) 89 | 90 | args = parser.parse_args() 91 | split_audio(args.input_path, args.output_path) -------------------------------------------------------------------------------- /test/vad/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(EXTRA_COMPONENT_DIRS 4 | ../../components 5 | ) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(vad) 9 | -------------------------------------------------------------------------------- /test/vad/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(srcs 2 | main.c 3 | ) 4 | 5 | set(requires 6 | perf_tester 7 | ) 8 | 9 | idf_component_register(SRCS ${srcs} 10 | INCLUDE_DIRS . 11 | REQUIRES ${requires}) 12 | 13 | -------------------------------------------------------------------------------- /test/vad/main/main.c: -------------------------------------------------------------------------------- 1 | #include "mn_perf_tester.h" 2 | #include "model_path.h" 3 | #include "esp_board_init.h" 4 | #include "esp_process_sdkconfig.h" 5 | 6 | static int start_vad_test(int argc, char **argv) 7 | { 8 | printf("Start to test VAD:\n"); 9 | 10 | srmodel_list_t *models = esp_srmodel_init("model"); 11 | char *model_name = esp_srmodel_filter(models, "vadnet", NULL); 12 | char csv_file[128]; 13 | char log_file[128]; 14 | if (model_name == NULL) { 15 | sprintf(csv_file, "/sdcard/%s.csv", "webrtc_vad"); 16 | sprintf(log_file, "/sdcard/%s.log", "webrtc_vad"); 17 | } else { 18 | sprintf(csv_file, "/sdcard/%s.csv", "webrtc_vad"); 19 | sprintf(log_file, "/sdcard/%s.log", model_name); 20 | } 21 | printf("test:%s, log:%s\n", csv_file, log_file); 22 | 23 | // Select speech enhancement pipeline 24 | afe_config_t* afe_config = afe_config_init("MNN", models, AFE_TYPE_SR, AFE_MODE_HIGH_PERF); 25 | afe_config->vad_min_speech_ms = 32; 26 | afe_config->vad_min_noise_ms = 96; 27 | // afe_config->aec_init = false; 28 | // afe_config->se_init = false; 29 | // afe_config->ns_init = false; 30 | afe_config->vad_mode = VAD_MODE_1; 31 | // afe_config->vad_model_name = NULL; 32 | perf_tester_config_t *tester_config = get_perf_tester_config(); 33 | offline_vad_tester(csv_file, log_file, esp_afe_handle_from_config(afe_config), afe_config, 34 | TESTER_WAV_3CH, tester_config); 35 | return 0; 36 | } 37 | 38 | void app_main() 39 | { 40 | ESP_ERROR_CHECK(esp_board_init(16000, 1, 16)); 41 | ESP_ERROR_CHECK(esp_sdcard_init("/sdcard", 10)); 42 | heap_caps_print_heap_info(MALLOC_CAP_8BIT); 43 | 44 | // Init console repl 45 | esp_console_repl_t *repl = NULL; 46 | esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT(); 47 | repl_config.prompt = "perf_tester>"; 48 | esp_console_dev_uart_config_t uart_config = ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT(); 49 | ESP_ERROR_CHECK(esp_console_new_repl_uart(&uart_config, &repl_config, &repl)); 50 | 51 | // Register cmd 52 | esp_console_register_help_command(); 53 | register_perf_tester_config_cmd(); 54 | register_perf_tester_start_cmd(&start_vad_test); 55 | 56 | // Start console repl 57 | ESP_ERROR_CHECK(esp_console_start_repl(repl)); 58 | } -------------------------------------------------------------------------------- /test/vad/partitions.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 2500k 4 | model, data, spiffs, , 5168K, 5 | -------------------------------------------------------------------------------- /test/vad/python/libripaty.py: -------------------------------------------------------------------------------- 1 | import csv 2 | 3 | output_file = "output.csv" 4 | 5 | # Open the CSV file for writing 6 | with open(output_file, mode='w', newline='') as file: 7 | writer = csv.writer(file) 8 | 9 | # Write the header 10 | writer.writerow(["key_index", "start", "stop"]) 11 | 12 | # Iterate through the JSON data and write rows to the CSV file 13 | for key_index, entries in data.items(): 14 | for entry in entries: 15 | writer.writerow([key_index, entry["start"], entry["stop"]]) 16 | 17 | print(f"CSV file '{output_file}' has been created.") -------------------------------------------------------------------------------- /test/vad/sdkconfig.defaults: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/test/vad/sdkconfig.defaults -------------------------------------------------------------------------------- /test/vad/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.3.0 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32p4" 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_PARTITION_TABLE_CUSTOM=y 8 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 9 | CONFIG_MODEL_FILE_PATH="" 10 | CONFIG_COMPILER_OPTIMIZATION_PERF=y 11 | CONFIG_ESP32P4_REV_MIN_0=y 12 | CONFIG_SPIRAM=y 13 | CONFIG_SPIRAM_SPEED_200M=y 14 | CONFIG_CACHE_L2_CACHE_256KB=y 15 | CONFIG_CACHE_L2_CACHE_LINE_128B=y 16 | CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=n 17 | CONFIG_ESP_INT_WDT=n 18 | CONFIG_ESP_TASK_WDT_EN=n 19 | CONFIG_FREERTOS_HZ=1000 20 | CONFIG_MBEDTLS_CMAC_C=y 21 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y 22 | CONFIG_FATFS_LFN_HEAP=y 23 | -------------------------------------------------------------------------------- /test/vad/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_TARGET="esp32s3" 2 | CONFIG_IDF_TARGET_ESP32S3=y 3 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 4 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 5 | CONFIG_PARTITION_TABLE_CUSTOM=y 6 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 7 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 8 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 9 | CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y 10 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 11 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 12 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 13 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 14 | CONFIG_SPIRAM_MODE_OCT=y 15 | CONFIG_SPIRAM_SPEED_80M=y 16 | # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set 17 | CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y 18 | # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set 19 | # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set 20 | # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set 21 | CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y 22 | CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y 23 | 24 | CONFIG_USE_AFE=y 25 | CONFIG_AFE_INTERFACE_V1=y 26 | CONFIG_USE_WAKENET=y 27 | CONFIG_USE_MULTINET=n 28 | CONFIG_SR_WN_LOAD_MULIT_WORD=y 29 | 30 | # 31 | # Load Multiple Wake Words 32 | # 33 | CONFIG_SR_WN_WN9_HILEXIN_MULTI=y 34 | CONFIG_SR_WN_WN9_HIESP_MULTI=y 35 | CONFIG_FATFS_LFN_HEAP=y 36 | -------------------------------------------------------------------------------- /test/wakenet/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(EXTRA_COMPONENT_DIRS 4 | ../../components 5 | ) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(wakenet) 9 | -------------------------------------------------------------------------------- /test/wakenet/README.md: -------------------------------------------------------------------------------- 1 | # WakeNet Test Report Generation Guide 2 | 3 | This program automates the testing of recorded audio sets and generates comprehensive test reports for wake word detection performance. 4 | 5 | ## Test Preparation 6 | 7 | ### 1. Create RAR Test Set (Wake Word Detection Test) 8 | 9 | **File Format Requirements**: 10 | - CSV file containing test cases and pass criteria 11 | - Must be named `{wn_name}.csv` (where `wn_name` matches your wake word model name in `menuconfig`) 12 | - Store in the root directory of the SD card 13 | 14 | **File Structure Example**: 15 | ```csv 16 | filename,required,total 17 | /sdcard/hilexin_0dB_silence.wav,285,300 18 | /sdcard/hilexin_0dB_pub_-10dB.wav,270,300 19 | /sdcard/hilexin_0dB_pink_-10dB.wav,270,300 20 | /sdcard/hilexin_0dB_pub_-5dB.wav,270,300 21 | /sdcard/hilexin_0dB_pink_-5dB.wav,270,300 22 | /sdcard/hilexin_5dB_pub_5dB.wav,260,300 23 | /sdcard/hilexin_5dB_pink_5dB.wav,260,300 24 | ``` 25 | 26 | **Field Definitions**: 27 | | Field | Description | 28 | |----------|-------------| 29 | | filename | Full path to test audio file on SD card | 30 | | required | Minimum number of successful detections needed to pass (typically 85%-95% of total) | 31 | | total | Total number of wake word instances in the audio file | 32 | 33 | **Customization Note**: 34 | To use a different filename, modify the source file: 35 | [wakenet_main.c](./main/wakenet_main.c) 36 | 37 | --- 38 | 39 | ### 2. Prepare FAR Test Set (False Alarm Test) 40 | 41 | **General Requirements**: 42 | - Standardized test set for all wake word models 43 | - 48 hours of continuous audio data 44 | - Must be named `far_48h.csv` 45 | - Store in the root directory of the SD card 46 | 47 | **Audio Content Composition**: 48 | | Content Type | Duration | Description | 49 | |--------------|----------|-------------| 50 | | Chinese Speech | 22 hours | Various accents and speaking styles | 51 | | English Speech | 22 hours | Multiple dialects and pronunciations | 52 | | Music | 4 hours | Different genres and recording qualities | 53 | 54 | **File Preparation**: 55 | 1. Download the FAR test package 56 | 2. Extract contents to SD card root directory 57 | 3. Verify all files are properly transferred 58 | 59 | --- 60 | 61 | ## Setup and Execution 62 | 63 | ### 1. Hardware Preparation 64 | 1. Insert prepared SD card into the device 65 | 2. Ensure proper connection to host computer via USB 66 | 67 | ### 2. Build and Flash Firmware 68 | ```bash 69 | # Build and flash the program 70 | idf.py flash monitor 71 | 72 | # For first-time setup: 73 | idf.py set-target esp32s3 # Specify your target chip if different 74 | ``` 75 | 76 | ### 3. Run Tests 77 | 78 | **FAR Test Execution**: 79 | 1. In serial monitor, type command: 80 | ``` 81 | far 82 | ``` 83 | 2. Program will: 84 | - Process the 48-hour test set 85 | - Monitor for false wake word detections 86 | - Calculate false alarm rate 87 | - Generate comprehensive report 88 | 89 | **NOTE**: The FAR test automatically enables **debug mode** by default. In debug mode, the system will output **detection threshold**. Please adjust the threshold based on the test results before conducting the RAR test. 90 | 91 | 92 | **RAR Test Execution**: 93 | 1. Open serial monitor after flashing 94 | 2. Type command: 95 | ``` 96 | rar 97 | ``` 98 | 3. Program will: 99 | - Load `{wn_name}.csv` 100 | - Process each test file 101 | - Generate detection statistics 102 | - Output pass/fail results 103 | --- 104 | -------------------------------------------------------------------------------- /test/wakenet/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(srcs 2 | wakenet_main.c 3 | ) 4 | 5 | set(requires 6 | perf_tester 7 | ) 8 | 9 | idf_component_register(SRCS ${srcs} 10 | INCLUDE_DIRS . 11 | REQUIRES ${requires}) 12 | 13 | -------------------------------------------------------------------------------- /test/wakenet/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-sr: ">=2.1.2" 3 | -------------------------------------------------------------------------------- /test/wakenet/main/wakenet_main.c: -------------------------------------------------------------------------------- 1 | #include "wn_perf_tester.h" 2 | #include "esp_afe_config.h" 3 | #include "model_path.h" 4 | #include "esp_board_init.h" 5 | #include "esp_mn_speech_commands.h" 6 | #include "esp_process_sdkconfig.h" 7 | #include "perf_tester_cmd.h" 8 | #include "esp_log.h" 9 | #include "esp_sr_debug.h" 10 | 11 | static void* wakenet_test(srmodel_list_t *models, const char *csv_file, const char* log_file) 12 | { 13 | // Select speech enhancement pipeline 14 | afe_config_t *afe_config = afe_config_init("MMR", models, AFE_TYPE_SR, AFE_MODE_LOW_COST); 15 | afe_config->ns_init = false; 16 | afe_config->ns_model_name = NULL; 17 | perf_tester_config_t *tester_config = get_perf_tester_config(); 18 | afe_config_print(afe_config); 19 | void *task_handle = offline_wn_tester_start(csv_file, log_file, NULL, afe_config, TESTER_WAV_3CH, tester_config); 20 | afe_config_free(afe_config); 21 | return task_handle; 22 | } 23 | 24 | static int start_rar_test(int argc, char **argv) 25 | { 26 | printf("Start RAR test:\n"); 27 | srmodel_list_t *models = esp_srmodel_init("model"); 28 | char *wn_name = esp_srmodel_filter(models, ESP_WN_PREFIX, NULL); 29 | char csv_file[128]; 30 | char log_file[128]; 31 | sprintf(csv_file, "/sdcard/%s.csv", wn_name); 32 | sprintf(log_file, "/sdcard/%s.log", wn_name); 33 | printf("test:%s, log:%s\n", csv_file, log_file); 34 | 35 | esp_sr_set_debug_mode(1); 36 | wakenet_test(models, csv_file, log_file); 37 | 38 | return 0; 39 | } 40 | 41 | static int start_far_test(int argc, char **argv) 42 | { 43 | printf("Start FAR test (48-hour dataset):\n"); 44 | srmodel_list_t *models = esp_srmodel_init("model"); 45 | char *wn_name = esp_srmodel_filter(models, ESP_WN_PREFIX, NULL); 46 | char csv_file[128] = "/sdcard/far_48h.csv"; 47 | char log_file[128]; 48 | sprintf(log_file, "/sdcard/%s_far.log", wn_name); 49 | printf("test:%s, log:%s\n", csv_file, log_file); 50 | 51 | esp_sr_set_debug_mode(1); 52 | wakenet_test(models, csv_file, log_file); 53 | return 0; 54 | } 55 | 56 | void register_test_commands() 57 | { 58 | // Register RAR command 59 | const esp_console_cmd_t rar_cmd = { 60 | .command = "rar", 61 | .help = "Run RAR test, please make sure the .csv is in /sdcard", 62 | .hint = NULL, 63 | .func = start_rar_test, 64 | }; 65 | ESP_ERROR_CHECK(esp_console_cmd_register(&rar_cmd)); 66 | 67 | // Register FAR command 68 | const esp_console_cmd_t far_cmd = { 69 | .command = "far", 70 | .help = "Run FAR test (48-hour dataset), please make sure the far_48hours.csv is in /sdcard", 71 | .hint = NULL, 72 | .func = start_far_test, 73 | }; 74 | ESP_ERROR_CHECK(esp_console_cmd_register(&far_cmd)); 75 | } 76 | 77 | void app_main() 78 | { 79 | ESP_ERROR_CHECK(esp_board_init(16000, 1, 16)); 80 | ESP_ERROR_CHECK(esp_sdcard_init("/sdcard", 10)); 81 | heap_caps_print_heap_info(MALLOC_CAP_8BIT); 82 | 83 | // Init console repl 84 | esp_console_repl_t *repl = NULL; 85 | esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT(); 86 | repl_config.prompt = "perf_tester>"; 87 | esp_console_dev_uart_config_t uart_config = ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT(); 88 | ESP_ERROR_CHECK(esp_console_new_repl_uart(&uart_config, &repl_config, &repl)); 89 | 90 | // Register commands 91 | esp_console_register_help_command(); 92 | register_perf_tester_config_cmd(); 93 | register_test_commands(); 94 | 95 | // Start console repl 96 | ESP_ERROR_CHECK(esp_console_start_repl(repl)); 97 | } 98 | -------------------------------------------------------------------------------- /test/wakenet/partitions.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 2500k 4 | model, data, spiffs, , 5168K, 5 | -------------------------------------------------------------------------------- /test/wakenet/pytest_wakenet.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Steps to run these cases: 3 | - Build 4 | - . ${IDF_PATH}/export.sh 5 | - pip install idf_build_apps 6 | - python tools/build_apps.py test/wakenet -t esp32s3 7 | - Test 8 | - pip install -r tools/ci/requirement.pytest.txt 9 | - pytest test/wakenet --target esp32s2 10 | ''' 11 | 12 | import json 13 | import os 14 | import re 15 | 16 | import pytest 17 | from pytest_embedded import Dut 18 | 19 | 20 | def save_report(results): 21 | with open(results["report_file"], "w") as f: 22 | json.dump(results, f) 23 | 24 | 25 | @pytest.mark.target('esp32s3') 26 | @pytest.mark.env('korvo-2') 27 | @pytest.mark.timeout(60000) 28 | @pytest.mark.config('hiesp') 29 | @pytest.mark.config('hilexin') 30 | def test_wakenet(config, noise, snr, dut: Dut)-> None: 31 | 32 | def match_log(pattern, timeout=18000): 33 | str = dut.expect(pattern, timeout=timeout).group(1).decode() 34 | return str 35 | 36 | def match_log_int(pattern, timeout=18000): 37 | num = match_log(pattern, timeout) 38 | return int(num) 39 | 40 | dut.expect('perf_tester>', timeout=20) 41 | mode = 'norm' 42 | dut.write('config {} {} {}'.format(mode, noise, snr)) 43 | dut.expect('mode:{}, noise:{}, snr:{}'.format(mode, noise, snr), timeout=20) 44 | dut.write('rar') 45 | timeout = 36000 46 | results = {} 47 | basedir = os.path.dirname(dut.logfile) 48 | report_file = os.path.join(basedir, "report.json") 49 | results["report_file"] = report_file 50 | 51 | #Get the number of test file 52 | file_num_pattern = re.compile(rb'Number of files: (\d+)') 53 | file_num = match_log_int(file_num_pattern, 20) 54 | dut.expect('MC Quantized wakenet9: ', timeout=20) 55 | results["file_num"] = file_num 56 | 57 | # Get the trigger times and memory siize 58 | # The following formats are defined in perf_tester.c 59 | psram_pattern = re.compile(rb'AFE PSRAM: (\d+) KB') 60 | sram_pattern = re.compile(rb'AFE SRAM: (\d+) KB') 61 | psram_size = match_log_int(psram_pattern, timeout) 62 | sram_size = match_log_int(sram_pattern, timeout) 63 | assert psram_size < 1120 # Assert that the psram size is under 1120 kB 64 | assert sram_size < 32 # Assert that the internal ram size is under 32 kB 65 | results["psram"] = psram_size 66 | results["sram"] = sram_size 67 | 68 | for i in range(file_num): 69 | file_id = f'File{i}' 70 | filename_pattern = re.compile(str.encode(f'{file_id}: (\\S+)')) 71 | trigger_times_pattern = re.compile(str.encode(f'{file_id}, trigger times: (\\d+)')) 72 | required_times_pattern = re.compile(str.encode(f'{file_id}, required times: (\\d+)')) 73 | truth_times_pattern = re.compile(str.encode(f'{file_id}, truth times: (\\d+)')) 74 | 75 | filename = match_log(filename_pattern, timeout) 76 | trigger_times = match_log_int(trigger_times_pattern, timeout) 77 | required_times = match_log_int(required_times_pattern, timeout) 78 | truth_times = match_log_int(truth_times_pattern, timeout) 79 | 80 | results[file_id] = {} 81 | results[file_id]["filename"] = filename 82 | results[file_id]["trigger_times"] = trigger_times 83 | results[file_id]["required_times"] = required_times 84 | results[file_id]["truth_times"] = truth_times 85 | assert trigger_times >= required_times 86 | 87 | save_report(results) 88 | dut.expect('TEST DONE', timeout=timeout) 89 | dut.write('\x03') 90 | -------------------------------------------------------------------------------- /test/wakenet/sdkconfig.ci.hiesp: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_TARGET="esp32s3" 2 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 3 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 4 | CONFIG_PARTITION_TABLE_CUSTOM=y 5 | CONFIG_SR_WN_WN9_HIESP=y 6 | CONFIG_ESP32_S3_KORVO_2_V3_0_BOARD=y 7 | CONFIG_COMPILER_ORPHAN_SECTIONS_PLACE=y 8 | CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=y 9 | CONFIG_SPIRAM=y 10 | CONFIG_SPIRAM_MODE_OCT=y 11 | CONFIG_SPIRAM_SPEED_80M=y 12 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 13 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 14 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 15 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 16 | CONFIG_ESP_WIFI_STATIC_TX_BUFFER=y 17 | CONFIG_FATFS_LFN_HEAP=y 18 | CONFIG_LOG_COLORS=y 19 | CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y 20 | CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y 21 | -------------------------------------------------------------------------------- /test/wakenet/sdkconfig.ci.hilexin: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_TARGET="esp32s3" 2 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 3 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 4 | CONFIG_PARTITION_TABLE_CUSTOM=y 5 | CONFIG_SR_WN_WN9_HILEXIN=y 6 | CONFIG_ESP32_S3_KORVO_2_V3_0_BOARD=y 7 | CONFIG_COMPILER_ORPHAN_SECTIONS_PLACE=y 8 | CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=y 9 | CONFIG_SPIRAM=y 10 | CONFIG_SPIRAM_MODE_OCT=y 11 | CONFIG_SPIRAM_SPEED_80M=y 12 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 13 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 14 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 15 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 16 | CONFIG_ESP_WIFI_STATIC_TX_BUFFER=y 17 | CONFIG_FATFS_LFN_HEAP=y 18 | CONFIG_LOG_COLORS=y 19 | CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y 20 | CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y 21 | -------------------------------------------------------------------------------- /test/wakenet/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.4.1 Project Minimal Configuration 3 | # 4 | CONFIG_IDF_TARGET="esp32s3" 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_PARTITION_TABLE_CUSTOM=y 8 | CONFIG_SR_WN_WN9_HILEXIN=y 9 | CONFIG_ESP32_S3_KORVO_2_V3_0_BOARD=y 10 | CONFIG_COMPILER_ORPHAN_SECTIONS_PLACE=y 11 | CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=y 12 | CONFIG_SPIRAM=y 13 | CONFIG_SPIRAM_MODE_OCT=y 14 | CONFIG_SPIRAM_SPEED_80M=y 15 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 16 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 17 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 18 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 19 | CONFIG_ESP_WIFI_STATIC_TX_BUFFER=y 20 | CONFIG_FATFS_LFN_HEAP=y 21 | CONFIG_LOG_COLORS=y 22 | CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y 23 | CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y 24 | -------------------------------------------------------------------------------- /tools/ci/push_to_github.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # gitlab-ci script to push current tested revision (tag or branch) to github 4 | 5 | set -ex 6 | 7 | if [ -n "${CI_COMMIT_TAG}" ]; then 8 | # for tags 9 | git push github "${CI_COMMIT_TAG}" 10 | else 11 | # for branches 12 | git push github "${CI_COMMIT_SHA}:refs/heads/${CI_COMMIT_REF_NAME}" 13 | fi 14 | 15 | -------------------------------------------------------------------------------- /tools/ci/requirements.txt: -------------------------------------------------------------------------------- 1 | pytest 2 | pytest-embedded-idf 3 | pytest-embedded-serial-esp 4 | pytest-rerunfailures 5 | pytest-timeout 6 | -------------------------------------------------------------------------------- /tools/default_firmware/README.md: -------------------------------------------------------------------------------- 1 | # Default firmware 2 | 3 | ## overview 4 | 5 | esp32_korvo_v1_1_fw_v0_1_20200323.bin is the default firmware of ESP32-Korvo V1.1. 6 | 7 | default_firmware_ESP32-S3-Korvo-1.bin is the default firmware of ESP32-S3-Korvo-1. 8 | 9 | ## Usgae 10 | 11 | ### Setting Up ESP-IDF 12 | 13 | See https://idf.espressif.com/ for links to detailed instructions on how to set up the ESP-IDF depending on chip you use. 14 | 15 | ### Flash bin 16 | 17 | ``` 18 | python $IDF_PATH/components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0x0000 esp32_korvo_v1_1_fw_v0_1_20200323.bin` 19 | ``` 20 | 21 | ``` 22 | python $IDF_PATH/components/esptool_py/esptool/esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0x0000 default_firmware_ESP32-S3-Korvo-1.bin` 23 | ``` 24 | 25 | For Windows users , [Espressif Flash Download Tools](https://www.espressif.com/zh-hans/support/download/other-tools) also can be used to flash bin。 26 | 27 | -------------------------------------------------------------------------------- /tools/default_firmware/default_firmware_ESP32-S3-Korvo-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/tools/default_firmware/default_firmware_ESP32-S3-Korvo-1 -------------------------------------------------------------------------------- /tools/default_firmware/esp32_korvo_v1_1_fw_v0_1_20200323.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/tools/default_firmware/esp32_korvo_v1_1_fw_v0_1_20200323.bin -------------------------------------------------------------------------------- /tools/generate_audio_file/README.md: -------------------------------------------------------------------------------- 1 | ## How to generate audio files: 2 | 3 | - generate_audio_file.py is an example of generate audio table from .wav files. 4 | - In this example, the wav file must be in 16k/16bit mono format. 5 | - generate_audio_file.py will bundle the wav files into a single table named with audio files's name. -------------------------------------------------------------------------------- /tools/generate_audio_file/alexa.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/tools/generate_audio_file/alexa.wav -------------------------------------------------------------------------------- /tools/generate_audio_file/generate_audio_file.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from __future__ import print_function 3 | import os 4 | import struct 5 | import wave 6 | 7 | import contextlib 8 | 9 | def read_wave(path): 10 | with contextlib.closing(wave.open(path, 'rb')) as wf: 11 | num_channels = wf.getnchannels() 12 | assert num_channels == 1 13 | sample_width = wf.getsampwidth() 14 | assert sample_width == 2 15 | sample_rate = wf.getframerate() 16 | assert sample_rate in (8000,16000,48000) 17 | pcm_data = wf.readframes(wf.getnframes()) 18 | return pcm_data, sample_rate 19 | 20 | 21 | def get_wave_array_str(filename, target_bits): 22 | pcm_data, sr = read_wave(filename) 23 | array_str = "" 24 | i =0 25 | for data in pcm_data: 26 | #val = struct.unpack("B", data) 27 | array_str += "%0#4x, "%(data) 28 | if (i + 1) % 16 == 0: 29 | array_str += "\n" 30 | i = i + 1 31 | return array_str 32 | 33 | 34 | #def get_wave_array_str(filename, target_bits): 35 | # with open(filename, "rb") as f: 36 | # array_str = "" 37 | # head = f.read(44) 38 | # i = 0 39 | # while (1): 40 | # data = f.read(1) 41 | # if len(data) == 0: 42 | # break 43 | # if len(data) == 1: 44 | # val = struct.unpack("B", data) 45 | # array_str += "%0#4x, "%(val) 46 | # if (i + 1) % 16 == 0: 47 | # array_str += "\n" 48 | # i = i + 1 49 | # return array_str 50 | 51 | def gen_wave_table(wav_file_list, scale_bits = 8): 52 | for wav in wav_file_list: 53 | print("processing: {}".format(wav)) 54 | (filepath,tempfilename) = os.path.split(wav) 55 | (shotname,extension) = os.path.splitext(tempfilename) 56 | h_file_name = shotname + ".h" 57 | with open(h_file_name, "w") as audio_table: 58 | print('#include ', file=audio_table) 59 | name_array = "const unsigned char " + shotname + "[] = {" 60 | print(name_array, file=audio_table) 61 | print(get_wave_array_str(filename = wav, target_bits = scale_bits), file=audio_table) 62 | print('};\n', file=audio_table) 63 | print("Done...") 64 | 65 | if __name__=='__main__': 66 | print("Generating audio array...") 67 | wav_list = [] 68 | for filename in os.listdir("./"): 69 | if filename.endswith(".wav"): 70 | wav_list.append(filename) 71 | gen_wave_table(wav_file_list = wav_list) 72 | -------------------------------------------------------------------------------- /tools/generate_audio_file/hijeson.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/tools/generate_audio_file/hijeson.wav -------------------------------------------------------------------------------- /tools/generate_audio_file/hilexin.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/tools/generate_audio_file/hilexin.wav -------------------------------------------------------------------------------- /tools/generate_audio_file/xiaoaitongxue.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-skainet/ed8743b566eb67b9f29a7ba1b7f1608e0d8c9266/tools/generate_audio_file/xiaoaitongxue.wav --------------------------------------------------------------------------------