Spaces:
Paused
Paused
up32
Browse files- __pycache__/app.cpython-312.pyc +0 -0
- app.py +23 -15
__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
@@ -4,6 +4,7 @@ import outetts
|
|
4 |
import io
|
5 |
import json
|
6 |
import base64
|
|
|
7 |
# Initialize the interface
|
8 |
interface = outetts.Interface(
|
9 |
config=outetts.ModelConfig.auto_config(
|
@@ -47,22 +48,29 @@ async def websocket_tts(websocket: WebSocket):
|
|
47 |
# Status: Generating linguistic features
|
48 |
await websocket.send_text(json.dumps({"generation_status": "Generating linguistic features"}))
|
49 |
# Save to buffer
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
chunk_size = 4096
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
# Final event
|
67 |
await websocket.send_text(json.dumps({
|
68 |
"data": {
|
|
|
4 |
import io
|
5 |
import json
|
6 |
import base64
|
7 |
+
import os
|
8 |
# Initialize the interface
|
9 |
interface = outetts.Interface(
|
10 |
config=outetts.ModelConfig.auto_config(
|
|
|
48 |
# Status: Generating linguistic features
|
49 |
await websocket.send_text(json.dumps({"generation_status": "Generating linguistic features"}))
|
50 |
# Save to buffer
|
51 |
+
import uuid
|
52 |
+
temp_path = f"temp_{uuid.uuid4().hex}.wav"
|
53 |
+
output.save(temp_path)
|
54 |
chunk_size = 4096
|
55 |
+
try:
|
56 |
+
with open(temp_path, "rb") as f:
|
57 |
+
while True:
|
58 |
+
chunk = f.read(chunk_size)
|
59 |
+
if not chunk:
|
60 |
+
break
|
61 |
+
audio_b64 = base64.b64encode(chunk).decode("ascii")
|
62 |
+
await websocket.send_text(json.dumps({
|
63 |
+
"data": {
|
64 |
+
"audio_bytes": audio_b64,
|
65 |
+
"duration": None,
|
66 |
+
"request_finished": False
|
67 |
+
}
|
68 |
+
}))
|
69 |
+
finally:
|
70 |
+
try:
|
71 |
+
os.remove(temp_path)
|
72 |
+
except FileNotFoundError:
|
73 |
+
pass
|
74 |
# Final event
|
75 |
await websocket.send_text(json.dumps({
|
76 |
"data": {
|