| 643 | return event; |
| 644 | } |
| 645 | |
| 646 | runtime::TaskResult SileroRuntime::finalize_stream(const SileroVADConfig & config) const { |
| 647 | const auto total_start = Clock::now(); |
| 648 | runtime::TaskResult result; |
| 649 | for (const auto & segment : streamed_segments_) { |
| 650 | result.speech_segments.push_back({ |
| 651 | {segment.start, segment.end}, |
| 652 | config.threshold, |
| 653 | {}, |
| 654 | }); |
| 655 | } |
| 656 | const int64_t min_speech_samples = static_cast<int64_t>(kSampleRate) * config.min_speech_duration_ms / 1000; |
| 657 | if (triggered_ && (current_sample_ - current_speech_start_) > min_speech_samples) { |
| 658 | result.speech_segments.push_back({ |
| 659 | {current_speech_start_, current_sample_}, |
| 660 | config.threshold, |
| 661 | {}, |
| 662 | }); |
| 663 | } |
| 664 | engine::debug::timing_log_scalar("silero_vad.streaming.finalize_ms", engine::debug::elapsed_ms(total_start)); |
| 665 | return result; |
| 666 | } |
no test coverage detected