Spaces:
Sleeping
Sleeping
Upload infer_serverless.py
Browse files259 unmodified lines260261262263264265266267268269270271272273274259 unmodified linesreturn json.dumps({"error": "File size exceeds 10 MB"}), 400content_type_format_map = {'audio/mpeg': 'mp3','audio/wav': 'wav','audio/x-wav': 'wav','audio/mp4': 'mp4','audio/x-m4a': 'mp4',}# Default to 'mp3' if content type is unknown (or adjust as needed)audio_format = content_type_format_map.get(file.content_type, 'mp3')# Convert the uploaded file to an audio segmentaudio = AudioSegment.from_file(local_file_path, format=audio_format)259 unmodified lines260261262263264265266267268269270271272273274259 unmodified linesreturn json.dumps({"error": "File size exceeds 10 MB"}), 400content_type_format_map = {'.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')# Convert the uploaded file to an audio segmentaudio = AudioSegment.from_file(local_file_path, format=audio_format)
infer_serverless.py+7-7