Spaces:
Running
Running
| from __future__ import annotations | |
| from typing import Any | |
| class AnalysisError(Exception): | |
| def __init__( | |
| self, | |
| code: str, | |
| message: str, | |
| *, | |
| status_code: int = 422, | |
| details: dict[str, Any] | None = None, | |
| ) -> None: | |
| super().__init__(message) | |
| self.code = code | |
| self.message = message | |
| self.status_code = status_code | |
| self.details = details | |
| class AudioDecodeError(AnalysisError): | |
| def __init__(self, message: str = "The uploaded audio could not be decoded.") -> None: | |
| super().__init__("AUDIO_DECODE_FAILED", message, status_code=422) | |
| class ModelInferenceError(AnalysisError): | |
| def __init__(self, representation: str) -> None: | |
| super().__init__( | |
| "MODEL_INFERENCE_FAILED", | |
| f"Inference failed for representation '{representation}'.", | |
| status_code=500, | |
| ) | |