Skip to content

Commit

Permalink
Merge branch 'feature/add_volc_rtc_example' into 'master'
Browse files Browse the repository at this point in the history
example: add volc rtc example

See merge request adf/esp-adf-internal!1368
  • Loading branch information
jason-mao committed Jan 20, 2025
2 parents 8fc8a4a + 77e5f72 commit 60054d2
Show file tree
Hide file tree
Showing 28 changed files with 3,855 additions and 13 deletions.
14 changes: 5 additions & 9 deletions components/audio_recorder/audio_recorder.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,15 @@ static void audio_recorder_update_state(audio_recorder_t *recorder, int event)
audio_recorder_set_state(recorder, RECORDER_ST_SPEECHING);
audio_recorder_update_state_2_user(recorder, AUDIO_REC_WAKEUP_START, &recorder->wakeup_result, sizeof(recorder_sr_wakeup_result_t));
audio_recorder_update_state_2_user(recorder, AUDIO_REC_VAD_START, NULL, 0);
audio_recorder_encoder_enable(recorder, true);
}
audio_recorder_encoder_enable(recorder, true);
} else if (!sr_st.wwe_enable && event == RECORDER_EVENT_SPEECH_DECT) {
if (recorder->vad_check) {
audio_recorder_set_state(recorder, RECORDER_ST_WAIT_FOR_SPEECH);
audio_recorder_vad_timer_start(recorder);
} else {
audio_recorder_set_state(recorder, RECORDER_ST_SPEECHING);
audio_recorder_update_state_2_user(recorder, AUDIO_REC_VAD_START, NULL, 0);
audio_recorder_encoder_enable(recorder, true);
}
}
break;
Expand All @@ -297,12 +296,12 @@ static void audio_recorder_update_state(audio_recorder_t *recorder, int event)
} else {
audio_recorder_set_state(recorder, RECORDER_ST_SPEECHING);
audio_recorder_update_state_2_user(recorder, AUDIO_REC_VAD_START, NULL, 0);
audio_recorder_encoder_enable(recorder, true);
}
} else if (event == RECORDER_EVENT_WAKEUP_TIMER_EXPIRED) {
recorder->state = RECORDER_ST_IDLE;
esp_timer_stop(recorder->vad_timer);
audio_recorder_update_state_2_user(recorder, AUDIO_REC_WAKEUP_END, NULL, 0);
audio_recorder_encoder_enable(recorder, false);
}
break;
}
Expand All @@ -313,24 +312,23 @@ static void audio_recorder_update_state(audio_recorder_t *recorder, int event)
audio_recorder_set_state(recorder, RECORDER_ST_SPEECHING);
esp_timer_stop(recorder->wakeup_timer);
audio_recorder_update_state_2_user(recorder, AUDIO_REC_VAD_START, NULL, 0);
audio_recorder_encoder_enable(recorder, true);
} else if (event == RECORDER_EVENT_WAKEUP_TIMER_EXPIRED) {
recorder->state = RECORDER_ST_IDLE;
esp_timer_stop(recorder->vad_timer);
audio_recorder_update_state_2_user(recorder, AUDIO_REC_WAKEUP_END, NULL, 0);
audio_recorder_encoder_enable(recorder, false);
}
break;
}
case RECORDER_ST_SPEECHING: {
if (event == RECORDER_EVENT_NOISE_DECT) {
if (event == RECORDER_EVENT_NOISE_DECT && sr_st.wwe_enable) {
if (recorder->vad_check) {
audio_recorder_set_state(recorder, RECORDER_ST_WAIT_FOR_SILENCE);
audio_recorder_vad_timer_start(recorder);
} else {
audio_recorder_set_state(recorder, RECORDER_ST_WAIT_FOR_SLEEP);
audio_recorder_wakeup_timer_start(recorder);
audio_recorder_update_state_2_user(recorder, AUDIO_REC_VAD_END, NULL, 0);
audio_recorder_encoder_enable(recorder, false);
}
}
break;
Expand All @@ -347,7 +345,6 @@ static void audio_recorder_update_state(audio_recorder_t *recorder, int event)
recorder->state = RECORDER_ST_IDLE;
}
audio_recorder_update_state_2_user(recorder, AUDIO_REC_VAD_END, NULL, 0);
audio_recorder_encoder_enable(recorder, false);
}
break;
}
Expand Down Expand Up @@ -404,7 +401,6 @@ static void audio_recorder_task(void *parameters)
ESP_LOGI(TAG, "RECORDER_CMD_TRIGGER_STOP [state %d]", recorder->state);
if ((recorder->state >= RECORDER_ST_SPEECHING) && (recorder->state <= RECORDER_ST_WAIT_FOR_SILENCE)) {
audio_recorder_update_state_2_user(recorder, AUDIO_REC_VAD_END, NULL, 0);
audio_recorder_encoder_enable(recorder, false);
}
if (recorder->state != RECORDER_ST_IDLE) {
audio_recorder_update_state_2_user(recorder, AUDIO_REC_WAKEUP_END, NULL, 0);
Expand Down Expand Up @@ -688,7 +684,7 @@ int audio_recorder_data_read(audio_rec_handle_t handle, void *buffer, int length
audio_recorder_t *recorder = (audio_recorder_t *)handle;
recorder_subproc_iface_t *subproc = NULL;
int ret = 0;
if (recorder->state != RECORDER_ST_SPEECHING && recorder->state != RECORDER_ST_WAIT_FOR_SILENCE) {
if (recorder->state == RECORDER_ST_IDLE) {
ESP_LOGW(TAG, "Not in speeching, return 0");
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions components/audio_recorder/recorder_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ static esp_err_t recorder_encoder_enable(void *handle, bool enable)
} else {
rb_done_write(recorder_encoder->out_rb);
audio_pipeline_stop(recorder_encoder->pipeline);
audio_pipeline_wait_for_stop(recorder_encoder->pipeline);
audio_pipeline_reset_elements(recorder_encoder->pipeline);
audio_pipeline_reset_items_state(recorder_encoder->pipeline);
}
Expand Down
13 changes: 10 additions & 3 deletions components/clouds/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@ if (DEFINED ENV{DUER_PATH})
return()
endif()

set(COMPONENT_ADD_INCLUDEDIRS ./dueros/lightduer/include)
set(COMPONENT_ADD_INCLUDEDIRS ./dueros/lightduer/include ./volc_engine_rtc/include)

# Edit following two lines to set component requirements (see docs)
set(COMPONENT_SRCS )

set(COMPONENT_SRCS)

register_component()

target_link_libraries(${COMPONENT_TARGET} INTERFACE "-L${CMAKE_CURRENT_LIST_DIR}/dueros/lightduer/${CONFIG_IDF_TARGET}")

IF ((CONFIG_IDF_TARGET STREQUAL "esp32s3"))
IF (IDF_VERSION_MAJOR EQUAL 5)
add_prebuilt_library(VolcEngineRTCLite "${CMAKE_CURRENT_LIST_DIR}/volc_engine_rtc/libs/${CONFIG_IDF_TARGET}/libVolcEngineRTCLite.a"
REQUIRES mbedtls espressif__zlib json lwip)
target_link_libraries(${COMPONENT_LIB} INTERFACE VolcEngineRTCLite)
ENDIF()
ENDIF()

IF ((CONFIG_IDF_TARGET STREQUAL "esp32") OR (CONFIG_IDF_TARGET STREQUAL "esp32s3") OR (CONFIG_IDF_TARGET STREQUAL "esp32p4"))
IF (IDF_VERSION_MAJOR GREATER 4)
target_link_libraries(${COMPONENT_TARGET} INTERFACE duer-device-v5x)
Expand Down
2 changes: 2 additions & 0 deletions components/clouds/idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
espressif/zlib: "^1.3.0"
Loading

0 comments on commit 60054d2

Please sign in to comment.