Spaces:
Running
on
Zero
Running
on
Zero
mrfakename
commited on
Commit
•
1755826
1
Parent(s):
aeff822
Sync from GitHub repo
Browse filesThis Space is synced from the GitHub repo: https://github.com/SWivid/F5-TTS. Please submit contributions to the Space there
src/f5_tts/train/finetune_gradio.py
CHANGED
@@ -35,7 +35,10 @@ tts_api = None
|
|
35 |
last_checkpoint = ""
|
36 |
last_device = ""
|
37 |
|
38 |
-
|
|
|
|
|
|
|
39 |
|
40 |
device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
|
41 |
|
@@ -290,7 +293,7 @@ def start_training(
|
|
290 |
elif dataset_name.endswith("_char"):
|
291 |
tokenizer_type = "char"
|
292 |
else:
|
293 |
-
|
294 |
|
295 |
dataset_name = dataset_name.replace("_pinyin", "").replace("_char", "")
|
296 |
|
@@ -300,7 +303,7 @@ def start_training(
|
|
300 |
fp16 = ""
|
301 |
|
302 |
cmd = (
|
303 |
-
f"accelerate launch {fp16}
|
304 |
f"--learning_rate {learning_rate} "
|
305 |
f"--batch_size_per_gpu {batch_size_per_gpu} "
|
306 |
f"--batch_size_type {batch_size_type} "
|
@@ -362,8 +365,8 @@ def stop_training():
|
|
362 |
|
363 |
def get_list_projects():
|
364 |
project_list = []
|
365 |
-
for folder in os.listdir(
|
366 |
-
path_folder = os.path.join(
|
367 |
if not os.path.isdir(path_folder):
|
368 |
continue
|
369 |
folder = folder.lower()
|
@@ -560,9 +563,9 @@ def create_metadata(name_project, ch_tokenizer, progress=gr.Progress()):
|
|
560 |
|
561 |
new_vocal = ""
|
562 |
if not ch_tokenizer:
|
563 |
-
file_vocab_finetune = "
|
564 |
if not os.path.isfile(file_vocab_finetune):
|
565 |
-
return "Error: Vocabulary file 'Emilia_ZH_EN_pinyin' not found!"
|
566 |
shutil.copy2(file_vocab_finetune, file_vocab)
|
567 |
|
568 |
with open(file_vocab, "r", encoding="utf-8-sig") as f:
|
@@ -732,7 +735,7 @@ def vocab_check(project_name):
|
|
732 |
|
733 |
file_metadata = os.path.join(path_project, "metadata.csv")
|
734 |
|
735 |
-
file_vocab = "
|
736 |
if not os.path.isfile(file_vocab):
|
737 |
return f"the file {file_vocab} not found !"
|
738 |
|
@@ -850,10 +853,9 @@ def get_checkpoints_project(project_name, is_gradio=True):
|
|
850 |
if project_name is None:
|
851 |
return [], ""
|
852 |
project_name = project_name.replace("_pinyin", "").replace("_char", "")
|
853 |
-
path_project_ckpts = os.path.join("ckpts", project_name)
|
854 |
|
855 |
if os.path.isdir(path_project_ckpts):
|
856 |
-
files_checkpoints = glob(os.path.join(path_project_ckpts, "*.pt"))
|
857 |
files_checkpoints = sorted(
|
858 |
files_checkpoints,
|
859 |
key=lambda x: int(os.path.basename(x).split("_")[1].split(".")[0])
|
@@ -1037,7 +1039,7 @@ for tutorial and updates check here (https://github.com/SWivid/F5-TTS/discussion
|
|
1037 |
random_sample_prepare = gr.Button("random sample")
|
1038 |
|
1039 |
with gr.Row():
|
1040 |
-
random_text_prepare = gr.Text(label="
|
1041 |
random_audio_prepare = gr.Audio(label="Audio", type="filepath")
|
1042 |
|
1043 |
random_sample_prepare.click(
|
|
|
35 |
last_checkpoint = ""
|
36 |
last_device = ""
|
37 |
|
38 |
+
path_basic = os.path.abspath(os.path.join(__file__, "../../../.."))
|
39 |
+
path_data = os.path.join(path_basic, "data")
|
40 |
+
path_project_ckpts = os.path.join(path_basic, "ckpts")
|
41 |
+
file_train = "f5_tts/train/finetune_cli.py"
|
42 |
|
43 |
device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
|
44 |
|
|
|
293 |
elif dataset_name.endswith("_char"):
|
294 |
tokenizer_type = "char"
|
295 |
else:
|
296 |
+
tokenizer_type = "custom"
|
297 |
|
298 |
dataset_name = dataset_name.replace("_pinyin", "").replace("_char", "")
|
299 |
|
|
|
303 |
fp16 = ""
|
304 |
|
305 |
cmd = (
|
306 |
+
f"accelerate launch {fp16} {file_train} --exp_name {exp_name} "
|
307 |
f"--learning_rate {learning_rate} "
|
308 |
f"--batch_size_per_gpu {batch_size_per_gpu} "
|
309 |
f"--batch_size_type {batch_size_type} "
|
|
|
365 |
|
366 |
def get_list_projects():
|
367 |
project_list = []
|
368 |
+
for folder in os.listdir(path_data):
|
369 |
+
path_folder = os.path.join(path_data, folder)
|
370 |
if not os.path.isdir(path_folder):
|
371 |
continue
|
372 |
folder = folder.lower()
|
|
|
563 |
|
564 |
new_vocal = ""
|
565 |
if not ch_tokenizer:
|
566 |
+
file_vocab_finetune = os.path.join(path_data, "Emilia_ZH_EN_pinyin/vocab.txt")
|
567 |
if not os.path.isfile(file_vocab_finetune):
|
568 |
+
return "Error: Vocabulary file 'Emilia_ZH_EN_pinyin' not found!", ""
|
569 |
shutil.copy2(file_vocab_finetune, file_vocab)
|
570 |
|
571 |
with open(file_vocab, "r", encoding="utf-8-sig") as f:
|
|
|
735 |
|
736 |
file_metadata = os.path.join(path_project, "metadata.csv")
|
737 |
|
738 |
+
file_vocab = os.path.join(path_data, "Emilia_ZH_EN_pinyin/vocab.txt")
|
739 |
if not os.path.isfile(file_vocab):
|
740 |
return f"the file {file_vocab} not found !"
|
741 |
|
|
|
853 |
if project_name is None:
|
854 |
return [], ""
|
855 |
project_name = project_name.replace("_pinyin", "").replace("_char", "")
|
|
|
856 |
|
857 |
if os.path.isdir(path_project_ckpts):
|
858 |
+
files_checkpoints = glob(os.path.join(path_project_ckpts, project_name, "*.pt"))
|
859 |
files_checkpoints = sorted(
|
860 |
files_checkpoints,
|
861 |
key=lambda x: int(os.path.basename(x).split("_")[1].split(".")[0])
|
|
|
1039 |
random_sample_prepare = gr.Button("random sample")
|
1040 |
|
1041 |
with gr.Row():
|
1042 |
+
random_text_prepare = gr.Text(label="Tokenizer")
|
1043 |
random_audio_prepare = gr.Audio(label="Audio", type="filepath")
|
1044 |
|
1045 |
random_sample_prepare.click(
|