Spaces:
Configuration error
Configuration error
unknown
commited on
Commit
·
e941976
1
Parent(s):
b7a1746
add to suport audio name , audio.wav , full audio path
Browse files
src/f5_tts/train/finetune_gradio.py
CHANGED
@@ -735,6 +735,22 @@ def format_seconds_to_hms(seconds):
|
|
735 |
return "{:02d}:{:02d}:{:02d}".format(hours, minutes, int(seconds))
|
736 |
|
737 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
738 |
def create_metadata(name_project, ch_tokenizer, progress=gr.Progress()):
|
739 |
path_project = os.path.join(path_data, name_project)
|
740 |
path_project_wavs = os.path.join(path_project, "wavs")
|
@@ -764,7 +780,7 @@ def create_metadata(name_project, ch_tokenizer, progress=gr.Progress()):
|
|
764 |
continue
|
765 |
name_audio, text = sp_line[:2]
|
766 |
|
767 |
-
file_audio =
|
768 |
|
769 |
if not os.path.isfile(file_audio):
|
770 |
error_files.append([file_audio, "error path"])
|
|
|
735 |
return "{:02d}:{:02d}:{:02d}".format(hours, minutes, int(seconds))
|
736 |
|
737 |
|
738 |
+
def get_correct_audio_path(audio_input, base_path="wavs"):
|
739 |
+
# Case 1: If it's a full path, use it directly
|
740 |
+
if os.path.isabs(audio_input):
|
741 |
+
file_audio = audio_input
|
742 |
+
|
743 |
+
# Case 2: If it has .wav but is not a full path
|
744 |
+
elif audio_input.endswith(".wav") and not os.path.isabs(audio_input):
|
745 |
+
file_audio = os.path.join(base_path, audio_input)
|
746 |
+
|
747 |
+
# Case 3: If only the name (no .wav and not a full path)
|
748 |
+
elif not audio_input.endswith(".wav") and not os.path.isabs(audio_input):
|
749 |
+
file_audio = os.path.join(base_path, audio_input + ".wav")
|
750 |
+
|
751 |
+
return file_audio
|
752 |
+
|
753 |
+
|
754 |
def create_metadata(name_project, ch_tokenizer, progress=gr.Progress()):
|
755 |
path_project = os.path.join(path_data, name_project)
|
756 |
path_project_wavs = os.path.join(path_project, "wavs")
|
|
|
780 |
continue
|
781 |
name_audio, text = sp_line[:2]
|
782 |
|
783 |
+
file_audio = get_correct_audio_path(name_audio, path_project_wavs)
|
784 |
|
785 |
if not os.path.isfile(file_audio):
|
786 |
error_files.append([file_audio, "error path"])
|