feat: integrate chat voice and diagnostics client
This commit is contained in:
@@ -76,6 +76,8 @@ pub struct SileroOnnxVad {
|
||||
|
||||
enum SileroInner {
|
||||
Onnx(OnnxSession),
|
||||
#[cfg(test)]
|
||||
Stub,
|
||||
}
|
||||
|
||||
struct OnnxSession {
|
||||
@@ -179,9 +181,13 @@ impl SileroOnnxVad {
|
||||
use ort::value::Value;
|
||||
use tracing::error;
|
||||
|
||||
let SileroInner::Onnx(ref mut inner) = self.inner else {
|
||||
return self.last_probability;
|
||||
#[cfg(test)]
|
||||
let inner = match self.inner {
|
||||
SileroInner::Onnx(ref mut inner) => inner,
|
||||
SileroInner::Stub => return self.last_probability,
|
||||
};
|
||||
#[cfg(not(test))]
|
||||
let SileroInner::Onnx(ref mut inner) = self.inner;
|
||||
|
||||
debug_assert_eq!(audio_frame.len(), SILERO_FRAME_16K);
|
||||
|
||||
@@ -259,17 +265,6 @@ impl SileroOnnxVad {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub(crate) fn bundled_onnxruntime_path_for_vad() -> Option<std::path::PathBuf> {
|
||||
let exe = std::env::current_exe().ok()?;
|
||||
let app_dir = exe.parent()?;
|
||||
let framework = app_dir
|
||||
.join("Frameworks")
|
||||
.join("onnxruntime.framework")
|
||||
.join("onnxruntime");
|
||||
framework.exists().then_some(framework)
|
||||
}
|
||||
|
||||
impl VoiceActivityDetector for SileroOnnxVad {
|
||||
/// Accept one 10 ms **16 kHz** f32 mono frame (160 samples).
|
||||
///
|
||||
@@ -333,7 +328,7 @@ impl SileroOnnxVadWorker {
|
||||
let latest_probability = Arc::new(AtomicU32::new(0.0_f32.to_bits()));
|
||||
let latest_processed_seq = Arc::new(AtomicU64::new(u64::MAX));
|
||||
let alive = Arc::new(AtomicBool::new(true));
|
||||
let (tx, rx) = std::sync::mpsc::sync_channel::<SileroFrameMessage>(32);
|
||||
let (tx, rx) = std::sync::mpsc::sync_channel::<SileroFrameMessage>(64);
|
||||
let latest_probability_for_thread = latest_probability.clone();
|
||||
let latest_processed_seq_for_thread = latest_processed_seq.clone();
|
||||
let alive_for_thread = alive.clone();
|
||||
|
||||
Reference in New Issue
Block a user