关键的地方在于使用这个 onnxruntime 库。

image.png

复制一份新的 cmake 文件,

image.png

根据那个 issue 的讨论,来打开禁用静态注册的开关,

if(PORT STREQUAL "onnx")
    # simply set to use single flag or list append to customize multiple flags
    list(APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS "-DONNX_DISABLE_STATIC_REGISTRATION=1")
endif()

https://github.com/microsoft/vcpkg/issues/49060

image.png

这里要注意,if 里面的用来判断的字符串是 onnx,之前 chatgpt 把它擅自改成了 onnxruntime,让我排查浪费了好多时间。

然后,就是把这个官方的示例喂给 ai,

https://github.com/snakers4/silero-vad/blob/master/examples/cpp/silero-vad-onnx.cpp

还有,这里暂时把 baseline 去掉了,不然安装 onnxruntime 有问题。暂时先不考虑什么 vcpkg 安装的规范性问题了,用

image.png