smjain commited on
Commit
3aa93c6
1 Parent(s): 056048b

Upload infer_serverless.py

Browse files
Files changed (1) hide show
  1. infer_serverless.py +7 -7
infer_serverless.py CHANGED
@@ -260,15 +260,15 @@ def api_convert_voice(filename,spk_id1,unique_id):
260
  return json.dumps({"error": "File size exceeds 10 MB"}), 400
261
 
262
  content_type_format_map = {
263
- 'audio/mpeg': 'mp3',
264
- 'audio/wav': 'wav',
265
- 'audio/x-wav': 'wav',
266
- 'audio/mp4': 'mp4',
267
- 'audio/x-m4a': 'mp4',
268
  }
269
-
 
270
  # Default to 'mp3' if content type is unknown (or adjust as needed)
271
- audio_format = content_type_format_map.get(file.content_type, 'mp3')
272
 
273
  # Convert the uploaded file to an audio segment
274
  audio = AudioSegment.from_file(local_file_path, format=audio_format)
 
260
  return json.dumps({"error": "File size exceeds 10 MB"}), 400
261
 
262
  content_type_format_map = {
263
+ '.mp3': 'mp3',
264
+ '.wav': 'wav',
265
+ '.mp4': 'mp4',
266
+ '.m4a': 'mp4',
 
267
  }
268
+ _, file_extension = os.path.splitext(local_file_path)
269
+ audio_format = content_type_format_map.get(file_extension.lower(), 'mp3')
270
  # Default to 'mp3' if content type is unknown (or adjust as needed)
271
+ #audio_format = content_type_format_map.get(file.content_type, 'mp3')
272
 
273
  # Convert the uploaded file to an audio segment
274
  audio = AudioSegment.from_file(local_file_path, format=audio_format)