haoheliu commited on
Commit
4eab478
1 Parent(s): e2a5daa

try out UI design

Browse files
Files changed (2) hide show
  1. .gitignore +1 -0
  2. app.py +49 -8
.gitignore CHANGED
@@ -1,2 +1,3 @@
1
  *.pyc
2
  __pycache__
 
 
1
  *.pyc
2
  __pycache__
3
+ test.py
app.py CHANGED
@@ -1,14 +1,55 @@
1
  import gradio as gr
2
  import numpy as np
3
- from audioldm import text_to_audio
4
 
5
- def greet(text):
6
- waveform = text_to_audio(text, n_gen=1) # [bs, 1, samples]
7
- waveform = [(16000, wave[0]) for wave in waveform]
 
8
  return waveform
9
 
10
- iface = gr.Interface(fn=greet, inputs="text", outputs=["audio", "audio"])
11
- iface.launch()
12
 
13
- # if __name__ == "__main__":
14
- # greet("hello world")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import numpy as np
3
+ # from audioldm import text_to_audio
4
 
5
+ def text2audio(text, length):
6
+ # waveform = text_to_audio(text, n_gen=1) # [bs, 1, samples]
7
+ # waveform = [(16000, wave[0]) for wave in waveform]
8
+ waveform = [(16000, np.random.randn(16000)), (16000, np.random.randn(16000))]
9
  return waveform
10
 
11
+ # iface = gr.Interface(fn=greet, inputs="text", outputs=["audio", "audio"])
12
+ # iface.launch()
13
 
14
+
15
+ block = gr.Blocks()
16
+
17
+ with block:
18
+ gr.HTML(
19
+ """
20
+ <div style="text-align: center; max-width: 700px; margin: 0 auto;">
21
+ <div
22
+ style="
23
+ display: inline-flex;
24
+ align-items: center;
25
+ gap: 0.8rem;
26
+ font-size: 1.75rem;
27
+ "
28
+ >
29
+ <h1 style="font-weight: 900; margin-bottom: 7px;">
30
+ Text-to-Audio Generation with AudioLDM
31
+ </h1>
32
+ </div>
33
+ <p style="margin-bottom: 10px; font-size: 94%">
34
+ <a href="https://arxiv.org/abs/2301.12503">[Paper]</a> <a href="https://audioldm.github.io/">[Project page]</a>
35
+ </p>
36
+ </div>
37
+ """
38
+ )
39
+ with gr.Group():
40
+ with gr.Box():
41
+ textbox = gr.Textbox(value="A man is speaking in a huge room")
42
+ length = gr.Slider(1.0, 30.0, value=5.0, step=0.5, label="Audio length in seconds")
43
+ # model = gr.Dropdown(choices=["harmonai/maestro-150k"], value="harmonai/maestro-150k",type="value", label="Model")
44
+ out = [gr.Audio(label="Output", type="numpy"), gr.Audio(label="Output", type="numpy")]
45
+ btn = gr.Button("Submit").style(full_width=True)
46
+
47
+ btn.click(text2audio, inputs=[textbox, length], outputs=out)
48
+ gr.HTML('''
49
+ <div class="footer" style="text-align: center; max-width: 700px; margin: 0 auto;">
50
+ <p>Model by <a href="https://haoheliu.github.io/" style="text-decoration: underline;" target="_blank">Haohe Liu</a>
51
+ </p>
52
+ </div>
53
+ ''')
54
+
55
+ block.launch(debug=True)