Update app.py
Browse files40 unmodified lines414243444546474849505152535455565740 unmodified lines# ---------- ENDPOINT ----------@app.post("/send_message_recive_pcm", response_class=PlainTextResponse)async def send_message_recive_pcm(message: str = Form(...)):pcm_array = text_to_pcm_array(message)return pcm_array# from pydantic import BaseModel# class Request(BaseModel):# message: str# @app.post("/send_message_recive_pcm", response_class=PlainTextResponse)# async def send_message_recive_pcm(req: Request):# pcm_array = text_to_pcm_array(req.message)# return pcm_array40 unmodified lines41424344454647484950515253545556575840 unmodified lines# ---------- ENDPOINT ----------# @app.post("/send_message_recive_pcm", response_class=PlainTextResponse)# async def send_message_recive_pcm(message: str = Form(...)):# pcm_array = text_to_pcm_array(message)# return pcm_arrayfrom fastapi.responses import StreamingResponseimport io@app.post("/send_message_recive_pcm")async def send_message_recive_pcm(message: str = Form(...)):pcm_array = text_to_pcm_array(message) # numpy array dtype=int16buf = io.BytesIO()buf.write(pcm_array.tobytes())buf.seek(0)return StreamingResponse(buf, media_type="application/octet-stream")
app.py+13-12