Spaces:
Paused
Paused
up11
Browse files- Dockerfile +2 -1
- __pycache__/app.cpython-312.pyc +0 -0
- app.py +31 -0
Dockerfile
CHANGED
@@ -12,4 +12,5 @@ RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
|
12 |
|
13 |
COPY --chown=user . /app
|
14 |
|
15 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
12 |
|
13 |
COPY --chown=user . /app
|
14 |
|
15 |
+
#CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
16 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--ws", "auto", "--allow-websocket-origin", "*"]
|
__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
@@ -24,6 +24,35 @@ app = FastAPI()
|
|
24 |
def greet_json():
|
25 |
return {"Hello": "World!"}
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
@app.post("/tts")
|
28 |
async def tts_endpoint(request: Request):
|
29 |
"""
|
@@ -56,5 +85,7 @@ async def tts_endpoint(request: Request):
|
|
56 |
return StreamingResponse(audio_stream(), media_type="audio/wav")
|
57 |
except Exception as e:
|
58 |
return JSONResponse({"error": str(e)}, status_code=500)
|
|
|
|
|
59 |
|
60 |
# WebSocket endpoint removed; use POST /tts for TTS requests.
|
|
|
24 |
def greet_json():
|
25 |
return {"Hello": "World!"}
|
26 |
|
27 |
+
@app.websocket("/ws/tts")
|
28 |
+
async def websocket_tts(websocket: WebSocket):
|
29 |
+
await websocket.accept()
|
30 |
+
try:
|
31 |
+
while True:
|
32 |
+
# Empfange Text-Chunk vom Client
|
33 |
+
data = await websocket.receive_text()
|
34 |
+
# Generiere Audio aus Text
|
35 |
+
output = interface.generate(
|
36 |
+
config=outetts.GenerationConfig(
|
37 |
+
text=data,
|
38 |
+
generation_type=outetts.GenerationType.CHUNKED,
|
39 |
+
speaker=speaker,
|
40 |
+
sampler_config=outetts.SamplerConfig(
|
41 |
+
temperature=0.4
|
42 |
+
),
|
43 |
+
)
|
44 |
+
)
|
45 |
+
# Schreibe Audio in BytesIO
|
46 |
+
audio_buffer = io.BytesIO()
|
47 |
+
output.save(audio_buffer)
|
48 |
+
audio_bytes = audio_buffer.getvalue()
|
49 |
+
# Sende Audiodaten als Bytes zurück
|
50 |
+
await websocket.send_bytes(audio_bytes)
|
51 |
+
except WebSocketDisconnect:
|
52 |
+
pass
|
53 |
+
|
54 |
+
|
55 |
+
'''
|
56 |
@app.post("/tts")
|
57 |
async def tts_endpoint(request: Request):
|
58 |
"""
|
|
|
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.
|