mirror of https://github.com/coqui-ai/TTS.git
Uses tabs instead of columns
This commit is contained in:
parent
cc4f37e1b0
commit
7cc348ed76
|
@ -0,0 +1 @@
|
||||||
|
faster_whisper
|
|
@ -95,11 +95,8 @@ def read_logs():
|
||||||
|
|
||||||
|
|
||||||
with gr.Blocks() as demo:
|
with gr.Blocks() as demo:
|
||||||
with gr.Tab("XTTS"):
|
state_vars = gr.State()
|
||||||
state_vars = gr.State(
|
with gr.Tab("Data processing"):
|
||||||
)
|
|
||||||
with gr.Row():
|
|
||||||
with gr.Column() as col1:
|
|
||||||
upload_file = gr.Audio(
|
upload_file = gr.Audio(
|
||||||
sources="upload",
|
sources="upload",
|
||||||
label="Select here the audio files that you want to use for XTTS trainining !",
|
label="Select here the audio files that you want to use for XTTS trainining !",
|
||||||
|
@ -138,7 +135,36 @@ with gr.Blocks() as demo:
|
||||||
|
|
||||||
prompt_compute_btn = gr.Button(value="Step 1 - Create dataset.")
|
prompt_compute_btn = gr.Button(value="Step 1 - Create dataset.")
|
||||||
|
|
||||||
with gr.Column() as col2:
|
def preprocess_dataset(audio_path, language, state_vars, progress=gr.Progress(track_tqdm=True)):
|
||||||
|
# create a temp directory to save the dataset
|
||||||
|
out_path = tempfile.TemporaryDirectory().name
|
||||||
|
if audio_path is None:
|
||||||
|
# ToDo: raise an error
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
train_meta, eval_meta = format_audio_list([audio_path], target_language=language, out_path=out_path, gradio_progress=progress)
|
||||||
|
|
||||||
|
state_vars = {}
|
||||||
|
state_vars["train_csv"] = train_meta
|
||||||
|
state_vars["eval_csv"] = eval_meta
|
||||||
|
print(state_vars)
|
||||||
|
return "Dataset Processed!", state_vars
|
||||||
|
|
||||||
|
prompt_compute_btn.click(
|
||||||
|
fn=preprocess_dataset,
|
||||||
|
inputs=[
|
||||||
|
upload_file,
|
||||||
|
lang,
|
||||||
|
state_vars,
|
||||||
|
],
|
||||||
|
outputs=[
|
||||||
|
progress_data,
|
||||||
|
state_vars,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
with gr.Tab("Fine-tuning XTTS"):
|
||||||
num_epochs = gr.Slider(
|
num_epochs = gr.Slider(
|
||||||
label="num_epochs",
|
label="num_epochs",
|
||||||
minimum=1,
|
minimum=1,
|
||||||
|
@ -163,7 +189,24 @@ with gr.Blocks() as demo:
|
||||||
demo.load(read_logs, None, logs_tts_train, every=1)
|
demo.load(read_logs, None, logs_tts_train, every=1)
|
||||||
train_btn = gr.Button(value="Step 2 - Run the training")
|
train_btn = gr.Button(value="Step 2 - Run the training")
|
||||||
|
|
||||||
with gr.Column() as col3:
|
def train_model(language, num_epochs, batch_size, state_vars, output_path="./", progress=gr.Progress(track_tqdm=True)):
|
||||||
|
# state_vars = {'train_csv': '/tmp/tmprh4k_vou/metadata_train.csv', 'eval_csv': '/tmp/tmprh4k_vou/metadata_eval.csv'}
|
||||||
|
|
||||||
|
config_path, original_xtts_checkpoint, vocab_file, exp_path, speaker_wav = train_gpt(language, num_epochs, batch_size, state_vars["train_csv"], state_vars["eval_csv"], output_path=output_path)
|
||||||
|
# copy original files to avoid parameters changes issues
|
||||||
|
os.system(f"cp {config_path} {exp_path}")
|
||||||
|
os.system(f"cp {vocab_file} {exp_path}")
|
||||||
|
|
||||||
|
ft_xtts_checkpoint = os.path.join(exp_path, "best_model.pth")
|
||||||
|
state_vars["config_path"] = config_path
|
||||||
|
state_vars["original_xtts_checkpoint"] = original_xtts_checkpoint
|
||||||
|
state_vars["vocab_file"] = vocab_file
|
||||||
|
state_vars["ft_xtts_checkpoint"] = ft_xtts_checkpoint
|
||||||
|
state_vars["speaker_audio_file"] = speaker_wav
|
||||||
|
return "Model training done!", state_vars, config_path, vocab_file, ft_xtts_checkpoint, speaker_wav
|
||||||
|
|
||||||
|
|
||||||
|
with gr.Tab("Inference"):
|
||||||
xtts_checkpoint = gr.Textbox(
|
xtts_checkpoint = gr.Textbox(
|
||||||
label="XTTS checkpoint path:",
|
label="XTTS checkpoint path:",
|
||||||
value="",
|
value="",
|
||||||
|
@ -212,51 +255,6 @@ with gr.Blocks() as demo:
|
||||||
reference_audio = gr.Audio(label="Reference audio used.")
|
reference_audio = gr.Audio(label="Reference audio used.")
|
||||||
|
|
||||||
|
|
||||||
def preprocess_dataset(audio_path, language, state_vars, progress=gr.Progress(track_tqdm=True)):
|
|
||||||
# create a temp directory to save the dataset
|
|
||||||
out_path = tempfile.TemporaryDirectory().name
|
|
||||||
if audio_path is None:
|
|
||||||
# ToDo: raise an error
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
train_meta, eval_meta = format_audio_list([audio_path], target_language=language, out_path=out_path, gradio_progress=progress)
|
|
||||||
|
|
||||||
state_vars = {}
|
|
||||||
state_vars["train_csv"] = train_meta
|
|
||||||
state_vars["eval_csv"] = eval_meta
|
|
||||||
print(state_vars)
|
|
||||||
return "Dataset Processed!", state_vars
|
|
||||||
|
|
||||||
prompt_compute_btn.click(
|
|
||||||
fn=preprocess_dataset,
|
|
||||||
inputs=[
|
|
||||||
upload_file,
|
|
||||||
lang,
|
|
||||||
state_vars,
|
|
||||||
],
|
|
||||||
outputs=[
|
|
||||||
progress_data,
|
|
||||||
state_vars,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
def train_model(language, num_epochs, batch_size, state_vars, output_path="./", progress=gr.Progress(track_tqdm=True)):
|
|
||||||
# state_vars = {'train_csv': '/tmp/tmprh4k_vou/metadata_train.csv', 'eval_csv': '/tmp/tmprh4k_vou/metadata_eval.csv'}
|
|
||||||
|
|
||||||
config_path, original_xtts_checkpoint, vocab_file, exp_path, speaker_wav = train_gpt(language, num_epochs, batch_size, state_vars["train_csv"], state_vars["eval_csv"], output_path=output_path)
|
|
||||||
# copy original files to avoid parameters changes issues
|
|
||||||
os.system(f"cp {config_path} {exp_path}")
|
|
||||||
os.system(f"cp {vocab_file} {exp_path}")
|
|
||||||
|
|
||||||
ft_xtts_checkpoint = os.path.join(exp_path, "best_model.pth")
|
|
||||||
state_vars["config_path"] = config_path
|
|
||||||
state_vars["original_xtts_checkpoint"] = original_xtts_checkpoint
|
|
||||||
state_vars["vocab_file"] = vocab_file
|
|
||||||
state_vars["ft_xtts_checkpoint"] = ft_xtts_checkpoint
|
|
||||||
state_vars["speaker_audio_file"] = speaker_wav
|
|
||||||
return "Model training done!", state_vars, config_path, vocab_file, ft_xtts_checkpoint, speaker_wav
|
|
||||||
|
|
||||||
|
|
||||||
train_btn.click(
|
train_btn.click(
|
||||||
fn=train_model,
|
fn=train_model,
|
||||||
inputs=[
|
inputs=[
|
||||||
|
@ -268,6 +266,7 @@ with gr.Blocks() as demo:
|
||||||
outputs=[progress_train, state_vars, xtts_config, xtts_vocab, xtts_checkpoint, speaker_reference_audio],
|
outputs=[progress_train, state_vars, xtts_config, xtts_vocab, xtts_checkpoint, speaker_reference_audio],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
tts_btn.click(
|
tts_btn.click(
|
||||||
fn=run_tts,
|
fn=run_tts,
|
||||||
inputs=[
|
inputs=[
|
||||||
|
|
Loading…
Reference in New Issue