danneauxs commited on
Commit
7a8491d
·
1 Parent(s): 3cb0dc4

tts engine.py

Browse files
gradio_tabs/tab6_settings.py CHANGED
@@ -303,6 +303,77 @@ def create_config_backup():
303
  outputs=[backup_status]
304
  )
305
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
  def create_system_info():
307
  """Create system information display."""
308
 
@@ -370,6 +441,10 @@ def create_settings_tab():
370
  with gr.Tab("🔧 Configuration"):
371
  create_config_editor(config_manager)
372
 
 
 
 
 
373
  # Backup & Restore
374
  with gr.Tab("💾 Backup"):
375
  create_config_backup()
 
303
  outputs=[backup_status]
304
  )
305
 
306
+ def create_chunking_test():
307
+ """Create chunking test interface."""
308
+
309
+ with gr.Column():
310
+ gr.Markdown("## 🧪 Text Chunking Test")
311
+ gr.Markdown("Test and verify text chunking logic with custom parameters")
312
+
313
+ with gr.Row():
314
+ with gr.Column(scale=2):
315
+ test_text = gr.Textbox(
316
+ label="Test Text",
317
+ placeholder="Enter custom test text (leave blank for default)...",
318
+ lines=4
319
+ )
320
+
321
+ with gr.Column(scale=1):
322
+ max_words = gr.Slider(
323
+ minimum=5,
324
+ maximum=100,
325
+ value=30,
326
+ step=1,
327
+ label="Max Words per Chunk"
328
+ )
329
+ min_words = gr.Slider(
330
+ minimum=1,
331
+ maximum=20,
332
+ value=4,
333
+ step=1,
334
+ label="Min Words per Chunk"
335
+ )
336
+
337
+ test_btn = gr.Button("🧪 Run Chunking Test", variant="primary")
338
+
339
+ results_output = gr.Textbox(
340
+ label="Test Results",
341
+ placeholder="Chunking test results will appear here...",
342
+ lines=15,
343
+ interactive=False
344
+ )
345
+
346
+ def run_chunking_test(text_input, max_w, min_w):
347
+ """Run the chunking test"""
348
+ try:
349
+ from modules.text_processor import test_chunking
350
+ import io
351
+ import contextlib
352
+
353
+ # Capture the test_chunking output
354
+ captured_output = io.StringIO()
355
+
356
+ with contextlib.redirect_stdout(captured_output):
357
+ test_chunking(
358
+ text_input if text_input.strip() else None,
359
+ max_w,
360
+ min_w
361
+ )
362
+
363
+ # Get the captured results
364
+ results_text = captured_output.getvalue()
365
+ return results_text if results_text else "✅ Chunking test completed successfully"
366
+
367
+ except Exception as e:
368
+ return f"❌ Error running chunking test: {str(e)}"
369
+
370
+ # Wire up the test button
371
+ test_btn.click(
372
+ run_chunking_test,
373
+ inputs=[test_text, max_words, min_words],
374
+ outputs=[results_output]
375
+ )
376
+
377
  def create_system_info():
378
  """Create system information display."""
379
 
 
441
  with gr.Tab("🔧 Configuration"):
442
  create_config_editor(config_manager)
443
 
444
+ # Chunking Test
445
+ with gr.Tab("🧪 Chunking Test"):
446
+ create_chunking_test()
447
+
448
  # Backup & Restore
449
  with gr.Tab("💾 Backup"):
450
  create_config_backup()
modules/tts_engine.py CHANGED
@@ -288,7 +288,7 @@ def process_batch(
288
  chunk = chunk_data['text']
289
  boundary_type = chunk_data.get("boundary_type", "none")
290
  chunk_tts_params = chunk_data.get("tts_params", tts_params)
291
- result = process_one_chunk(i, chunk, text_chunks_dir, audio_chunks_dir, voice_path, chunk_tts_params, start_time, total_chunks, punc_norm, basename, log_run_func, log_path, device, model, asr_model, boundary_type, enable_asr)
292
  results.append(result)
293
  return results
294
 
@@ -973,8 +973,8 @@ def process_book_folder(book_dir, voice_path, tts_params, device, skip_cleanup=F
973
  global_chunk_index, chunk, text_chunks_dir, audio_chunks_dir,
974
  voice_path, chunk_tts_params, start_time, total_chunks,
975
  punc_norm, book_dir.name, log_run, log_path, device,
976
- model, asr_model, boundary_type,
977
- asr_enabled
978
  ))
979
 
980
  # Wait for batch to complete
 
288
  chunk = chunk_data['text']
289
  boundary_type = chunk_data.get("boundary_type", "none")
290
  chunk_tts_params = chunk_data.get("tts_params", tts_params)
291
+ result = process_one_chunk(i, chunk, text_chunks_dir, audio_chunks_dir, voice_path, chunk_tts_params, start_time, total_chunks, punc_norm, basename, log_run_func, log_path, device, model, asr_model, boundary_type=boundary_type, enable_asr=enable_asr)
292
  results.append(result)
293
  return results
294
 
 
973
  global_chunk_index, chunk, text_chunks_dir, audio_chunks_dir,
974
  voice_path, chunk_tts_params, start_time, total_chunks,
975
  punc_norm, book_dir.name, log_run, log_path, device,
976
+ model, asr_model, boundary_type=boundary_type,
977
+ enable_asr=asr_enabled
978
  ))
979
 
980
  # Wait for batch to complete