use thiserror::Error;
#[derive(Error, Debug)]
pub enum TTSError {
#[error(
"TTS provider error: {0}\nProvider: {1}\nDetails: This error originated from the TTS provider implementation"
)]
ProviderError(String, String),
#[error(
"Invalid voice data: {0}\nContext: {1}\nSuggestion: Ensure voice embeddings are properly downloaded from HuggingFace"
)]
InvalidVoiceData(String, String),
#[error(
"Audio generation failed: {0}\nInput text length: {1} characters\nVoice: {2}\nSuggestion: Try shorter text or check model initialization"
)]
GenerationFailed(String, usize, String),
#[error(
"Streaming not supported by this provider\nProvider: {0}\nSuggestion: Use generate_speech() instead of generate_speech_stream()"
)]
StreamingNotSupported(String),
#[error(
"IO error during TTS operation: {0}\nOperation: {1}\nPath: {2}\nSuggestion: Check file permissions and disk space"
)]
IoError(std::io::Error, String, String),
#[error(
"Model not found: '{0}'\nModel path: {1}\nSuggestion: Ensure model is downloaded from HuggingFace. Check HUGGINGFACE_TOKEN environment variable"
)]
ModelNotFound(String, String),
#[error("TTS error: {0}\nContext: {1}")]
Other(String, String),
}
pub type TTSResult<T> = Result<T, TTSError>;
#[derive(Error, Debug)]
pub enum STTError {
#[error(
"STT provider error: {0}\nProvider: {1}\nDetails: This error originated from the STT provider implementation"
)]
ProviderError(String, String),
#[error(
"Transcription failed: {0}\nAudio duration: {1}s\nSample rate: {2}Hz\nSuggestion: Check audio quality or try a different model"
)]
TranscriptionFailed(String, f32, u32),
#[error(
"Streaming not supported by this provider\nProvider: {0}\nSuggestion: Use transcribe() instead of transcribe_stream()"
)]
StreamingNotSupported(String),
#[error(
"Invalid audio format: {0}\nExpected sample rate: {1}Hz, Got: {2}Hz\nExpected channels: {3}, Got: {4}\nSuggestion: Resample audio to the correct format"
)]
InvalidAudioFormat(String, u32, u32, u16, u16),
#[error(
"IO error during STT operation: {0}\nOperation: {1}\nPath: {2}\nSuggestion: Check file permissions and disk space"
)]
IoError(std::io::Error, String, String),
#[error(
"Model not found: '{0}'\nModel path: {1}\nSuggestion: Ensure model is downloaded from HuggingFace"
)]
ModelNotFound(String, String),
#[error("STT error: {0}\nContext: {1}")]
Other(String, String),
}
pub type STTResult<T> = Result<T, STTError>;