Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -161,7 +161,34 @@ def predict_full(model, text, melody, duration, topk, topp, temperature, cfg_coe
|
|
161 |
outs = _do_predictions(
|
162 |
[text], [melody], duration, progress=True,
|
163 |
top_k=topk, top_p=topp, temperature=temperature, cfg_coef=cfg_coef)
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
|
166 |
|
167 |
def toggle_audio_src(choice):
|
@@ -204,7 +231,12 @@ def ui_full(launch_kwargs):
|
|
204 |
temperature = gr.Number(label="Temperature", value=1.0, interactive=True)
|
205 |
cfg_coef = gr.Number(label="Classifier Free Guidance", value=3.0, interactive=True)
|
206 |
with gr.Column():
|
207 |
-
output =
|
|
|
|
|
|
|
|
|
|
|
208 |
submit.click(predict_full,
|
209 |
inputs=[model, text, melody, duration, topk, topp, temperature, cfg_coef],
|
210 |
outputs=[output])
|
|
|
161 |
outs = _do_predictions(
|
162 |
[text], [melody], duration, progress=True,
|
163 |
top_k=topk, top_p=topp, temperature=temperature, cfg_coef=cfg_coef)
|
164 |
+
|
165 |
+
return inference(outs[0])
|
166 |
+
|
167 |
+
def inference(audio):
|
168 |
+
os.makedirs("out", exist_ok=True)
|
169 |
+
write('test.wav', audio[0], audio[1])
|
170 |
+
|
171 |
+
command = "python3 -m demucs.separate -n mdx_extra_q -d cpu test.wav -o out"
|
172 |
+
process = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
173 |
+
print("Demucs script output:", process.stdout.decode())
|
174 |
+
|
175 |
+
os.makedirs("out", exist_ok=True)
|
176 |
+
write('test.wav', audio[0], audio[1])
|
177 |
+
result = os.system("python3 -m demucs.separate -n mdx_extra_q -d cpu test.wav -o out")
|
178 |
+
print(f"Demucs script result: {result}")
|
179 |
+
|
180 |
+
# Check if files exist before returning
|
181 |
+
files = ["./out/mdx_extra_q/test/vocals.wav",
|
182 |
+
"./out/mdx_extra_q/test/bass.wav",
|
183 |
+
"./out/mdx_extra_q/test/drums.wav",
|
184 |
+
"./out/mdx_extra_q/test/other.wav"]
|
185 |
+
for file in files:
|
186 |
+
if not os.path.isfile(file):
|
187 |
+
print(f"File not found: {file}")
|
188 |
+
else:
|
189 |
+
print(f"File exists: {file}")
|
190 |
+
|
191 |
+
return files
|
192 |
|
193 |
|
194 |
def toggle_audio_src(choice):
|
|
|
231 |
temperature = gr.Number(label="Temperature", value=1.0, interactive=True)
|
232 |
cfg_coef = gr.Number(label="Classifier Free Guidance", value=3.0, interactive=True)
|
233 |
with gr.Column():
|
234 |
+
output = [
|
235 |
+
gr.Audio(audio_file1, label="Generated Music 1"),
|
236 |
+
gr.Audio(audio_file2, label="Generated Music 2"),
|
237 |
+
gr.Audio(audio_file3, label="Generated Music 3"),
|
238 |
+
gr.Audio(audio_file4, label="Generated Music 4")
|
239 |
+
]
|
240 |
submit.click(predict_full,
|
241 |
inputs=[model, text, melody, duration, topk, topp, temperature, cfg_coef],
|
242 |
outputs=[output])
|