File size: 3,364 Bytes
b5df735
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
"""
Custom error classes for audio processing
"""


class AudioProcessingError(Exception):
    """Base exception for audio processing errors"""
    
    def __init__(self, message: str, error_code: str = None, details: dict = None):
        super().__init__(message)
        self.message = message
        self.error_code = error_code or "AUDIO_PROCESSING_ERROR"
        self.details = details or {}
    
    def to_dict(self) -> dict:
        """Convert error to dictionary format"""
        return {
            "error": self.error_code,
            "message": self.message,
            "details": self.details
        }


class TranscriptionError(AudioProcessingError):
    """Exception for transcription-related errors"""
    
    def __init__(self, message: str, model: str = None, audio_file: str = None, **kwargs):
        super().__init__(message, error_code="TRANSCRIPTION_ERROR", **kwargs)
        if model:
            self.details["model"] = model
        if audio_file:
            self.details["audio_file"] = audio_file


class SpeakerDetectionError(AudioProcessingError):
    """Exception for speaker detection-related errors"""
    
    def __init__(self, message: str, audio_file: str = None, **kwargs):
        super().__init__(message, error_code="SPEAKER_DETECTION_ERROR", **kwargs)
        if audio_file:
            self.details["audio_file"] = audio_file


class SpeakerDiarizationError(AudioProcessingError):
    """Exception for speaker diarization-related errors"""
    
    def __init__(self, message: str, audio_file: str = None, **kwargs):
        super().__init__(message, error_code="SPEAKER_DIARIZATION_ERROR", **kwargs)
        if audio_file:
            self.details["audio_file"] = audio_file


class AudioSplittingError(AudioProcessingError):
    """Exception for audio splitting-related errors"""
    
    def __init__(self, message: str, audio_file: str = None, **kwargs):
        super().__init__(message, error_code="AUDIO_SPLITTING_ERROR", **kwargs)
        if audio_file:
            self.details["audio_file"] = audio_file


class FileProcessingError(AudioProcessingError):
    """Exception for file processing-related errors"""
    
    def __init__(self, message: str, file_path: str = None, **kwargs):
        super().__init__(message, error_code="FILE_PROCESSING_ERROR", **kwargs)
        if file_path:
            self.details["file_path"] = file_path


class ModelLoadError(AudioProcessingError):
    """Exception for model loading errors"""
    
    def __init__(self, message: str, model_name: str = None, **kwargs):
        super().__init__(message, error_code="MODEL_LOAD_ERROR", **kwargs)
        if model_name:
            self.details["model_name"] = model_name


class ConfigurationError(AudioProcessingError):
    """Exception for configuration-related errors"""
    
    def __init__(self, message: str, config_key: str = None, **kwargs):
        super().__init__(message, error_code="CONFIGURATION_ERROR", **kwargs)
        if config_key:
            self.details["config_key"] = config_key


class DeploymentError(AudioProcessingError):
    """Exception for deployment-related errors"""
    
    def __init__(self, message: str, service: str = None, **kwargs):
        super().__init__(message, error_code="DEPLOYMENT_ERROR", **kwargs)
        if service:
            self.details["service"] = service