haoheliu commited on
Commit
858c11b
1 Parent(s): ddc4da2
Files changed (1) hide show
  1. app.py +53 -47
app.py CHANGED
@@ -11,53 +11,59 @@ def text2audio(text, duration, guidance_scale, random_seed):
11
  # waveform = [(16000, np.random.randn(16000)), (16000, np.random.randn(16000))]
12
  return waveform
13
 
14
- iface = gr.Interface(fn=text2audio, inputs=[
15
- gr.Textbox(value="A man is speaking in a huge room", max_lines=1),
16
- gr.Slider(2.5, 10, value=5, step=2.5),
17
- gr.Slider(0, 5, value=2.5, step=0.5),
18
- gr.Number(value=42)
19
- ], outputs=[gr.Audio(label="Output", type="numpy"), gr.Audio(label="Output", type="numpy")]
20
- )
21
- iface.launch(share=True)
 
22
 
23
- # block = gr.Blocks()
24
 
25
- # with block:
26
- # gr.HTML(
27
- # """
28
- # <div style="text-align: center; max-width: 700px; margin: 0 auto;">
29
- # <div
30
- # style="
31
- # display: inline-flex;
32
- # align-items: center;
33
- # gap: 0.8rem;
34
- # font-size: 1.75rem;
35
- # "
36
- # >
37
- # <h1 style="font-weight: 900; margin-bottom: 7px;">
38
- # Text-to-Audio Generation with AudioLDM
39
- # </h1>
40
- # </div>
41
- # <p style="margin-bottom: 10px; font-size: 94%">
42
- # <a href="https://arxiv.org/abs/2301.12503">[Paper]</a> <a href="https://audioldm.github.io/">[Project page]</a>
43
- # </p>
44
- # </div>
45
- # """
46
- # )
47
- # with gr.Group():
48
- # with gr.Box():
49
- # textbox = gr.Textbox(value="A man is speaking in a huge room")
50
- # length = gr.Slider(1.0, 30.0, value=5.0, step=0.5, label="Audio length in seconds")
51
- # # model = gr.Dropdown(choices=["harmonai/maestro-150k"], value="harmonai/maestro-150k",type="value", label="Model")
52
- # out = [gr.Audio(label="Output", type="numpy"), gr.Audio(label="Output", type="numpy")]
53
- # btn = gr.Button("Submit").style(full_width=True)
54
-
55
- # btn.click(text2audio, inputs=[textbox, length], outputs=out)
56
- # gr.HTML('''
57
- # <div class="footer" style="text-align: center; max-width: 700px; margin: 0 auto;">
58
- # <p>Model by <a href="https://haoheliu.github.io/" style="text-decoration: underline;" target="_blank">Haohe Liu</a>
59
- # </p>
60
- # </div>
61
- # ''')
 
 
 
 
62
 
63
- # block.launch(debug=True)
 
 
11
  # waveform = [(16000, np.random.randn(16000)), (16000, np.random.randn(16000))]
12
  return waveform
13
 
14
+ # iface = gr.Interface(fn=text2audio, inputs=[
15
+ # gr.Textbox(value="A man is speaking in a huge room", max_lines=1),
16
+ # gr.Slider(2.5, 10, value=5, step=2.5),
17
+ # gr.Slider(0, 5, value=2.5, step=0.5),
18
+ # gr.Number(value=42)
19
+ # ], outputs=[gr.Audio(label="Output", type="numpy"), gr.Audio(label="Output", type="numpy")],
20
+ # allow_flagging="never"
21
+ # )
22
+ # iface.launch(share=True)
23
 
24
+ iface = gr.Blocks()
25
 
26
+ with iface:
27
+ gr.HTML(
28
+ """
29
+ <div style="text-align: center; max-width: 700px; margin: 0 auto;">
30
+ <div
31
+ style="
32
+ display: inline-flex;
33
+ align-items: center;
34
+ gap: 0.8rem;
35
+ font-size: 1.75rem;
36
+ "
37
+ >
38
+ <h1 style="font-weight: 900; margin-bottom: 7px;">
39
+ Text-to-Audio Generation with AudioLDM
40
+ </h1>
41
+ </div>
42
+ <p style="margin-bottom: 10px; font-size: 94%">
43
+ <a href="https://arxiv.org/abs/2301.12503">[Paper]</a> <a href="https://audioldm.github.io/">[Project page]</a>
44
+ </p>
45
+ </div>
46
+ """
47
+ )
48
+ with gr.Group():
49
+ with gr.Box():
50
+ ############# Input
51
+ textbox = gr.Textbox(value="A hammer is hitting a wooden surface", max_lines=1)
52
+ duration = gr.Slider(2.5, 10, value=5, step=2.5)
53
+ guidance_scale = gr.Slider(0, 5, value=2.5, step=0.5)
54
+ seed = gr.Number(value=42)
55
+ ############# Output
56
+ outputs=[gr.Audio(label="Output", type="numpy"), gr.Audio(label="Output", type="numpy")]
57
+
58
+ btn = gr.Button("Submit").style(full_width=True)
59
+ btn.click(text2audio, inputs=[textbox, duration, guidance_scale, seed], outputs=outputs)
60
+ gr.HTML('''
61
+ <hr>
62
+ <div class="footer" style="text-align: center; max-width: 700px; margin: 0 auto;">
63
+ <p>Model by <a href="https://haoheliu.github.io/" style="text-decoration: underline;" target="_blank">Haohe Liu</a>
64
+ </p>
65
+ </div>
66
+ ''')
67
 
68
+ iface.queue(concurrency_count=2)
69
+ iface.launch(debug=True, share=True)