Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,3 @@
|
|
1 |
-
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
2 |
-
# All rights reserved.
|
3 |
-
|
4 |
-
# This source code is licensed under the license found in the
|
5 |
-
# LICENSE file in the root directory of this source tree.
|
6 |
-
|
7 |
-
# Updated to account for UI changes from https://github.com/rkfg/audiocraft/blob/long/app.py
|
8 |
-
# also released under the MIT license.
|
9 |
-
|
10 |
import argparse
|
11 |
from concurrent.futures import ProcessPoolExecutor
|
12 |
import os
|
@@ -19,6 +10,7 @@ import warnings
|
|
19 |
|
20 |
import torch
|
21 |
import gradio as gr
|
|
|
22 |
|
23 |
from audiocraft.data.audio_utils import convert_audio
|
24 |
from audiocraft.data.audio import audio_write
|
@@ -123,11 +115,11 @@ def _do_predictions(texts, melodies, duration, progress=False, **gen_kwargs):
|
|
123 |
outputs = outputs.detach().cpu().float()
|
124 |
out_files = []
|
125 |
for output in outputs:
|
126 |
-
with NamedTemporaryFile("wb", suffix=".
|
127 |
audio_write(
|
128 |
file.name, output, MODEL.sample_rate, strategy="loudness",
|
129 |
loudness_headroom_db=16, loudness_compressor=True, add_suffix=False)
|
130 |
-
out_files.append(
|
131 |
file_cleaner.add(file.name)
|
132 |
res = [out_file.result() for out_file in out_files]
|
133 |
for file in res:
|
@@ -211,7 +203,7 @@ def ui_full(launch_kwargs):
|
|
211 |
temperature = gr.Number(label="Temperature", value=1.0, interactive=True)
|
212 |
cfg_coef = gr.Number(label="Classifier Free Guidance", value=3.0, interactive=True)
|
213 |
with gr.Column():
|
214 |
-
output = gr.
|
215 |
submit.click(predict_full,
|
216 |
inputs=[model, text, melody, duration, topk, topp, temperature, cfg_coef],
|
217 |
outputs=[output])
|
@@ -305,7 +297,7 @@ def ui_batched(launch_kwargs):
|
|
305 |
with gr.Row():
|
306 |
submit = gr.Button("Generate")
|
307 |
with gr.Column():
|
308 |
-
output = gr.
|
309 |
submit.click(predict_batched, inputs=[text, melody],
|
310 |
outputs=[output], batch=True, max_batch_size=MAX_BATCH_SIZE)
|
311 |
radio.change(toggle_audio_src, radio, [melody], queue=False, show_progress=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import argparse
|
2 |
from concurrent.futures import ProcessPoolExecutor
|
3 |
import os
|
|
|
10 |
|
11 |
import torch
|
12 |
import gradio as gr
|
13 |
+
import pydub
|
14 |
|
15 |
from audiocraft.data.audio_utils import convert_audio
|
16 |
from audiocraft.data.audio import audio_write
|
|
|
115 |
outputs = outputs.detach().cpu().float()
|
116 |
out_files = []
|
117 |
for output in outputs:
|
118 |
+
with NamedTemporaryFile("wb", suffix=".mp3", delete=False) as file:
|
119 |
audio_write(
|
120 |
file.name, output, MODEL.sample_rate, strategy="loudness",
|
121 |
loudness_headroom_db=16, loudness_compressor=True, add_suffix=False)
|
122 |
+
out_files.append(file.name)
|
123 |
file_cleaner.add(file.name)
|
124 |
res = [out_file.result() for out_file in out_files]
|
125 |
for file in res:
|
|
|
203 |
temperature = gr.Number(label="Temperature", value=1.0, interactive=True)
|
204 |
cfg_coef = gr.Number(label="Classifier Free Guidance", value=3.0, interactive=True)
|
205 |
with gr.Column():
|
206 |
+
output = gr.Audio(label="Generated Music")
|
207 |
submit.click(predict_full,
|
208 |
inputs=[model, text, melody, duration, topk, topp, temperature, cfg_coef],
|
209 |
outputs=[output])
|
|
|
297 |
with gr.Row():
|
298 |
submit = gr.Button("Generate")
|
299 |
with gr.Column():
|
300 |
+
output = gr.Audio(label="Generated Music")
|
301 |
submit.click(predict_batched, inputs=[text, melody],
|
302 |
outputs=[output], batch=True, max_batch_size=MAX_BATCH_SIZE)
|
303 |
radio.change(toggle_audio_src, radio, [melody], queue=False, show_progress=False)
|