1een commited on
Commit
fba960c
·
1 Parent(s): 017b2c6
Files changed (1) hide show
  1. fixed_app.py +9 -2
fixed_app.py CHANGED
@@ -134,6 +134,12 @@ def decode_audio(audio_base64: str) -> str:
134
  raise HTTPException(status_code=500, detail="Failed to create temporary audio file")
135
 
136
  logger.info(f"音频文件已保存到: {temp_path}, 大小: {os.path.getsize(temp_path)} 字节, 格式: {file_extension}")
 
 
 
 
 
 
137
  return temp_path
138
  except HTTPException:
139
  raise
@@ -473,14 +479,15 @@ async def test_transcribe():
473
 
474
  model_path = load_model("tiny") # 使用tiny模型进行快速测试
475
 
476
- # 构建命令
477
  if "whisper-cli" in whisper_binary:
478
  cmd = [
479
  whisper_binary,
480
  "-m", model_path,
481
  "-f", test_audio_path,
482
  "-l", "en",
483
- "-otxt" # 输出文本格式
 
484
  ]
485
  else:
486
  cmd = [
 
134
  raise HTTPException(status_code=500, detail="Failed to create temporary audio file")
135
 
136
  logger.info(f"音频文件已保存到: {temp_path}, 大小: {os.path.getsize(temp_path)} 字节, 格式: {file_extension}")
137
+
138
+ # 检查格式兼容性
139
+ supported_formats = [".wav", ".flac", ".mp3", ".ogg"]
140
+ if file_extension not in supported_formats:
141
+ logger.warning(f"音频格式 {file_extension} 可能不被whisper-cli支持,支持的格式: {supported_formats}")
142
+
143
  return temp_path
144
  except HTTPException:
145
  raise
 
479
 
480
  model_path = load_model("tiny") # 使用tiny模型进行快速测试
481
 
482
+ # 构建命令 - 使用JSON输出来获取更详细的结果
483
  if "whisper-cli" in whisper_binary:
484
  cmd = [
485
  whisper_binary,
486
  "-m", model_path,
487
  "-f", test_audio_path,
488
  "-l", "en",
489
+ "-oj", # JSON输出
490
+ "-np" # 不打印额外信息
491
  ]
492
  else:
493
  cmd = [