diff --git a/build-ios.sh b/build-ios.sh index 855b92dd6..e5fa9e2a0 100755 --- a/build-ios.sh +++ b/build-ios.sh @@ -127,7 +127,8 @@ cmake --build build/os64 --target install echo "Generate xcframework" mkdir -p "build/simulator/lib" -for f in libkaldi-native-fbank-core.a libsherpa-onnx-c-api.a libsherpa-onnx-core.a; do +for f in libkaldi-native-fbank-core.a libsherpa-onnx-c-api.a libsherpa-onnx-core.a \ + libsherpa-onnx-fst.a libsherpa-onnx-kaldifst-core.a libkaldi-decoder-core.a; do lipo -create build/simulator_arm64/lib/${f} \ build/simulator_x86_64/lib/${f} \ -output build/simulator/lib/${f} @@ -138,12 +139,18 @@ done libtool -static -o build/simulator/sherpa-onnx.a \ build/simulator/lib/libkaldi-native-fbank-core.a \ build/simulator/lib/libsherpa-onnx-c-api.a \ - build/simulator/lib/libsherpa-onnx-core.a + build/simulator/lib/libsherpa-onnx-core.a \ + build/simulator/lib/libsherpa-onnx-fst.a \ + build/simulator/lib/libsherpa-onnx-kaldifst-core.a \ + build/simulator/lib/libkaldi-decoder-core.a libtool -static -o build/os64/sherpa-onnx.a \ build/os64/lib/libkaldi-native-fbank-core.a \ build/os64/lib/libsherpa-onnx-c-api.a \ - build/os64/lib/libsherpa-onnx-core.a + build/os64/lib/libsherpa-onnx-core.a \ + build/os64/lib/libsherpa-onnx-fst.a \ + build/os64/lib/libsherpa-onnx-kaldifst-core.a \ + build/os64/lib/libkaldi-decoder-core.a rm -rf sherpa-onnx.xcframework diff --git a/build-swift-macos.sh b/build-swift-macos.sh index a346adbb5..a1b06205c 100755 --- a/build-swift-macos.sh +++ b/build-swift-macos.sh @@ -26,4 +26,7 @@ make install libtool -static -o ./install/lib/libsherpa-onnx.a \ ./install/lib/libsherpa-onnx-c-api.a \ ./install/lib/libsherpa-onnx-core.a \ - ./install/lib/libkaldi-native-fbank-core.a + ./install/lib/libkaldi-native-fbank-core.a \ + ./install/lib/libsherpa-onnx-fst.a \ + ./install/lib/libsherpa-onnx-kaldifst-core.a \ + ./install/lib/libkaldi-decoder-core.a diff --git a/sherpa-onnx/c-api/c-api.cc b/sherpa-onnx/c-api/c-api.cc index c08a3fef6..3f6b35466 100644 --- a/sherpa-onnx/c-api/c-api.cc +++ b/sherpa-onnx/c-api/c-api.cc @@ -488,6 +488,11 @@ int32_t SherpaOnnxVoiceActivityDetectorEmpty( return p->impl->Empty(); } +int32_t SherpaOnnxVoiceActivityDetectorDetected( + SherpaOnnxVoiceActivityDetector *p) { + return p->impl->IsSpeechDetected(); +} + SHERPA_ONNX_API void SherpaOnnxVoiceActivityDetectorPop( SherpaOnnxVoiceActivityDetector *p) { p->impl->Pop(); diff --git a/sherpa-onnx/c-api/c-api.h b/sherpa-onnx/c-api/c-api.h index a5a341d27..b79b83072 100644 --- a/sherpa-onnx/c-api/c-api.h +++ b/sherpa-onnx/c-api/c-api.h @@ -570,6 +570,11 @@ SHERPA_ONNX_API void SherpaOnnxVoiceActivityDetectorAcceptWaveform( SHERPA_ONNX_API int32_t SherpaOnnxVoiceActivityDetectorEmpty(SherpaOnnxVoiceActivityDetector *p); +// Return 1 if there is voice detected. +// Return 0 if voice is silent. +SHERPA_ONNX_API int32_t +SherpaOnnxVoiceActivityDetectorDetected(SherpaOnnxVoiceActivityDetector *p); + // Return the first speech segment. // It throws if SherpaOnnxVoiceActivityDetectorEmpty() returns 1. SHERPA_ONNX_API void SherpaOnnxVoiceActivityDetectorPop( diff --git a/swift-api-examples/SherpaOnnx.swift b/swift-api-examples/SherpaOnnx.swift index 11dabcda0..53637011c 100644 --- a/swift-api-examples/SherpaOnnx.swift +++ b/swift-api-examples/SherpaOnnx.swift @@ -548,7 +548,11 @@ class SherpaOnnxVoiceActivityDetectorWrapper { } func isEmpty() -> Bool { - return SherpaOnnxVoiceActivityDetectorEmpty(vad) == 1 ? true : false + return SherpaOnnxVoiceActivityDetectorEmpty(vad) == 1 + } + + func isDetected() -> Bool { + return SherpaOnnxVoiceActivityDetectorDetected(vad) == 1 } func pop() {