added Infos and prints
Browse files
app.py
CHANGED
@@ -97,11 +97,13 @@ def wipe_npz_file(folder_path):
|
|
97 |
print("YO")
|
98 |
|
99 |
def split_process(audio, chosen_out_track):
|
|
|
100 |
os.makedirs("out", exist_ok=True)
|
101 |
write('test.wav', audio[0], audio[1])
|
102 |
os.system("python3 -m demucs.separate -n mdx_extra_q -j 4 test.wav -o out")
|
103 |
#return "./out/mdx_extra_q/test/vocals.wav","./out/mdx_extra_q/test/bass.wav","./out/mdx_extra_q/test/drums.wav","./out/mdx_extra_q/test/other.wav"
|
104 |
if chosen_out_track == "vocals":
|
|
|
105 |
return "./out/mdx_extra_q/test/vocals.wav"
|
106 |
elif chosen_out_track == "bass":
|
107 |
return "./out/mdx_extra_q/test/bass.wav"
|
@@ -128,9 +130,11 @@ def infer(prompt, input_wav_file, clean_audio, hidden_numpy_audio):
|
|
128 |
new_name = os.path.splitext(os.path.basename(input_wav_file))[0]
|
129 |
print(f"FILE BASENAME is: {new_name}")
|
130 |
if os.path.exists(os.path.join("bark_voices", f"{new_name}_cleaned")):
|
|
|
131 |
check_name = os.path.join("bark_voices", f"{new_name}_cleaned")
|
132 |
source_path = os.path.join(check_name, f"{new_name}_cleaned.wav")
|
133 |
else:
|
|
|
134 |
source_path = split_process(hidden_numpy_audio, "vocals")
|
135 |
|
136 |
# Rename the file
|
@@ -138,6 +142,7 @@ def infer(prompt, input_wav_file, clean_audio, hidden_numpy_audio):
|
|
138 |
os.rename(source_path, new_path)
|
139 |
source_path = new_path
|
140 |
else :
|
|
|
141 |
# Path to your WAV file
|
142 |
source_path = input_wav_file
|
143 |
|
@@ -156,6 +161,8 @@ def infer(prompt, input_wav_file, clean_audio, hidden_numpy_audio):
|
|
156 |
# Move the WAV file to the new directory
|
157 |
shutil.move(source_path, os.path.join(destination_path, f"{file_name}.wav"))
|
158 |
|
|
|
|
|
159 |
# Split the text into sentences based on common punctuation marks
|
160 |
sentences = re.split(r'(?<=[.!?])\s+', prompt)
|
161 |
|
@@ -164,7 +171,8 @@ def infer(prompt, input_wav_file, clean_audio, hidden_numpy_audio):
|
|
164 |
|
165 |
# Join the selected sentences back into a single string
|
166 |
limited_prompt = ' '.join(first_nb_sentences)
|
167 |
-
|
|
|
168 |
tts.tts_to_file(text=limited_prompt,
|
169 |
file_path="output.wav",
|
170 |
voice_dir="bark_voices/",
|
@@ -178,11 +186,11 @@ def infer(prompt, input_wav_file, clean_audio, hidden_numpy_audio):
|
|
178 |
print(item)
|
179 |
|
180 |
tts_video = gr.make_waveform(audio="output.wav")
|
181 |
-
|
182 |
return "output.wav", tts_video, gr.update(value=f"bark_voices/{file_name}/{contents[1]}", visible=True), gr.Group.update(visible=True), destination_path
|
183 |
|
184 |
def infer_from_c(prompt, c_name):
|
185 |
-
|
186 |
# Split the text into sentences based on common punctuation marks
|
187 |
sentences = re.split(r'(?<=[.!?])\s+', prompt)
|
188 |
|
@@ -198,7 +206,7 @@ def infer_from_c(prompt, c_name):
|
|
198 |
speaker=f"{c_name}")
|
199 |
|
200 |
tts_video = gr.make_waveform(audio="output.wav")
|
201 |
-
|
202 |
return "output.wav", tts_video, gr.update(value=f"examples/library/{c_name}/{c_name}.npz", visible=True), gr.Group.update(visible=True)
|
203 |
|
204 |
|
|
|
97 |
print("YO")
|
98 |
|
99 |
def split_process(audio, chosen_out_track):
|
100 |
+
gr.Info("Cleaning your audio sample")
|
101 |
os.makedirs("out", exist_ok=True)
|
102 |
write('test.wav', audio[0], audio[1])
|
103 |
os.system("python3 -m demucs.separate -n mdx_extra_q -j 4 test.wav -o out")
|
104 |
#return "./out/mdx_extra_q/test/vocals.wav","./out/mdx_extra_q/test/bass.wav","./out/mdx_extra_q/test/drums.wav","./out/mdx_extra_q/test/other.wav"
|
105 |
if chosen_out_track == "vocals":
|
106 |
+
print("Audio sample cleaned")
|
107 |
return "./out/mdx_extra_q/test/vocals.wav"
|
108 |
elif chosen_out_track == "bass":
|
109 |
return "./out/mdx_extra_q/test/bass.wav"
|
|
|
130 |
new_name = os.path.splitext(os.path.basename(input_wav_file))[0]
|
131 |
print(f"FILE BASENAME is: {new_name}")
|
132 |
if os.path.exists(os.path.join("bark_voices", f"{new_name}_cleaned")):
|
133 |
+
print("This file has already been cleaned")
|
134 |
check_name = os.path.join("bark_voices", f"{new_name}_cleaned")
|
135 |
source_path = os.path.join(check_name, f"{new_name}_cleaned.wav")
|
136 |
else:
|
137 |
+
print("This file is new, we need to clean and store it")
|
138 |
source_path = split_process(hidden_numpy_audio, "vocals")
|
139 |
|
140 |
# Rename the file
|
|
|
142 |
os.rename(source_path, new_path)
|
143 |
source_path = new_path
|
144 |
else :
|
145 |
+
print("We do NOT want to clean audio sample")
|
146 |
# Path to your WAV file
|
147 |
source_path = input_wav_file
|
148 |
|
|
|
161 |
# Move the WAV file to the new directory
|
162 |
shutil.move(source_path, os.path.join(destination_path, f"{file_name}.wav"))
|
163 |
|
164 |
+
# โโโโโ
|
165 |
+
|
166 |
# Split the text into sentences based on common punctuation marks
|
167 |
sentences = re.split(r'(?<=[.!?])\s+', prompt)
|
168 |
|
|
|
171 |
|
172 |
# Join the selected sentences back into a single string
|
173 |
limited_prompt = ' '.join(first_nb_sentences)
|
174 |
+
|
175 |
+
gr.Info("Generating audio from prompt")
|
176 |
tts.tts_to_file(text=limited_prompt,
|
177 |
file_path="output.wav",
|
178 |
voice_dir="bark_voices/",
|
|
|
186 |
print(item)
|
187 |
|
188 |
tts_video = gr.make_waveform(audio="output.wav")
|
189 |
+
print("FINISHED")
|
190 |
return "output.wav", tts_video, gr.update(value=f"bark_voices/{file_name}/{contents[1]}", visible=True), gr.Group.update(visible=True), destination_path
|
191 |
|
192 |
def infer_from_c(prompt, c_name):
|
193 |
+
print(f"USING VOICE LIBRARY: {c_name}")
|
194 |
# Split the text into sentences based on common punctuation marks
|
195 |
sentences = re.split(r'(?<=[.!?])\s+', prompt)
|
196 |
|
|
|
206 |
speaker=f"{c_name}")
|
207 |
|
208 |
tts_video = gr.make_waveform(audio="output.wav")
|
209 |
+
print("FINISHED")
|
210 |
return "output.wav", tts_video, gr.update(value=f"examples/library/{c_name}/{c_name}.npz", visible=True), gr.Group.update(visible=True)
|
211 |
|
212 |
|