checklist-agent / app /utils /audio.py
alexorlov's picture
Upload app/utils/audio.py with huggingface_hub
f18a891 verified
raw
history blame contribute delete
455 Bytes
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