Update audio utilities

This commit is contained in:
Niko 2024-01-09 17:32:04 -07:00
parent 9861dfdb93
commit f3b155c44f
No known key found for this signature in database
GPG key ID: 3861E636EA1E0E2B
4 changed files with 110 additions and 21 deletions

View file

@ -41,6 +41,10 @@ pub enum WhisperError {
FailedToCreateState,
/// No samples were provided.
NoSamples,
/// Input and output slices were not the same length.
InputOutputLengthMismatch { input_len: usize, output_len: usize },
/// Input slice was not an even number of samples.
HalfSampleMissing(usize),
}
impl From<Utf8Error> for WhisperError {
@ -109,6 +113,24 @@ impl std::fmt::Display for WhisperError {
c_int
),
NoSamples => write!(f, "Input sample buffer was empty."),
InputOutputLengthMismatch {
output_len,
input_len,
} => {
write!(
f,
"Input and output slices were not the same length. Input: {}, Output: {}",
input_len, output_len
)
}
HalfSampleMissing(size) => {
write!(
f,
"Input slice was not an even number of samples, got {}, expected {}",
size,
size + 1
)
}
}
}
}