CoolFace
Modelpublic

aoiandroid/IndexTTS-Rust

sourceHugging Facemitupdated 4mo agoView on Hugging Face
0likes1downloads
error.rs89 linesDownload Raw Back to src
1//! Error types for IndexTTS2 3use thiserror::Error;4 5/// Main error type for IndexTTS6#[derive(Error, Debug)]7pub enum Error {8    #[error("Audio processing error: {0}")]9    Audio(String),10 11    #[error("Text processing error: {0}")]12    Text(String),13 14    #[error("Model inference error: {0}")]15    Model(String),16 17    #[error("Configuration error: {0}")]18    Config(String),19 20    #[error("IO error: {0}")]21    Io(#[from] std::io::Error),22 23    #[error("File not found: {0}")]24    FileNotFound(String),25 26    #[error("Invalid format: {0}")]27    InvalidFormat(String),28 29    #[error("ONNX Runtime error: {0}")]30    Onnx(String),31 32    #[error("Tokenization error: {0}")]33    Tokenization(String),34 35    #[error("Model loading error: {0}")]36    ModelLoading(String),37 38    #[error("Inference error: {0}")]39    Inference(String),40 41    #[error("Vocoder error: {0}")]42    Vocoder(String),43 44    #[error("Unsupported operation: {0}")]45    Unsupported(String),46 47    #[error("Download error: {0}")]48    Download(String),49 50    #[error("Shape mismatch: expected {expected}, got {actual}")]51    ShapeMismatch { expected: String, actual: String },52}53 54/// Result type for IndexTTS operations55pub type Result<T> = std::result::Result<T, Error>;56 57impl From<serde_yaml::Error> for Error {58    fn from(err: serde_yaml::Error) -> Self {59        Error::Config(err.to_string())60    }61}62 63impl From<serde_json::Error> for Error {64    fn from(err: serde_json::Error) -> Self {65        Error::Config(err.to_string())66    }67}68 69impl From<hound::Error> for Error {70    fn from(err: hound::Error) -> Self {71        Error::Audio(err.to_string())72    }73}74 75impl From<ndarray::ShapeError> for Error {76    fn from(err: ndarray::ShapeError) -> Self {77        Error::ShapeMismatch {78            expected: "valid shape".into(),79            actual: err.to_string(),80        }81    }82}83 84impl From<regex::Error> for Error {85    fn from(err: regex::Error) -> Self {86        Error::Text(err.to_string())87    }88}89