fix: Edge TTS音频路径修复,静态文件挂载到main.py顶层

This commit is contained in:
2026-04-22 23:23:11 +08:00
parent 37242cdf82
commit 6c8d1e676c
5 changed files with 6 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -13,6 +13,9 @@ from fastapi.staticfiles import StaticFiles
# 导入后端服务 # 导入后端服务
from server import app as api_app from server import app as api_app
# 确保音频缓存目录存在
os.makedirs("audio_cache", exist_ok=True)
# 主应用 # 主应用
app = FastAPI(title="Voice Chat Web") app = FastAPI(title="Voice Chat Web")
@@ -51,6 +54,9 @@ async def proxy_chattts_audio(filename: str):
return Response(content=f'{"detail":"{str(e)}"}'.encode(), status_code=500, media_type="application/json") return Response(content=f'{"detail":"{str(e)}"}'.encode(), status_code=500, media_type="application/json")
# 挂载音频文件目录Edge TTS 生成的 MP3
app.mount("/audio", StaticFiles(directory="audio_cache"), name="audio")
# 挂载 API # 挂载 API
app.mount("/api", api_app) app.mount("/api", api_app)