Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import numpy as np
|
|
6 |
import soundfile as sf
|
7 |
from tempfile import NamedTemporaryFile
|
8 |
import subprocess
|
9 |
-
from pydantic import BaseModel, ValidationError
|
10 |
from typing import Optional, Tuple
|
11 |
|
12 |
# Pydantic model for audio input validation
|
@@ -14,6 +14,9 @@ class AudioInput(BaseModel):
|
|
14 |
audio_data: Optional[Tuple[int, np.ndarray]] = None # Microphone input (sample_rate, audio_data)
|
15 |
audio_path: Optional[str] = None # File upload path
|
16 |
|
|
|
|
|
|
|
17 |
def validate_audio(self):
|
18 |
"""Validate the audio input."""
|
19 |
if self.audio_data is None and self.audio_path is None:
|
|
|
6 |
import soundfile as sf
|
7 |
from tempfile import NamedTemporaryFile
|
8 |
import subprocess
|
9 |
+
from pydantic import BaseModel, ValidationError, ConfigDict
|
10 |
from typing import Optional, Tuple
|
11 |
|
12 |
# Pydantic model for audio input validation
|
|
|
14 |
audio_data: Optional[Tuple[int, np.ndarray]] = None # Microphone input (sample_rate, audio_data)
|
15 |
audio_path: Optional[str] = None # File upload path
|
16 |
|
17 |
+
# Allow arbitrary types (e.g., numpy.ndarray)
|
18 |
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
19 |
+
|
20 |
def validate_audio(self):
|
21 |
"""Validate the audio input."""
|
22 |
if self.audio_data is None and self.audio_path is None:
|