1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! voxr error types.
//!
//! Model and kernel errors arrive from boostr and pass through unchanged in
//! [`Error::Boostr`]; the variants declared here cover what this crate adds:
//! argument checks on sample buffers, files that fail to load, audio voxr
//! does not decode, and decoded data that does not fit the pipeline.
/// voxr result type.
pub type Result<T> = std::result::Result<T, Error>;
/// voxr errors.
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// Invalid argument to an operation.
#[error("invalid argument '{arg}': {reason}")]
InvalidArgument {
/// Argument name.
arg: &'static str,
/// Why it is invalid.
reason: String,
},
/// A well-formed input uses a codec, feature or layout voxr does not
/// decode, such as multichannel or HE-AAC. Another decoder can read it.
#[error("unsupported audio: {reason}")]
Unsupported {
/// What is unsupported, and the next action.
reason: String,
},
/// A model asset (voice pack, tokenizer, checkpoint) failed to load.
#[error("model error: {reason}")]
ModelError {
/// Description of what went wrong.
reason: String,
},
/// Decoded or generated data does not fit the pipeline.
#[error("data error: {reason}")]
DataError {
/// Description of what went wrong.
reason: String,
},
/// Error from a boostr model, loader, or kernel.
#[error(transparent)]
Boostr(#[from] boostr::error::Error),
/// IO error.
#[error("io error: {0}")]
Io(#[from] std::io::Error),
}
impl From<numr::error::Error> for Error {
/// A numr error reaching this crate came through a boostr tensor call, so
/// it reports under the same variant as the rest of boostr's errors.
fn from(err: numr::error::Error) -> Self {
Self::Boostr(boostr::error::Error::from(err))
}
}