Rajhuggingface4253 commited on
Commit
829b125
·
verified ·
1 Parent(s): 8002d1c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -23
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
- 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
- # 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
- except Exception as e:
178
- logger.error(f"Error in producer thread: {e}")
179
- queue.put_nowait(e)
180
- finally:
181
- # Signal that production is finished by putting a sentinel value (None)
182
- queue.put_nowait(None)
 
 
 
 
 
 
 
 
 
 
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
  """