mecomp_analysis/
errors.rs1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum AnalysisError {
5 #[error("Failed to open file: {0}")]
6 FileOpenError(#[from] std::io::Error),
7 #[error("Failed to decode audio: {0}")]
8 DecodeError(#[from] symphonia::core::errors::Error),
9 #[error("Failed to resample audio: {0}")]
10 ResampleError(#[from] rubato::ResampleError),
11 #[error("Failed to create resampler: {0}")]
12 ResamplerConstructionError(#[from] rubato::ResamplerConstructionError),
13 #[error("Failure During Analysis: {0}")]
14 AnalysisError(String),
15 #[error("Samples are empty or too short")]
16 EmptySamples,
17 #[error("Audio Source length is unknown or infinite")]
18 IndeterminantDuration,
19 #[error("Too many or too little features were provided at the end of the analysis")]
20 InvalidFeaturesLen,
21 #[error("Embedding Error: {0}")]
22 EmbeddingError(#[from] ort::Error),
23 #[error("Send Error")]
24 SendError,
25}
26
27pub type AnalysisResult<T> = Result<T, AnalysisError>;
28
29#[derive(Error, Debug)]
30pub enum ClusteringError {
31 #[error("Error during GMM clustering: {0}")]
32 Gmm(#[from] linfa_clustering::GmmError),
33 #[error("Error during KMeans clustering: {0}")]
34 KMeans(#[from] linfa_clustering::KMeansError),
35 #[error("Library too small to cluster")]
36 SmallLibrary,
37 #[error("Optimal k could not be found below k={0}")]
38 OptimalKNotFound(usize),
39 #[error("Failed to project data {0}")]
40 ProjectionError(#[from] ProjectionError),
41}
42
43#[derive(Error, Debug)]
44pub enum ProjectionError {
45 #[error("with T-SNE: {0}")]
46 TSneError(#[from] linfa_tsne::TSneError),
47 #[error("with PCA: {0}")]
48 PcaError(#[from] linfa_reduction::ReductionError),
49}