'commit'
This commit is contained in:
@@ -274,9 +274,10 @@ if __name__ == '__main__':
|
||||
api_secret = XF_APISECRET
|
||||
api_key = XF_APIKEY
|
||||
# audio_file = "./1.mp3"
|
||||
audio_file = r'D:\dsWork\dsProject\dsLightRag\static\audio\audio_1f0a8c47db2d4f9ba7674055a352cab8.wav'
|
||||
audio_file = r'D:\dsWork\dsProject\dsLightRag\static\audio\audio_afc0a96e382c428cba2f00e3f71e4e8f.mp3'
|
||||
# 创建评测器实例
|
||||
evaluator = XunFeiAudioEvaluator(appid, api_key, api_secret, audio_file, "english","nice to meet you.")
|
||||
txt="Hello everyone! Nice to meet you. Today is a beautiful day. I am learning English pronunciation with this tool."
|
||||
evaluator = XunFeiAudioEvaluator(appid, api_key, api_secret, audio_file, "english",txt)
|
||||
|
||||
# 运行评测
|
||||
results, eval_time = evaluator.run_evaluation()
|
||||
|
Binary file not shown.
@@ -37,13 +37,29 @@ async def save_audio(audio: UploadFile = File(...), txt: str = Form(...)):
|
||||
shutil.copy2(temp_file, file_path)
|
||||
logger.info(f"已保存文件到: {file_path}")
|
||||
|
||||
# 添加wav转mp3功能
|
||||
import subprocess
|
||||
mp3_temp_file = os.path.join(temp_dir, f"temp_{uuid.uuid4().hex}.mp3")
|
||||
try:
|
||||
# 使用ffmpeg将wav转换为mp3
|
||||
subprocess.run(
|
||||
["ffmpeg", "-i", temp_file, "-y", mp3_temp_file],
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE
|
||||
)
|
||||
logger.info(f"已将wav转换为mp3: {mp3_temp_file}")
|
||||
except subprocess.CalledProcessError as e:
|
||||
logger.error(f"ffmpeg转换失败: {e.stderr.decode()}")
|
||||
raise Exception(f"音频格式转换失败: {e.stderr.decode()}")
|
||||
|
||||
# 2. 讯飞评分
|
||||
from KeDaXunFei.XunFeiAudioEvaluator import XunFeiAudioEvaluator
|
||||
evaluator = XunFeiAudioEvaluator(
|
||||
appid=XF_APPID,
|
||||
api_key=XF_APIKEY,
|
||||
api_secret=XF_APISECRET,
|
||||
audio_file=temp_file,
|
||||
audio_file=mp3_temp_file, # 使用转换后的mp3文件
|
||||
language="english",
|
||||
txt=txt
|
||||
)
|
||||
|
Binary file not shown.
@@ -433,7 +433,7 @@
|
||||
<div class="container">
|
||||
<h1>🎙️ 英语朗读评测</h1>
|
||||
|
||||
|
||||
|
||||
<!-- 添加英文朗读文本输入区域 -->
|
||||
<div class="text-container">
|
||||
<h3 style="color: #5eead4; margin-bottom: 10px;">📝 请朗读以下文本</h3>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user