Spaces:
Runtime error
Runtime error
import argparse | |
from concurrent.futures import ProcessPoolExecutor | |
import os | |
from pathlib import Path | |
import subprocess as sp | |
from tempfile import NamedTemporaryFile | |
import time | |
import typing as tp | |
import warnings | |
import torch | |
import gradio as gr | |
from audiocraft.data.audio_utils import convert_audio | |
from audiocraft.data.audio import audio_write | |
from audiocraft.models import MusicGen | |
def ui_batched(launch_kwargs): | |
with gr.Blocks() as demo: | |
gr.Markdown( | |
""" | |
# MusicGen | |
This is the demo for [MusicGen](https://github.com/facebookresearch/audiocraft), | |
a simple and controllable model for music generation | |
presented at: ["Simple and Controllable Music Generation"](https://huggingface.co/papers/2306.05284). | |
<br/> | |
<a href="https://huggingface.co/spaces/facebook/MusicGen?duplicate=true" | |
style="display: inline-block;margin-top: .5em;margin-right: .25em;" target="_blank"> | |
<img style="margin-bottom: 0em;display: inline;margin-top: -.25em;" | |
src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a> | |
for longer sequences, more control and no queue.</p> | |
""" | |
) | |
with gr.Row(): | |
with gr.Column(): | |
with gr.Row(): | |
text = gr.Text(label="Describe your music", lines=2, interactive=True) | |
with gr.Column(): | |
radio = gr.Radio(["file", "mic"], value="file", | |
label="Condition on a melody (optional) File or Mic") | |
melody = gr.Audio(source="upload", type="numpy", label="File", | |
interactive=True, elem_id="melody-input") | |
with gr.Row(): | |
submit = gr.Button("Generate") | |
with gr.Column(): | |
output = gr.Video(label="Generated Music") | |
submit.click(predict_batched, inputs=[text, melody], | |
outputs=[output], batch=True, max_batch_size=MAX_BATCH_SIZE) | |
radio.change(toggle_audio_src, radio, [melody], queue=False, show_progress=False) |