#[cfg(feature = "onnx")]
use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error(transparent)]
Core(#[from] zuoer::Error),
#[cfg(feature = "onnx")]
#[cfg_attr(docsrs, doc(cfg(feature = "onnx")))]
#[error("failed to load Silero model from {path}: {source}")]
LoadModel {
path: PathBuf,
#[source]
source: ort::Error,
},
#[cfg(feature = "onnx")]
#[cfg_attr(docsrs, doc(cfg(feature = "onnx")))]
#[error(transparent)]
Ort(#[from] ort::Error),
#[cfg(feature = "onnx")]
#[cfg_attr(docsrs, doc(cfg(feature = "onnx")))]
#[error("batch contains mixed sample rates (expected {expected} Hz, found {actual} Hz)")]
MixedBatchSampleRate {
expected: u32,
actual: u32,
},
#[cfg(feature = "onnx")]
#[cfg_attr(docsrs, doc(cfg(feature = "onnx")))]
#[error("Silero model returned unexpected shape for {tensor}: {shape:?}")]
UnexpectedOutputShape {
tensor: &'static str,
shape: Vec<i64>,
},
}
pub type Result<T> = std::result::Result<T, Error>;
impl From<Error> for zuoer::Error {
fn from(error: Error) -> Self {
zuoer::Error::Backend(Box::new(error))
}
}