Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -206,106 +206,101 @@ def toggle_audio_src(choice):
|
|
206 |
|
207 |
|
208 |
def ui_full(launch_kwargs):
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
""
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
label="Model", value="melody", interactive=True)
|
232 |
-
with gr.Row():
|
233 |
-
duration = gr.Slider(minimum=1, maximum=120, value=10, label="Duration", interactive=True)
|
234 |
-
with gr.Row():
|
235 |
-
topk = gr.Number(label="Top-k", value=250, interactive=True)
|
236 |
-
topp = gr.Number(label="Top-p", value=0, interactive=True)
|
237 |
-
temperature = gr.Number(label="Temperature", value=1.0, interactive=True)
|
238 |
-
cfg_coef = gr.Number(label="Classifier Free Guidance", value=3.0, interactive=True)
|
239 |
-
with gr.Column():
|
240 |
-
output = [
|
241 |
-
gr.Audio(label=f"Generated Music {i+1}")
|
242 |
-
for i in range(len(files))
|
243 |
-
]
|
244 |
-
output_area = gr.Output(output)
|
245 |
-
|
246 |
-
submit.click(predict_full,
|
247 |
-
inputs=[model, text, melody, duration, topk, topp, temperature, cfg_coef],
|
248 |
-
outputs=[output_area.value]) # Use value attribute of output_area
|
249 |
-
radio.change(toggle_audio_src, radio, [melody], queue=False, show_progress=False)
|
250 |
-
gr.Examples(
|
251 |
-
fn=predict_full,
|
252 |
-
examples=[
|
253 |
-
[
|
254 |
-
"An 80s driving pop song with heavy drums and synth pads in the background",
|
255 |
-
"./assets/bach.mp3",
|
256 |
-
"melody"
|
257 |
-
],
|
258 |
-
[
|
259 |
-
"A cheerful country song with acoustic guitars",
|
260 |
-
"./assets/bolero_ravel.mp3",
|
261 |
-
"melody"
|
262 |
-
],
|
263 |
-
[
|
264 |
-
"90s rock song with electric guitar and heavy drums",
|
265 |
-
None,
|
266 |
-
"medium"
|
267 |
-
],
|
268 |
-
[
|
269 |
-
"a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions",
|
270 |
-
"./assets/bach.mp3",
|
271 |
-
"melody"
|
272 |
-
],
|
273 |
-
[
|
274 |
-
"lofi slow bpm electro chill with organic samples",
|
275 |
-
None,
|
276 |
-
"medium",
|
277 |
-
],
|
278 |
],
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
for more details.
|
305 |
-
"""
|
306 |
-
)
|
307 |
|
308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
|
310 |
|
311 |
def ui_batched(launch_kwargs):
|
|
|
206 |
|
207 |
|
208 |
def ui_full(launch_kwargs):
|
209 |
+
interface = gr.Interface(
|
210 |
+
fn=predict_full,
|
211 |
+
inputs=[
|
212 |
+
gr.Radio(["melody", "medium", "small", "large"], label="Model", default="melody"),
|
213 |
+
gr.Text(label="Input Text"),
|
214 |
+
gr.Audio(source="upload", type="numpy", label="File", interactive=True, elem_id="melody-input"),
|
215 |
+
gr.Slider(minimum=1, maximum=120, default=10, label="Duration", step=1),
|
216 |
+
gr.Number(label="Top-k", default=250),
|
217 |
+
gr.Number(label="Top-p", default=0),
|
218 |
+
gr.Number(label="Temperature", default=1.0),
|
219 |
+
gr.Number(label="Classifier Free Guidance", default=3.0),
|
220 |
+
],
|
221 |
+
outputs=[
|
222 |
+
gr.Audio(label=f"Generated Music {i+1}") for i in range(len(files))
|
223 |
+
],
|
224 |
+
title="MusicGen",
|
225 |
+
description="This is your private demo for MusicGen, a simple and controllable model for music generation.",
|
226 |
+
examples=[
|
227 |
+
[
|
228 |
+
"An 80s driving pop song with heavy drums and synth pads in the background",
|
229 |
+
"./assets/bach.mp3",
|
230 |
+
"melody"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
],
|
232 |
+
[
|
233 |
+
"A cheerful country song with acoustic guitars",
|
234 |
+
"./assets/bolero_ravel.mp3",
|
235 |
+
"melody"
|
236 |
+
],
|
237 |
+
[
|
238 |
+
"90s rock song with electric guitar and heavy drums",
|
239 |
+
None,
|
240 |
+
"medium"
|
241 |
+
],
|
242 |
+
[
|
243 |
+
"a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions",
|
244 |
+
"./assets/bach.mp3",
|
245 |
+
"melody"
|
246 |
+
],
|
247 |
+
[
|
248 |
+
"lofi slow bpm electro chill with organic samples",
|
249 |
+
None,
|
250 |
+
"medium",
|
251 |
+
],
|
252 |
+
],
|
253 |
+
allow_flagging=False,
|
254 |
+
layout="vertical",
|
255 |
+
**launch_kwargs
|
256 |
+
)
|
|
|
|
|
|
|
257 |
|
258 |
+
interface.launch()
|
259 |
+
|
260 |
+
|
261 |
+
if __name__ == "__main__":
|
262 |
+
parser = argparse.ArgumentParser()
|
263 |
+
parser.add_argument(
|
264 |
+
'--listen',
|
265 |
+
type=str,
|
266 |
+
default='0.0.0.0' if 'SPACE_ID' in os.environ else '127.0.0.1',
|
267 |
+
help='IP to listen on for connections to Gradio',
|
268 |
+
)
|
269 |
+
parser.add_argument(
|
270 |
+
'--username', type=str, default='', help='Username for authentication'
|
271 |
+
)
|
272 |
+
parser.add_argument(
|
273 |
+
'--password', type=str, default='', help='Password for authentication'
|
274 |
+
)
|
275 |
+
parser.add_argument(
|
276 |
+
'--server_port',
|
277 |
+
type=int,
|
278 |
+
default=0,
|
279 |
+
help='Port to run the server listener on',
|
280 |
+
)
|
281 |
+
parser.add_argument(
|
282 |
+
'--inbrowser', action='store_true', help='Open in browser'
|
283 |
+
)
|
284 |
+
parser.add_argument(
|
285 |
+
'--share', action='store_true', help='Share the gradio UI'
|
286 |
+
)
|
287 |
+
|
288 |
+
args = parser.parse_args()
|
289 |
+
|
290 |
+
launch_kwargs = {}
|
291 |
+
launch_kwargs['server_name'] = args.listen
|
292 |
+
|
293 |
+
if args.username and args.password:
|
294 |
+
launch_kwargs['auth'] = (args.username, args.password)
|
295 |
+
if args.server_port:
|
296 |
+
launch_kwargs['server_port'] = args.server_port
|
297 |
+
if args.inbrowser:
|
298 |
+
launch_kwargs['inbrowser'] = args.inbrowser
|
299 |
+
if args.share:
|
300 |
+
launch_kwargs['share'] = args.share
|
301 |
+
|
302 |
+
# Show the interface
|
303 |
+
ui_full(launch_kwargs)
|
304 |
|
305 |
|
306 |
def ui_batched(launch_kwargs):
|