Committed by
GitHub
Expose VAD isDetected api to Swift (#356)
正在显示
3 个修改的文件
包含
15 行增加
和
1 行删除
| @@ -488,6 +488,11 @@ int32_t SherpaOnnxVoiceActivityDetectorEmpty( | @@ -488,6 +488,11 @@ int32_t SherpaOnnxVoiceActivityDetectorEmpty( | ||
| 488 | return p->impl->Empty(); | 488 | return p->impl->Empty(); |
| 489 | } | 489 | } |
| 490 | 490 | ||
| 491 | +int32_t SherpaOnnxVoiceActivityDetectorDetected( | ||
| 492 | + SherpaOnnxVoiceActivityDetector *p) { | ||
| 493 | + return p->impl->IsSpeechDetected(); | ||
| 494 | +} | ||
| 495 | + | ||
| 491 | SHERPA_ONNX_API void SherpaOnnxVoiceActivityDetectorPop( | 496 | SHERPA_ONNX_API void SherpaOnnxVoiceActivityDetectorPop( |
| 492 | SherpaOnnxVoiceActivityDetector *p) { | 497 | SherpaOnnxVoiceActivityDetector *p) { |
| 493 | p->impl->Pop(); | 498 | p->impl->Pop(); |
| @@ -570,6 +570,11 @@ SHERPA_ONNX_API void SherpaOnnxVoiceActivityDetectorAcceptWaveform( | @@ -570,6 +570,11 @@ SHERPA_ONNX_API void SherpaOnnxVoiceActivityDetectorAcceptWaveform( | ||
| 570 | SHERPA_ONNX_API int32_t | 570 | SHERPA_ONNX_API int32_t |
| 571 | SherpaOnnxVoiceActivityDetectorEmpty(SherpaOnnxVoiceActivityDetector *p); | 571 | SherpaOnnxVoiceActivityDetectorEmpty(SherpaOnnxVoiceActivityDetector *p); |
| 572 | 572 | ||
| 573 | +// Return 1 if there is voice detected. | ||
| 574 | +// Return 0 if voice is silent. | ||
| 575 | +SHERPA_ONNX_API int32_t | ||
| 576 | +SherpaOnnxVoiceActivityDetectorDetected(SherpaOnnxVoiceActivityDetector *p); | ||
| 577 | + | ||
| 573 | // Return the first speech segment. | 578 | // Return the first speech segment. |
| 574 | // It throws if SherpaOnnxVoiceActivityDetectorEmpty() returns 1. | 579 | // It throws if SherpaOnnxVoiceActivityDetectorEmpty() returns 1. |
| 575 | SHERPA_ONNX_API void SherpaOnnxVoiceActivityDetectorPop( | 580 | SHERPA_ONNX_API void SherpaOnnxVoiceActivityDetectorPop( |
| @@ -548,7 +548,11 @@ class SherpaOnnxVoiceActivityDetectorWrapper { | @@ -548,7 +548,11 @@ class SherpaOnnxVoiceActivityDetectorWrapper { | ||
| 548 | } | 548 | } |
| 549 | 549 | ||
| 550 | func isEmpty() -> Bool { | 550 | func isEmpty() -> Bool { |
| 551 | - return SherpaOnnxVoiceActivityDetectorEmpty(vad) == 1 ? true : false | 551 | + return SherpaOnnxVoiceActivityDetectorEmpty(vad) == 1 |
| 552 | + } | ||
| 553 | + | ||
| 554 | + func isDetected() -> Bool { | ||
| 555 | + return SherpaOnnxVoiceActivityDetectorDetected(vad) == 1 | ||
| 552 | } | 556 | } |
| 553 | 557 | ||
| 554 | func pop() { | 558 | func pop() { |
-
请 注册 或 登录 后发表评论