laubonghaudoi commited on
Commit
870ed73
·
1 Parent(s): e34297f

Default reference

Browse files
Files changed (2) hide show
  1. app.py +30 -13
  2. ref/001_001.opus +0 -0
app.py CHANGED
@@ -354,6 +354,16 @@ def create_interface():
354
  placeholder="參考音頻對應嘅粵文轉寫",
355
  lines=3
356
  )
 
 
 
 
 
 
 
 
 
 
357
 
358
  # Text to synthesize
359
  text_input = gr.Textbox(
@@ -421,7 +431,25 @@ def create_interface():
421
  max_lines=3
422
  )
423
 
424
- # Event handler
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
425
  generate_btn.click(
426
  fn=generate_tts,
427
  inputs=[
@@ -435,18 +463,6 @@ def create_interface():
435
  ],
436
  outputs=[audio_output, status_output]
437
  )
438
-
439
- # Footer
440
- gr.Markdown(f"""
441
- ---
442
- <div style="text-align: center; opacity: 0.8;">
443
- <p>Powered by <a href="https://github.com/RVC-Boss/GPT-SoVITS" target="_blank">GPT-SoVITS</a> |
444
- Fine-tuned Models: <a href="https://huggingface.co/{YOUR_MODEL_REPO}" target="_blank">{YOUR_MODEL_REPO}</a></p>
445
- <p style="font-size: 0.9em; margin-top: 10px;">
446
- 首次使用要下載模型,請耐心等待 | First use requires model download, please be patient
447
- </p>
448
- </div>
449
- """)
450
 
451
  return demo
452
 
@@ -463,6 +479,7 @@ if __name__ == "__main__":
463
  (ROOT_DIR / "GPT_SoVITS").mkdir(exist_ok=True)
464
  (ROOT_DIR / "models").mkdir(exist_ok=True)
465
  (ROOT_DIR / "cache").mkdir(exist_ok=True)
 
466
 
467
  # Create and launch interface
468
  demo = create_interface()
 
354
  placeholder="參考音頻對應嘅粵文轉寫",
355
  lines=3
356
  )
357
+
358
+ # Default reference section
359
+ with gr.Accordion("示例參考音頻", open=True):
360
+ with gr.Row():
361
+ default_ref_btn = gr.Button(
362
+ "🎙️ 使用預設參考音頻",
363
+ variant="secondary",
364
+ size="sm"
365
+ )
366
+ gr.Markdown("*張悦楷《三國演義》開場白*", elem_id="ref_desc")
367
 
368
  # Text to synthesize
369
  text_input = gr.Textbox(
 
431
  max_lines=3
432
  )
433
 
434
+ # Event handlers
435
+
436
+ # Default reference audio button
437
+ def use_default_reference():
438
+ ref_audio_path = ROOT_DIR / "ref" / "001_001.opus"
439
+ # Check if file exists
440
+ if ref_audio_path.exists():
441
+ ref_text = "各位朋友,喺講《三國演義》之前啊,我唸一首詞畀大家聽下吓。"
442
+ return str(ref_audio_path), ref_text
443
+ else:
444
+ print(f"Warning: Default reference audio not found at {ref_audio_path}")
445
+ return None, ""
446
+
447
+ default_ref_btn.click(
448
+ fn=use_default_reference,
449
+ outputs=[ref_audio_input, ref_text_input]
450
+ )
451
+
452
+ # Generate button
453
  generate_btn.click(
454
  fn=generate_tts,
455
  inputs=[
 
463
  ],
464
  outputs=[audio_output, status_output]
465
  )
 
 
 
 
 
 
 
 
 
 
 
 
466
 
467
  return demo
468
 
 
479
  (ROOT_DIR / "GPT_SoVITS").mkdir(exist_ok=True)
480
  (ROOT_DIR / "models").mkdir(exist_ok=True)
481
  (ROOT_DIR / "cache").mkdir(exist_ok=True)
482
+ (ROOT_DIR / "ref").mkdir(exist_ok=True) # For reference audio files
483
 
484
  # Create and launch interface
485
  demo = create_interface()
ref/001_001.opus ADDED
Binary file (65.4 kB). View file