keshavbhandari commited on
Commit
8f11748
1 Parent(s): 56adc3d

testing app

Browse files
Files changed (3) hide show
  1. app.py +60 -8
  2. index.html +0 -45
  3. temp.wav +0 -0
app.py CHANGED
@@ -1,14 +1,66 @@
1
  import gradio as gr
 
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
5
 
6
- html_content = """
7
- <iframe src="http://localhost:8000/index.html" width="100%" height="600px" frameborder="0"></iframe>
 
 
 
 
8
  """
 
 
 
 
 
 
9
 
10
- with gr.Blocks() as demo:
11
- gr.Interface(fn=greet, inputs="text", outputs="text")
12
- gr.HTML(html_content)
 
 
 
 
 
 
13
 
14
- demo.launch(share=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import spaces
3
+ import librosa
4
+ import soundfile as sf
5
+ import wavio
6
 
7
+ @spaces.GPU(duration=120)
8
+ def gradio_generate(prompt, steps, guidance):
9
+ # Get example audio file
10
+ filename = librosa.ex('trumpet')
11
+ output_wave, samplerate = sf.read(filename, dtype='float32')
12
+ output_filename = "temp.wav"
13
+ wavio.write(output_filename, output_wave, rate=16000, sampwidth=2)
14
+
15
+ return output_filename
16
 
17
+ title="Text2midi: Generating Symbolic Music from Captions"
18
+ description_text = """
19
+ <p><a href="https://huggingface.co/spaces/amaai-lab/text2midi/blob/main/app.py?duplicate=true"> <img style="margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a> For faster inference without waiting in queue, you may duplicate the space and upgrade to a GPU in the settings. <br/><br/>
20
+ Generate midi music using Text2midi by providing a text prompt.
21
+ <br/><br/> This is the demo for Text2midi for controllable text to midi generation: <a href="https://arxiv.org/abs/tbd">Read our paper.</a>
22
+ <p/>
23
  """
24
+ #description_text = ""
25
+ # Gradio input and output components
26
+ input_text = gr.Textbox(lines=2, label="Prompt")
27
+ output_audio = gr.Audio(label="Generated Music", type="filepath")
28
+ denoising_steps = gr.Slider(minimum=100, maximum=200, value=100, step=1, label="Steps", interactive=True)
29
+ guidance_scale = gr.Slider(minimum=1, maximum=10, value=3, step=0.1, label="Guidance Scale", interactive=True)
30
 
31
+ # CSS styling for the Duplicate button
32
+ css = '''
33
+ #duplicate-button {
34
+ margin: auto;
35
+ color: white;
36
+ background: #1565c0;
37
+ border-radius: 100vh;
38
+ }
39
+ '''
40
 
41
+ # Gradio interface
42
+ gr_interface = gr.Interface(
43
+ fn=gradio_generate,
44
+ inputs=[input_text, denoising_steps, guidance_scale],
45
+ outputs=[output_audio],
46
+ description=description_text,
47
+ allow_flagging=False,
48
+ examples=[
49
+ ["This techno song features a synth lead playing the main melody. This is accompanied by programmed percussion playing a simple kick focused beat. The hi-hat is accented in an open position on the 3-and count of every bar. The synth plays the bass part with a voicing that sounds like a cello. This techno song can be played in a club. The chord sequence is Gm, A7, Eb, Bb, C, F, Gm. The beat counts to 2. The tempo of this song is 128.0 beats per minute. The key of this song is G minor.", 200, 3],
50
+ ["This is a new age piece. There is a flute playing the main melody with a lot of staccato notes. The rhythmic background consists of a medium tempo electronic drum beat with percussive elements all over the spectrum. There is a playful atmosphere to the piece. This piece can be used in the soundtrack of a children's TV show or an advertisement jingle.", 200, 3],
51
+ ["The song is an instrumental. The song is in medium tempo with a classical guitar playing a lilting melody in accompaniment style. The song is emotional and romantic. The song is a romantic instrumental song. The chord sequence is Gm, F6, Ebm. The time signature is 4/4. This song is in Adagio. The key of this song is G minor.", 200, 3],
52
+ ["This folk song features a female voice singing the main melody. This is accompanied by a tabla playing the percussion. A guitar strums chords. For most parts of the song, only one chord is played. At the last bar, a different chord is played. This song has minimal instruments. This song has a story-telling mood. This song can be played in a village scene in an Indian movie. The chord sequence is Bbm, Ab. The beat is 3. The tempo of this song is Allegro. The key of this song is Bb minor.", 200, 3],
53
+ ["This is a live performance of a classical music piece. There is an orchestra performing the piece with a violin lead playing the main melody. The atmosphere is sentimental and heart-touching. This piece could be playing in the background at a classy restaurant. The chord progression in this song is Am7, Gm, Dm, A7, Dm. The beat is 3. This song is in Largo. The key of this song is D minor.", 200, 3],
54
+ ["This is a techno piece with drums and beats and a leading melody. A synth plays chords. The music kicks off with a powerful and relentless drumbeat. Over the pounding beats, a leading melody emerges. In the middle of the song, a flock of seagulls flies over the venue and make loud bird sounds. It has strong danceability and can be played in a club. The tempo is 120 bpm. The chords played by the synth are Am, Cm, Dm, Gm.", 200, 3],
55
+ ],
56
+ cache_examples="lazy",
57
+ )
58
+
59
+ with gr.Blocks(css=css) as demo:
60
+ title=gr.HTML(f"<h1><center>{title}</center></h1>")
61
+ dupe = gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
62
+ gr_interface.render()
63
+
64
+
65
+ # Launch Gradio app.
66
+ demo.queue().launch()
index.html DELETED
@@ -1,45 +0,0 @@
1
- <p>This is a demo for the <strong>html-midi-player</strong> package. For more information, see <a href="https://github.com/cifkao/html-midi-player" target="_blank">its GitHub repository</a>.</p>
2
-
3
- <section id="section3">
4
- <h2>Custom player and visualizer style</h2>
5
- <midi-player
6
- src="https://cdn.jsdelivr.net/gh/cifkao/html-midi-player@2b12128/jazz.mid"
7
- sound-font visualizer="#section3 midi-visualizer">
8
- </midi-player>
9
- <midi-visualizer
10
- src="https://cdn.jsdelivr.net/gh/cifkao/html-midi-player@2b12128/jazz.mid">
11
- </midi-visualizer>
12
- </section>
13
-
14
- <section id="section1">
15
- <h2>1 player, 2 visualizers</h2>
16
- <midi-visualizer
17
- type="piano-roll"
18
- src="https://cdn.jsdelivr.net/gh/cifkao/html-midi-player@2b12128/twinkle_twinkle.mid">
19
- </midi-visualizer>
20
- <midi-visualizer
21
- type="staff"
22
- src="https://cdn.jsdelivr.net/gh/cifkao/html-midi-player@2b12128/twinkle_twinkle.mid">
23
- </midi-visualizer>
24
- <midi-player
25
- src="https://cdn.jsdelivr.net/gh/cifkao/html-midi-player@2b12128/twinkle_twinkle.mid"
26
- sound-font visualizer="#section1 midi-visualizer">
27
- </midi-player>
28
- </section>
29
-
30
- <section id="section2">
31
- <h2>2 players, 1 visualizer</h2>
32
- <midi-player
33
- src="https://cdn.jsdelivr.net/gh/cifkao/html-midi-player@2b12128/twinkle_twinkle.mid"
34
- sound-font visualizer="#section2 midi-visualizer">
35
- </midi-player>
36
- <midi-player
37
- src="https://cdn.jsdelivr.net/gh/magenta/magenta-js@571b384/music/demos/melody.mid"
38
- sound-font visualizer="#section2 midi-visualizer">
39
- </midi-player>
40
- <midi-visualizer
41
- type="piano-roll">
42
- </midi-visualizer>
43
- </section>
44
-
45
- <script src="https://cdn.jsdelivr.net/combine/npm/[email protected],npm/@magenta/[email protected]/es6/core.js,npm/focus-visible@5,npm/[email protected]"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
temp.wav ADDED
Binary file (235 kB). View file