fix: Edge TTS音频路径修复,静态文件挂载到main.py顶层
This commit is contained in:
BIN
audio_cache/0fba5247e6044c9490f447ed44b0ae38.mp3
Normal file
BIN
audio_cache/0fba5247e6044c9490f447ed44b0ae38.mp3
Normal file
Binary file not shown.
BIN
audio_cache/a01d80c36df943088e5a6c25a5b070c2.mp3
Normal file
BIN
audio_cache/a01d80c36df943088e5a6c25a5b070c2.mp3
Normal file
Binary file not shown.
BIN
audio_cache/cd2f3e5b5ade443f84ca628118b22e1a.mp3
Normal file
BIN
audio_cache/cd2f3e5b5ade443f84ca628118b22e1a.mp3
Normal file
Binary file not shown.
BIN
logs/server.log
BIN
logs/server.log
Binary file not shown.
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