lauraibnz commited on
Commit
3711db1
1 Parent(s): ca0c09e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -42
app.py CHANGED
@@ -34,46 +34,46 @@ def predict(midi_file=None, prompt="", negative_prompt="", audio_length_in_s=5,
34
  )
35
  return (16000, audio.audios.T)
36
 
37
- # with gr.Blocks(title="🎹 MIDI-AudioLDM", theme=gr.themes.Base(text_size=gr.themes.sizes.text_md, font=[gr.themes.GoogleFont("Nunito Sans")])) as demo:
38
- # gr.Markdown(
39
- # """
40
- # #🎹 MIDI-AudioLDM
41
- # MIDI-AudioLDM is a MIDI-conditioned text-to-audio model based on the project [AudioLDM](https://huggingface.co/spaces/haoheliu/audioldm-text-to-audio-generation). The model has been conditioned using the ControlNet architecture and has been developed within Hugging Face’s [🧨 Diffusers](https://huggingface.co/docs/diffusers/) framework. Once trained, MIDI-AudioLDM accepts a MIDI file and a text prompt as inputs and returns an audio file, which is an interpretation of the MIDI based on the given text description. This enables detailed control over different musical aspects such as notes, mood and timbre.
42
- # """)
43
- # with gr.Row():
44
- # with gr.Column():
45
- # midi = gr.File(label="midi file", file_types=[".mid"])
46
- # prompt = gr.Textbox(label="prompt")
47
- # neg_prompt = gr.Textbox(label="negative prompt")
48
- # with gr.Accordion("Advanced settings", open=False):
49
- # duration = gr.Slider(0, 30, value=5, step=5, label="duration (seconds)")
50
- # seed = gr.Number(value=42, label="seed")
51
- # cond = gr.Slider(0.0, 1.0, value=1.0, step=0.1, label="conditioning scale")
52
- # inf = gr.Slider(0, 50, value=20, step=0.1, label="inference steps")
53
- # guess = gr.Checkbox(label="guess mode")
54
- # with gr.Column():
55
- # audio = gr.Audio(label="audio")
56
- # btn = gr.Button("Generate")
57
- # btn.click(predict, inputs=[midi, prompt, neg_prompt, duration, seed, cond, inf, guess], outputs=[audio])
58
- # sr, out_audio = torchaudio.load('piano.wav')
59
- # gr.Examples(examples=[["S00.mid", "piano", "", 10, 25, 1.0, 20, False]], inputs=[midi, prompt, neg_prompt, duration, seed, cond, inf, guess], fn=predict, outputs=(sr, out_audio.numpy()))
60
 
61
- demo = gr.Interface(
62
- fn=predict, inputs=[
63
- gr.File(label="midi file", file_types=[".mid"]),
64
- "text",
65
- gr.Textbox(label="negative prompt"),
66
- gr.Slider(0, 30, value=5, step=5, label="duration (seconds)"),
67
- gr.Number(value=42, label="seed"),
68
- gr.Slider(0.0, 1.0, value=1.0, step=0.1, label="conditioning scale"),
69
- gr.Slider(0, 50, value=20, step=0.1, label="inference steps"),
70
- gr.Checkbox(label="guess mode")
71
- ],
72
- outputs="audio",
73
- examples=[["S00.mid", "piano", "", 10, 25, 1.0, 20, False]],
74
- cache_examples=True,
75
- title="🎹 MIDI-AudioLDM",
76
- description="MIDI-AudioLDM is a MIDI-conditioned text-to-audio model based on the project [AudioLDM](https://huggingface.co/spaces/haoheliu/audioldm-text-to-audio-generation). The model has been conditioned using the ControlNet architecture and has been developed within Hugging Face’s [🧨 Diffusers](https://huggingface.co/docs/diffusers/) framework. Once trained, MIDI-AudioLDM accepts a MIDI file and a text prompt as inputs and returns an audio file, which is an interpretation of the MIDI based on the given text description. This enables detailed control over different musical aspects such as notes, mood and timbre.",
77
- theme=gr.themes.Base(text_size=gr.themes.sizes.text_md, font=[gr.themes.GoogleFont("Nunito Sans")])
78
- )
79
- demo.launch()
 
34
  )
35
  return (16000, audio.audios.T)
36
 
37
+ with gr.Blocks(title="🎹 MIDI-AudioLDM", theme=gr.themes.Base(text_size=gr.themes.sizes.text_md, font=[gr.themes.GoogleFont("Nunito Sans")])) as demo:
38
+ gr.Markdown(
39
+ """
40
+ #🎹 MIDI-AudioLDM
41
+ MIDI-AudioLDM is a MIDI-conditioned text-to-audio model based on the project [AudioLDM](https://huggingface.co/spaces/haoheliu/audioldm-text-to-audio-generation). The model has been conditioned using the ControlNet architecture and has been developed within Hugging Face’s [🧨 Diffusers](https://huggingface.co/docs/diffusers/) framework. Once trained, MIDI-AudioLDM accepts a MIDI file and a text prompt as inputs and returns an audio file, which is an interpretation of the MIDI based on the given text description. This enables detailed control over different musical aspects such as notes, mood and timbre.
42
+ """)
43
+ with gr.Row():
44
+ with gr.Column():
45
+ midi = gr.File(label="midi file", file_types=[".mid"])
46
+ prompt = gr.Textbox(label="prompt")
47
+ neg_prompt = gr.Textbox(label="negative prompt")
48
+ with gr.Accordion("Advanced settings", open=False):
49
+ duration = gr.Slider(0, 30, value=5, step=5, label="duration (seconds)")
50
+ seed = gr.Number(value=42, label="seed")
51
+ cond = gr.Slider(0.0, 1.0, value=1.0, step=0.1, label="conditioning scale")
52
+ inf = gr.Slider(0, 50, value=20, step=0.1, label="inference steps")
53
+ guess = gr.Checkbox(label="guess mode")
54
+ with gr.Column():
55
+ audio = gr.Audio(label="audio")
56
+ btn = gr.Button("Generate")
57
+ btn.click(predict, inputs=[midi, prompt, neg_prompt, duration, seed, cond, inf, guess], outputs=[audio])
58
+ out_audio, sr = torchaudio.load('piano.wav')
59
+ gr.Examples(examples=[["S00.mid", "piano", "", 10, 25, 1.0, 20, False]], inputs=[midi, prompt, neg_prompt, duration, seed, cond, inf, guess], fn=predict, outputs=(sr, out_audio.numpy()))
60
 
61
+ # demo = gr.Interface(
62
+ # fn=predict, inputs=[
63
+ # gr.File(label="midi file", file_types=[".mid"]),
64
+ # "text",
65
+ # gr.Textbox(label="negative prompt"),
66
+ # gr.Slider(0, 30, value=5, step=5, label="duration (seconds)"),
67
+ # gr.Number(value=42, label="seed"),
68
+ # gr.Slider(0.0, 1.0, value=1.0, step=0.1, label="conditioning scale"),
69
+ # gr.Slider(0, 50, value=20, step=0.1, label="inference steps"),
70
+ # gr.Checkbox(label="guess mode")
71
+ # ],
72
+ # outputs="audio",
73
+ # examples=[["S00.mid", "piano", "", 10, 25, 1.0, 20, False]],
74
+ # cache_examples=True,
75
+ # title="🎹 MIDI-AudioLDM",
76
+ # description="MIDI-AudioLDM is a MIDI-conditioned text-to-audio model based on the project [AudioLDM](https://huggingface.co/spaces/haoheliu/audioldm-text-to-audio-generation). The model has been conditioned using the ControlNet architecture and has been developed within Hugging Face’s [🧨 Diffusers](https://huggingface.co/docs/diffusers/) framework. Once trained, MIDI-AudioLDM accepts a MIDI file and a text prompt as inputs and returns an audio file, which is an interpretation of the MIDI based on the given text description. This enables detailed control over different musical aspects such as notes, mood and timbre.",
77
+ # theme=gr.themes.Base(text_size=gr.themes.sizes.text_md, font=[gr.themes.GoogleFont("Nunito Sans")])
78
+ # )
79
+ # demo.launch()