Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -94,11 +94,11 @@ def build_prompt(text: str, voice: str):
|
|
94 |
|
95 |
def decode_block(block7: list[int]) -> bytes:
|
96 |
l1,l2,l3=[],[],[]
|
97 |
-
l1.append(block7[0]) #
|
98 |
-
l2.append(block7[1]) #
|
99 |
-
l3 += [block7[2], block7[3]] #
|
100 |
-
l2.append(block7[4]) #
|
101 |
-
l3 += [block7[5], block7[6]] #
|
102 |
|
103 |
with torch.no_grad():
|
104 |
codes = [torch.tensor(x, device=device).unsqueeze(0)
|
@@ -163,8 +163,9 @@ async def tts(ws: WebSocket):
|
|
163 |
buf.clear()
|
164 |
continue
|
165 |
# Only append if it's an audio token
|
|
|
166 |
if t >= AUDIO_BASE and t < AUDIO_BASE + AUDIO_SPAN:
|
167 |
-
buf.append(t
|
168 |
# masker.buffer_pos += 1 # Removed increment here
|
169 |
if len(buf) == 7:
|
170 |
await ws.send_bytes(decode_block(buf))
|
|
|
94 |
|
95 |
def decode_block(block7: list[int]) -> bytes:
|
96 |
l1,l2,l3=[],[],[]
|
97 |
+
l1.append(block7[0] - AUDIO_BASE) # Subtract AUDIO_BASE and position offset
|
98 |
+
l2.append(block7[1] - AUDIO_BASE - 4096) # Subtract AUDIO_BASE and position offset
|
99 |
+
l3 += [block7[2] - AUDIO_BASE - 8192, block7[3] - AUDIO_BASE - 12288] # Subtract AUDIO_BASE and position offsets
|
100 |
+
l2.append(block7[4] - AUDIO_BASE - 16384) # Subtract AUDIO_BASE and position offset
|
101 |
+
l3 += [block7[5] - AUDIO_BASE - 20480, block7[6] - AUDIO_BASE - 24576] # Subtract AUDIO_BASE and position offsets
|
102 |
|
103 |
with torch.no_grad():
|
104 |
codes = [torch.tensor(x, device=device).unsqueeze(0)
|
|
|
163 |
buf.clear()
|
164 |
continue
|
165 |
# Only append if it's an audio token
|
166 |
+
# Only append if it's an audio token
|
167 |
if t >= AUDIO_BASE and t < AUDIO_BASE + AUDIO_SPAN:
|
168 |
+
buf.append(t) # Append original token
|
169 |
# masker.buffer_pos += 1 # Removed increment here
|
170 |
if len(buf) == 7:
|
171 |
await ws.send_bytes(decode_block(buf))
|