autoagents_speech/
error.rs1use thiserror::Error;
2
3#[derive(Error, Debug)]
5pub enum TTSError {
6 #[error(
8 "TTS provider error: {0}\nProvider: {1}\nDetails: This error originated from the TTS provider implementation"
9 )]
10 ProviderError(String, String),
11
12 #[error(
14 "Invalid voice data: {0}\nContext: {1}\nSuggestion: Ensure voice embeddings are properly downloaded from HuggingFace"
15 )]
16 InvalidVoiceData(String, String),
17
18 #[error(
20 "Audio generation failed: {0}\nInput text length: {1} characters\nVoice: {2}\nSuggestion: Try shorter text or check model initialization"
21 )]
22 GenerationFailed(String, usize, String),
23
24 #[error(
26 "Streaming not supported by this provider\nProvider: {0}\nSuggestion: Use generate_speech() instead of generate_speech_stream()"
27 )]
28 StreamingNotSupported(String),
29
30 #[error(
32 "IO error during TTS operation: {0}\nOperation: {1}\nPath: {2}\nSuggestion: Check file permissions and disk space"
33 )]
34 IoError(std::io::Error, String, String),
35
36 #[error(
38 "Model not found: '{0}'\nModel path: {1}\nSuggestion: Ensure model is downloaded from HuggingFace. Check HUGGINGFACE_TOKEN environment variable"
39 )]
40 ModelNotFound(String, String),
41
42 #[error("TTS error: {0}\nContext: {1}")]
44 Other(String, String),
45}
46
47pub type TTSResult<T> = Result<T, TTSError>;
49
50#[derive(Error, Debug)]
52pub enum STTError {
53 #[error(
55 "STT provider error: {0}\nProvider: {1}\nDetails: This error originated from the STT provider implementation"
56 )]
57 ProviderError(String, String),
58
59 #[error(
61 "Transcription failed: {0}\nAudio duration: {1}s\nSample rate: {2}Hz\nSuggestion: Check audio quality or try a different model"
62 )]
63 TranscriptionFailed(String, f32, u32),
64
65 #[error(
67 "Streaming not supported by this provider\nProvider: {0}\nSuggestion: Use transcribe() instead of transcribe_stream()"
68 )]
69 StreamingNotSupported(String),
70
71 #[error(
73 "Invalid audio format: {0}\nExpected sample rate: {1}Hz, Got: {2}Hz\nExpected channels: {3}, Got: {4}\nSuggestion: Resample audio to the correct format"
74 )]
75 InvalidAudioFormat(String, u32, u32, u16, u16),
76
77 #[error(
79 "IO error during STT operation: {0}\nOperation: {1}\nPath: {2}\nSuggestion: Check file permissions and disk space"
80 )]
81 IoError(std::io::Error, String, String),
82
83 #[error(
85 "Model not found: '{0}'\nModel path: {1}\nSuggestion: Ensure model is downloaded from HuggingFace"
86 )]
87 ModelNotFound(String, String),
88
89 #[error("STT error: {0}\nContext: {1}")]
91 Other(String, String),
92}
93
94pub type STTResult<T> = Result<T, STTError>;