Spaces:
Sleeping
Sleeping
| from fastapi import UploadFile | |
| MAX_AUDIO_SIZE = 10 * 1024 * 1024 # 10MB | |
| ALLOWED_EXTENSIONS = (".webm", ".wav", ".mp3", ".ogg") | |
| def validate_audio_file(file: UploadFile) -> bool: | |
| """Check content type contains 'audio' or filename ends with allowed extensions.""" | |
| if file.content_type and "audio" in file.content_type: | |
| return True | |
| if file.filename: | |
| return file.filename.lower().endswith(ALLOWED_EXTENSIONS) | |
| return False | |