Spaces:
Paused
Paused
up12
Browse files- __pycache__/app.cpython-312.pyc +0 -0
- app.py +1 -39
__pycache__/app.cpython-312.pyc
CHANGED
Binary files a/__pycache__/app.cpython-312.pyc and b/__pycache__/app.cpython-312.pyc differ
|
|
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from fastapi import FastAPI, Request
|
2 |
from fastapi.responses import StreamingResponse, JSONResponse
|
3 |
import outetts
|
4 |
import io
|
@@ -51,41 +51,3 @@ async def websocket_tts(websocket: WebSocket):
|
|
51 |
except WebSocketDisconnect:
|
52 |
pass
|
53 |
|
54 |
-
|
55 |
-
'''
|
56 |
-
@app.post("/tts")
|
57 |
-
async def tts_endpoint(request: Request):
|
58 |
-
"""
|
59 |
-
Accepts JSON {"text": "..."} and streams the generated audio as WAV.
|
60 |
-
"""
|
61 |
-
try:
|
62 |
-
data = await request.json()
|
63 |
-
text = data.get("text")
|
64 |
-
if not text:
|
65 |
-
return JSONResponse({"error": "Missing 'text' in request"}, status_code=400)
|
66 |
-
|
67 |
-
# Generate audio from text
|
68 |
-
output = interface.generate(
|
69 |
-
config=outetts.GenerationConfig(
|
70 |
-
text=text,
|
71 |
-
generation_type=outetts.GenerationType.CHUNKED,
|
72 |
-
speaker=speaker,
|
73 |
-
sampler_config=outetts.SamplerConfig(
|
74 |
-
temperature=0.4
|
75 |
-
),
|
76 |
-
)
|
77 |
-
)
|
78 |
-
audio_buffer = io.BytesIO()
|
79 |
-
output.save(audio_buffer)
|
80 |
-
audio_buffer.seek(0)
|
81 |
-
|
82 |
-
def audio_stream():
|
83 |
-
yield audio_buffer.read()
|
84 |
-
|
85 |
-
return StreamingResponse(audio_stream(), media_type="audio/wav")
|
86 |
-
except Exception as e:
|
87 |
-
return JSONResponse({"error": str(e)}, status_code=500)
|
88 |
-
'''
|
89 |
-
|
90 |
-
|
91 |
-
# WebSocket endpoint removed; use POST /tts for TTS requests.
|
|
|
1 |
+
from fastapi import FastAPI, Request, WebSocket, WebSocketDisconnect
|
2 |
from fastapi.responses import StreamingResponse, JSONResponse
|
3 |
import outetts
|
4 |
import io
|
|
|
51 |
except WebSocketDisconnect:
|
52 |
pass
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|