This repository has been archived on 2025-08-26. You can view files and clone it, but cannot push or open issues or pull requests.
Files
enginex-mr_series-sherpa-onnx/sherpa-onnx/csrc/vad-model.h
2023-09-17 14:54:38 +08:00

40 lines
1.0 KiB
C++

// sherpa-onnx/csrc/vad-model.h
//
// Copyright (c) 2023 Xiaomi Corporation
#ifndef SHERPA_ONNX_CSRC_VAD_MODEL_H_
#define SHERPA_ONNX_CSRC_VAD_MODEL_H_
#include <memory>
#include "sherpa-onnx/csrc/vad-model-config.h"
namespace sherpa_onnx {
class VadModel {
public:
virtual ~VadModel() = default;
static std::unique_ptr<VadModel> Create(const VadModelConfig &config);
// reset the internal model states
virtual void Reset() = 0;
/**
* @param samples Pointer to a 1-d array containing audio samples.
* Each sample should be normalized to the range [-1, 1].
* @param n Number of samples. Should be equal to WindowSize()
*
* @return Return true if speech is detected. Return false otherwise.
*/
virtual bool IsSpeech(const float *samples, int32_t n) = 0;
virtual int32_t WindowSize() const = 0;
virtual int32_t MinSilenceDurationSamples() const = 0;
virtual int32_t MinSpeechDurationSamples() const = 0;
};
} // namespace sherpa_onnx
#endif // SHERPA_ONNX_CSRC_VAD_MODEL_H_