drewThomasson commited on
Commit
c0892e4
·
verified ·
1 Parent(s): bc1eafc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -588,7 +588,7 @@ from tqdm import tqdm
588
 
589
  # Convert chapters to audio using XTTS
590
 
591
- def convert_chapters_to_audio_custom_model(chapters_dir, output_audio_dir, target_voice_path=None, language=None, custom_model=None, temperature, length_penalty, repetition_penalty, top_k, top_p, speed, enable_text_splitting):
592
 
593
  if target_voice_path==None:
594
  target_voice_path = default_target_voice_path
@@ -657,7 +657,7 @@ def convert_chapters_to_audio_custom_model(chapters_dir, output_audio_dir, targe
657
 
658
 
659
 
660
- def convert_chapters_to_audio_standard_model(chapters_dir, output_audio_dir, target_voice_path=None, language="en", temperature, length_penalty, repetition_penalty, top_k, top_p, speed, enable_text_splitting):
661
  selected_tts_model = "tts_models/multilingual/multi-dataset/xtts_v2"
662
  tts = TTS(selected_tts_model, progress_bar=False).to(device)
663
 
@@ -708,7 +708,7 @@ def convert_chapters_to_audio_standard_model(chapters_dir, output_audio_dir, tar
708
 
709
 
710
  # Define the functions to be used in the Gradio interface
711
- def convert_ebook_to_audio(ebook_file, target_voice_file, language, use_custom_model, custom_model_file, custom_config_file, custom_vocab_file, custom_model_url=None, temperature, length_penalty, repetition_penalty, top_k, top_p, speed, enable_text_splitting, progress=gr.Progress()):
712
 
713
  ebook_file_path = args.ebook if args.ebook else ebook_file.name
714
  target_voice = args.voice if args.voice else target_voice_file.name if target_voice_file else None
@@ -780,9 +780,9 @@ def convert_ebook_to_audio(ebook_file, target_voice_file, language, use_custom_m
780
  print(f"Error updating progress: {e}")
781
 
782
  if use_custom_model:
783
- convert_chapters_to_audio_custom_model(chapters_directory, output_audio_directory, target_voice, language, custom_model, temperature, length_penalty, repetition_penalty, top_k, top_p, speed, enable_text_splitting)
784
  else:
785
- convert_chapters_to_audio_standard_model(chapters_directory, output_audio_directory, target_voice, language, temperature, length_penalty, repetition_penalty, top_k, top_p, speed, enable_text_splitting)
786
 
787
  try:
788
  progress(0.9, desc="Creating M4B from chapters")
@@ -940,12 +940,11 @@ def run_gradio_interface():
940
  convert_ebook_to_audio,
941
  inputs=[
942
  ebook_file, target_voice_file, language, use_custom_model, custom_model_file, custom_config_file,
943
- custom_vocab_file, custom_model_url, temperature, length_penalty, repetition_penalty,
944
- top_k, top_p, speed, enable_text_splitting
945
  ],
946
  outputs=[output, audio_player]
947
  )
948
-
949
  use_custom_model.change(
950
  lambda x: [gr.update(visible=x)] * 4,
951
  inputs=[use_custom_model],
@@ -1007,7 +1006,8 @@ if args.headless:
1007
 
1008
 
1009
  # Example headless execution
1010
- convert_ebook_to_audio(ebook_file_path, target_voice, args.language, args.use_custom_model, args.custom_model, args.custom_config, args.custom_vocab, custom_model_url, args.temperature, args.length_penalty, args.repetition_penalty, args.top_k, args.top_p, args.speed, args.enable_text_splitting)
 
1011
 
1012
  else:
1013
  # Launch Gradio UI
 
588
 
589
  # Convert chapters to audio using XTTS
590
 
591
+ def convert_chapters_to_audio_custom_model(chapters_dir, output_audio_dir, temperature, length_penalty, repetition_penalty, top_k, top_p, speed, enable_text_splitting, target_voice_path=None, language=None, custom_model=None):
592
 
593
  if target_voice_path==None:
594
  target_voice_path = default_target_voice_path
 
657
 
658
 
659
 
660
+ def convert_chapters_to_audio_standard_model(chapters_dir, output_audio_dir, temperature, length_penalty, repetition_penalty, top_k, top_p, speed, enable_text_splitting, target_voice_path=None, language="en"):
661
  selected_tts_model = "tts_models/multilingual/multi-dataset/xtts_v2"
662
  tts = TTS(selected_tts_model, progress_bar=False).to(device)
663
 
 
708
 
709
 
710
  # Define the functions to be used in the Gradio interface
711
+ def convert_ebook_to_audio(ebook_file, target_voice_file, language, use_custom_model, custom_model_file, custom_config_file, custom_vocab_file, temperature, length_penalty, repetition_penalty, top_k, top_p, speed, enable_text_splitting, custom_model_url=None, progress=gr.Progress()):
712
 
713
  ebook_file_path = args.ebook if args.ebook else ebook_file.name
714
  target_voice = args.voice if args.voice else target_voice_file.name if target_voice_file else None
 
780
  print(f"Error updating progress: {e}")
781
 
782
  if use_custom_model:
783
+ convert_chapters_to_audio_custom_model(chapters_directory, output_audio_directory, temperature, length_penalty, repetition_penalty, top_k, top_p, speed, enable_text_splitting, target_voice, language, custom_model)
784
  else:
785
+ convert_chapters_to_audio_standard_model(chapters_directory, output_audio_directory, temperature, length_penalty, repetition_penalty, top_k, top_p, speed, enable_text_splitting, target_voice, language)
786
 
787
  try:
788
  progress(0.9, desc="Creating M4B from chapters")
 
940
  convert_ebook_to_audio,
941
  inputs=[
942
  ebook_file, target_voice_file, language, use_custom_model, custom_model_file, custom_config_file,
943
+ custom_vocab_file, temperature, length_penalty, repetition_penalty,
944
+ top_k, top_p, speed, enable_text_splitting, custom_model_url
945
  ],
946
  outputs=[output, audio_player]
947
  )
 
948
  use_custom_model.change(
949
  lambda x: [gr.update(visible=x)] * 4,
950
  inputs=[use_custom_model],
 
1006
 
1007
 
1008
  # Example headless execution
1009
+ convert_ebook_to_audio(ebook_file_path, target_voice, args.language, args.use_custom_model, args.custom_model, args.custom_config, args.custom_vocab, args.temperature, args.length_penalty, args.repetition_penalty, args.top_k, args.top_p, args.speed, args.enable_text_splitting, custom_model_url)
1010
+
1011
 
1012
  else:
1013
  # Launch Gradio UI