Spaces:
Sleeping
Sleeping
Upload infer_serverless.py
Browse files259 unmodified lines260261262263264265266267263264265266267269268269270271271272273274259 unmodified lines return json.dumps({"error": "File size exceeds 10 MB"}), 400
content_type_format_map = { 'audio/mpeg': 'mp3', 'audio/wav': 'wav', 'audio/x-wav': 'wav', 'audio/mp4': 'mp4', 'audio/x-m4a': 'mp4', '.mp3': 'mp3', '.wav': 'wav', '.mp4': 'mp4', '.m4a': 'mp4', }
_, file_extension = os.path.splitext(local_file_path) audio_format = content_type_format_map.get(file_extension.lower(), 'mp3') # Default to 'mp3' if content type is unknown (or adjust as needed) audio_format = content_type_format_map.get(file.content_type, 'mp3') #audio_format = content_type_format_map.get(file.content_type, 'mp3')
# Convert the uploaded file to an audio segment audio = AudioSegment.from_file(local_file_path, format=audio_format)infer_serverless.py+7-7