fix: 前端录音改用WAV格式(PCM 16kHz),兼容模型端
This commit is contained in:
11
server.py
11
server.py
@@ -11,7 +11,6 @@ from datetime import datetime
|
||||
import aiohttp
|
||||
from fastapi import FastAPI, UploadFile, File, HTTPException, Form
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from pydantic import BaseModel
|
||||
|
||||
# 配置
|
||||
@@ -58,7 +57,7 @@ async def root():
|
||||
return {"status": "ok", "service": "voice-chat-web"}
|
||||
|
||||
|
||||
@app.get("/api/status", response_model=StatusResponse)
|
||||
@app.get("/status", response_model=StatusResponse)
|
||||
async def get_status():
|
||||
"""检查服务状态"""
|
||||
try:
|
||||
@@ -81,7 +80,7 @@ async def get_status():
|
||||
)
|
||||
|
||||
|
||||
@app.post("/api/voice/chat", response_model=VoiceResponse)
|
||||
@app.post("/voice/chat", response_model=VoiceResponse)
|
||||
async def voice_chat(
|
||||
audio: UploadFile = File(..., description="音频文件"),
|
||||
conversation_id: Optional[str] = Form(None, description="对话ID")
|
||||
@@ -131,7 +130,7 @@ async def voice_chat(
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
@app.delete("/api/conversation/{conversation_id}")
|
||||
@app.delete("/conversation/{conversation_id}")
|
||||
async def delete_conversation(conversation_id: str):
|
||||
"""删除对话"""
|
||||
try:
|
||||
@@ -146,10 +145,6 @@ async def delete_conversation(conversation_id: str):
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
# 静态文件(前端页面)
|
||||
app.mount("/static", StaticFiles(directory="static"), name="static")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
uvicorn.run(app, host="0.0.0.0", port=PORT)
|
||||
Reference in New Issue
Block a user