fix: Edge TTS音频路径修复,静态文件挂载到main.py顶层
This commit is contained in:
6
main.py
6
main.py
@@ -13,6 +13,9 @@ from fastapi.staticfiles import StaticFiles
|
||||
# 导入后端服务
|
||||
from server import app as api_app
|
||||
|
||||
# 确保音频缓存目录存在
|
||||
os.makedirs("audio_cache", exist_ok=True)
|
||||
|
||||
# 主应用
|
||||
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")
|
||||
|
||||
|
||||
# 挂载音频文件目录(Edge TTS 生成的 MP3)
|
||||
app.mount("/audio", StaticFiles(directory="audio_cache"), name="audio")
|
||||
|
||||
# 挂载 API
|
||||
app.mount("/api", api_app)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user