Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -156,30 +156,27 @@ class NeuTTSWrapper:
|
|
| 156 |
"""
|
| 157 |
[PRODUCER] Runs in a thread, generates audio chunks, and puts them into a queue.
|
| 158 |
"""
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
for i, sentence in enumerate(sentences):
|
| 165 |
-
if not sentence.strip():
|
| 166 |
-
continue
|
| 167 |
-
|
| 168 |
-
# RESTORED: The per-chunk debug log
|
| 169 |
-
logger.debug(f"Producing chunk {i+1}/{len(sentences)}: '{sentence[:30]}...'")
|
| 170 |
-
|
| 171 |
-
with torch.no_grad():
|
| 172 |
-
audio_chunk = self.tts_model.infer(sentence, ref_s, reference_text)
|
| 173 |
-
|
| 174 |
-
# Put the raw audio chunk into the queue for the consumer
|
| 175 |
-
queue.put_nowait(audio_chunk)
|
| 176 |
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
|
| 184 |
async def stream_consumer(queue: asyncio.Queue, output_format: str):
|
| 185 |
"""
|
|
|
|
| 156 |
"""
|
| 157 |
[PRODUCER] Runs in a thread, generates audio chunks, and puts them into a queue.
|
| 158 |
"""
|
| 159 |
+
try:
|
| 160 |
+
logger.info("Starting audio production thread...")
|
| 161 |
+
ref_s = self.tts_model.encode_reference(ref_audio_path)
|
| 162 |
+
sentences = self._split_text_into_chunks(text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
+
for i, sentence in enumerate(sentences):
|
| 165 |
+
if not sentence.strip():
|
| 166 |
+
continue
|
| 167 |
+
|
| 168 |
+
logger.debug(f"Producing chunk {i+1}/{len(sentences)}: '{sentence[:30]}...'")
|
| 169 |
+
|
| 170 |
+
with torch.no_grad():
|
| 171 |
+
audio_chunk = self.tts_model.infer(sentence, ref_s, reference_text)
|
| 172 |
+
|
| 173 |
+
queue.put_nowait(audio_chunk)
|
| 174 |
+
|
| 175 |
+
except Exception as e:
|
| 176 |
+
logger.error(f"Error in producer thread: {e}")
|
| 177 |
+
queue.put_nowait(e)
|
| 178 |
+
finally:
|
| 179 |
+
queue.put_nowait(None)
|
| 180 |
|
| 181 |
async def stream_consumer(queue: asyncio.Queue, output_format: str):
|
| 182 |
"""
|