Add Silero VAD (#313)
This commit is contained in:
41
sherpa-onnx/csrc/voice-activity-detector.h
Normal file
41
sherpa-onnx/csrc/voice-activity-detector.h
Normal file
@@ -0,0 +1,41 @@
|
||||
// sherpa-onnx/csrc/voice-activity-detector.h
|
||||
//
|
||||
// Copyright (c) 2023 Xiaomi Corporation
|
||||
#ifndef SHERPA_ONNX_CSRC_VOICE_ACTIVITY_DETECTOR_H_
|
||||
#define SHERPA_ONNX_CSRC_VOICE_ACTIVITY_DETECTOR_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "sherpa-onnx/csrc/vad-model-config.h"
|
||||
|
||||
namespace sherpa_onnx {
|
||||
|
||||
struct SpeechSegment {
|
||||
int32_t start; // in samples
|
||||
std::vector<float> samples;
|
||||
};
|
||||
|
||||
class VoiceActivityDetector {
|
||||
public:
|
||||
explicit VoiceActivityDetector(const VadModelConfig &config,
|
||||
float buffer_size_in_seconds = 60);
|
||||
~VoiceActivityDetector();
|
||||
|
||||
void AcceptWaveform(const float *samples, int32_t n);
|
||||
bool Empty() const;
|
||||
void Pop();
|
||||
const SpeechSegment &Front() const;
|
||||
|
||||
bool IsSpeechDetected() const;
|
||||
|
||||
void Reset();
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> impl_;
|
||||
};
|
||||
|
||||
} // namespace sherpa_onnx
|
||||
|
||||
#endif // SHERPA_ONNX_CSRC_VOICE_ACTIVITY_DETECTOR_H_
|
||||
Reference in New Issue
Block a user