tests : update VAD tests to use Silero V6.2.0 (#3534)

* tests : update VAD tests to use Silero V6.2.0

This commit updates the VAD tests to use the Silero V6.2.0 instead of
V5.1.2. I'm was not sure if we needed to keep testing for both versions,
but opted to just update to the latest version for simplicity.

* wasm : use C++17 for emscripten builds

This commit updates the CMakeLists.txt file to explicitly set the C++
standard to C++17 when building with Emscripten.

The motivation for this change is that building with Emscripten
will currently fail locally and on CI with the following error:
```console
[ 75%] Building CXX object examples/CMakeFiles/common.dir/common-ggml.cpp.o
In file included from /home/danbev/work/ai/whisper.cpp/examples/stream.wasm/emscripten.cpp:5:
/home/danbev/work/utils/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:11:2: error:
      "embind requires -std=c++17 or newer"
   11 | #error "embind requires -std=c++17 or newer"
      |  ^
In file included from /home/danbev/work/ai/whisper.cpp/examples/whisper.wasm/emscripten.cpp:4:
/home/danbev/work/utils/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:11:2: error:
      "embind requires -std=c++17 or newer"
   11 | #error "embind requires -std=c++17 or newer"
      |  ^
```
This commit is contained in:
Daniel Bevenius 2025-12-06 10:58:58 +01:00 committed by GitHub
parent 19ceec8eac
commit d566358a1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 10 additions and 5 deletions

View File

@ -34,6 +34,9 @@ endif()
if (EMSCRIPTEN) if (EMSCRIPTEN)
set(BUILD_SHARED_LIBS_DEFAULT OFF) set(BUILD_SHARED_LIBS_DEFAULT OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(WHISPER_WASM_SINGLE_FILE "whisper: embed WASM inside the generated whisper.js" ON) option(WHISPER_WASM_SINGLE_FILE "whisper: embed WASM inside the generated whisper.js" ON)
# TODO: without these, we get the following error: # TODO: without these, we get the following error:

Binary file not shown.

View File

@ -94,7 +94,7 @@ add_executable(${VAD_TEST} ${VAD_TEST}.cpp)
target_include_directories(${VAD_TEST} PRIVATE ../include ../ggml/include ../examples) target_include_directories(${VAD_TEST} PRIVATE ../include ../ggml/include ../examples)
target_link_libraries(${VAD_TEST} PRIVATE common) target_link_libraries(${VAD_TEST} PRIVATE common)
target_compile_definitions(${VAD_TEST} PRIVATE target_compile_definitions(${VAD_TEST} PRIVATE
VAD_MODEL_PATH="${PROJECT_SOURCE_DIR}/models/for-tests-silero-v5.1.2-ggml.bin" VAD_MODEL_PATH="${PROJECT_SOURCE_DIR}/models/for-tests-silero-v6.2.0-ggml.bin"
SAMPLE_PATH="${PROJECT_SOURCE_DIR}/samples/jfk.wav") SAMPLE_PATH="${PROJECT_SOURCE_DIR}/samples/jfk.wav")
add_test(NAME ${VAD_TEST} COMMAND ${VAD_TEST}) add_test(NAME ${VAD_TEST} COMMAND ${VAD_TEST})
set_tests_properties(${VAD_TEST} PROPERTIES LABELS "unit") set_tests_properties(${VAD_TEST} PROPERTIES LABELS "unit")
@ -106,7 +106,7 @@ target_include_directories(${VAD_TEST} PRIVATE ../include ../ggml/include ../exa
target_link_libraries(${VAD_TEST} PRIVATE common) target_link_libraries(${VAD_TEST} PRIVATE common)
target_compile_definitions(${VAD_TEST} PRIVATE target_compile_definitions(${VAD_TEST} PRIVATE
WHISPER_MODEL_PATH="${PROJECT_SOURCE_DIR}/models/ggml-base.en.bin" WHISPER_MODEL_PATH="${PROJECT_SOURCE_DIR}/models/ggml-base.en.bin"
VAD_MODEL_PATH="${PROJECT_SOURCE_DIR}/models/for-tests-silero-v5.1.2-ggml.bin" VAD_MODEL_PATH="${PROJECT_SOURCE_DIR}/models/for-tests-silero-v6.2.0-ggml.bin"
SAMPLE_PATH="${PROJECT_SOURCE_DIR}/samples/jfk.wav") SAMPLE_PATH="${PROJECT_SOURCE_DIR}/samples/jfk.wav")
add_test(NAME ${VAD_TEST} COMMAND ${VAD_TEST}) add_test(NAME ${VAD_TEST} COMMAND ${VAD_TEST})
set_tests_properties(${VAD_TEST} PROPERTIES LABELS "base;en") set_tests_properties(${VAD_TEST} PROPERTIES LABELS "base;en")

View File

@ -42,11 +42,13 @@ int main() {
const int n_segments = whisper_full_n_segments(wctx); const int n_segments = whisper_full_n_segments(wctx);
assert(n_segments == 1); assert(n_segments == 1);
printf("Segment text:\n%s", whisper_full_get_segment_text(wctx, 0));
assert(strcmp(" And so my fellow Americans, ask not what your country can do for you," assert(strcmp(" And so my fellow Americans, ask not what your country can do for you,"
" ask what you can do for your country.", " ask what you can do for your country.",
whisper_full_get_segment_text(wctx, 0)) == 0); whisper_full_get_segment_text(wctx, 0)) == 0);
assert(whisper_full_get_segment_t0(wctx, 0) == 29); assert(whisper_full_get_segment_t0(wctx, 0) == 32);
assert(whisper_full_get_segment_t1(wctx, 0) == 1049); assert(whisper_full_get_segment_t1(wctx, 0) == 1051);
whisper_free(wctx); whisper_free(wctx);

View File

@ -36,7 +36,7 @@ struct whisper_vad_segments * test_detect_timestamps(
struct whisper_vad_context * vctx, struct whisper_vad_context * vctx,
struct whisper_vad_params params) { struct whisper_vad_params params) {
struct whisper_vad_segments * timestamps = whisper_vad_segments_from_probs(vctx, params); struct whisper_vad_segments * timestamps = whisper_vad_segments_from_probs(vctx, params);
assert(whisper_vad_segments_n_segments(timestamps) == 5); assert(whisper_vad_segments_n_segments(timestamps) == 4);
for (int i = 0; i < whisper_vad_segments_n_segments(timestamps); ++i) { for (int i = 0; i < whisper_vad_segments_n_segments(timestamps); ++i) {
printf("VAD segment %d: start = %.2f, end = %.2f\n", i, printf("VAD segment %d: start = %.2f, end = %.2f\n", i,