Hmjz100 commited on
Commit
1a40823
·
verified ·
1 Parent(s): 2e3e8f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -296,6 +296,10 @@ inference_model = InferenceModel('/home/user/app/checkpoints/mt3/', 'mt3')
296
 
297
 
298
  def inference(audio):
 
 
 
 
299
  filename = os.path.basename(audio) # 获取输入文件的文件名
300
  print(f"[{current_time()}] 运行:输入文件: {filename}")
301
  with open(audio, 'rb') as fd:
 
296
 
297
 
298
  def inference(audio):
299
+ mime_type, _ = mimetypes.guess_type(audio)
300
+ if not mime_type.startswith('audio'):
301
+ raise ValueError(f"文件 {audio} 不是有效的音频文件")
302
+
303
  filename = os.path.basename(audio) # 获取输入文件的文件名
304
  print(f"[{current_time()}] 运行:输入文件: {filename}")
305
  with open(audio, 'rb') as fd: