'commit'
This commit is contained in:
@@ -4,6 +4,7 @@ import uuid
|
||||
import tempfile
|
||||
import shutil
|
||||
import sys
|
||||
import logging
|
||||
from fastapi import APIRouter, UploadFile, File
|
||||
|
||||
# 配置日志
|
||||
@@ -30,7 +31,13 @@ async def save_audio(audio: UploadFile = File(...)):
|
||||
content = await audio.read()
|
||||
with open(temp_file, "wb") as f:
|
||||
f.write(content)
|
||||
|
||||
|
||||
# 3. 保存到正式目录
|
||||
file_name = f"audio_{uuid.uuid4().hex}.wav"
|
||||
file_path = os.path.join(UPLOAD_DIR, file_name)
|
||||
shutil.copy2(temp_file, file_path)
|
||||
logger.info(f"已保存文件到: {file_path}")
|
||||
|
||||
# 2. 讯飞评分
|
||||
from KeDaXunFei.XunFeiAudioEvaluator import XunFeiAudioEvaluator
|
||||
evaluator = XunFeiAudioEvaluator(
|
||||
@@ -41,11 +48,8 @@ async def save_audio(audio: UploadFile = File(...)):
|
||||
language="english"
|
||||
)
|
||||
results, eval_time = evaluator.run_evaluation()
|
||||
|
||||
# 3. 保存到正式目录
|
||||
file_name = f"audio_{uuid.uuid4().hex}.wav"
|
||||
file_path = os.path.join(UPLOAD_DIR, file_name)
|
||||
shutil.copy2(temp_file, file_path)
|
||||
print(evaluator.get_evaluation_summary())
|
||||
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
|
Reference in New Issue
Block a user