Update app.py
Browse files
app.py
CHANGED
|
@@ -41,18 +41,18 @@ def text_to_pcm_array(text: str) -> str:
|
|
| 41 |
|
| 42 |
|
| 43 |
# ---------- ENDPOINT ----------
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
|
| 49 |
-
from fastapi.responses import StreamingResponse
|
| 50 |
-
import io
|
| 51 |
|
| 52 |
-
@app.post("/send_message_recive_pcm")
|
| 53 |
-
async def send_message_recive_pcm(message: str = Form(...)):
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
# ---------- ENDPOINT ----------
|
| 44 |
+
@app.post("/send_message_recive_pcm", response_class=PlainTextResponse)
|
| 45 |
+
async def send_message_recive_pcm(message: str = Form(...)):
|
| 46 |
+
pcm_array = text_to_pcm_array(message)
|
| 47 |
+
return pcm_array
|
| 48 |
|
| 49 |
+
# from fastapi.responses import StreamingResponse
|
| 50 |
+
# import io
|
| 51 |
|
| 52 |
+
# @app.post("/send_message_recive_pcm")
|
| 53 |
+
# async def send_message_recive_pcm(message: str = Form(...)):
|
| 54 |
+
# pcm_array = text_to_pcm_array(message) # numpy array dtype=int16
|
| 55 |
+
# buf = io.BytesIO()
|
| 56 |
+
# buf.write(pcm_array.tobytes())
|
| 57 |
+
# buf.seek(0)
|
| 58 |
+
# return StreamingResponse(buf, media_type="application/octet-stream")
|