haoheliu commited on
Commit
56c7c7f
1 Parent(s): 08ae136

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -26,12 +26,11 @@ audioldm = build_model()
26
  def text2audio(text, duration, guidance_scale, random_seed, n_candidates):
27
  # print(text, length, guidance_scale)
28
  waveform = text_to_audio(audioldm, text, random_seed, duration=duration, guidance_scale=guidance_scale, n_candidate_gen_per_text=int(n_candidates)) # [bs, 1, samples]
29
- audio_out = waveform
30
  waveform = [gr.make_waveform((16000, wave[0]), bg_image="bg.png") for wave in waveform]
31
  # waveform = [(16000, np.random.randn(16000)), (16000, np.random.randn(16000))]
32
  if(len(waveform) == 1):
33
  waveform = waveform[0]
34
- return waveform, audio_out
35
 
36
  # iface = gr.Interface(fn=text2audio, inputs=[
37
  # gr.Textbox(value="A man is speaking in a huge room", max_lines=1),
@@ -226,7 +225,7 @@ with iface:
226
  n_candidates = gr.Slider(1, 5, value=3, step=1, label="Automatic quality control. This number control the number of candidates (e.g., generate three audios and choose the best to show you). A Larger value usually lead to better quality with heavier computation")
227
  ############# Output
228
  # outputs=gr.Audio(label="Output", type="numpy")
229
- outputs=[gr.Video(label="Output", elem_id="output-video"), gr.Audio(visible=False)]
230
 
231
  # with gr.Group(elem_id="container-advanced-btns"):
232
  # # advanced_button = gr.Button("Advanced options", elem_id="advanced-btn")
@@ -243,7 +242,7 @@ with iface:
243
  share_button = gr.Button("Share to community", elem_id="share-btn")
244
 
245
  btn.click(text2audio, inputs=[
246
- textbox, duration, guidance_scale, seed, n_candidates], outputs=outputs)
247
 
248
  share_button.click(None, [], [], _js=share_js)
249
  gr.HTML('''
@@ -264,7 +263,7 @@ with iface:
264
  ],
265
  fn=text2audio,
266
  inputs=[textbox, duration, guidance_scale, seed, n_candidates],
267
- outputs=outputs,
268
  cache_examples=True,
269
  )
270
  gr.HTML('''
 
26
  def text2audio(text, duration, guidance_scale, random_seed, n_candidates):
27
  # print(text, length, guidance_scale)
28
  waveform = text_to_audio(audioldm, text, random_seed, duration=duration, guidance_scale=guidance_scale, n_candidate_gen_per_text=int(n_candidates)) # [bs, 1, samples]
 
29
  waveform = [gr.make_waveform((16000, wave[0]), bg_image="bg.png") for wave in waveform]
30
  # waveform = [(16000, np.random.randn(16000)), (16000, np.random.randn(16000))]
31
  if(len(waveform) == 1):
32
  waveform = waveform[0]
33
+ return waveform
34
 
35
  # iface = gr.Interface(fn=text2audio, inputs=[
36
  # gr.Textbox(value="A man is speaking in a huge room", max_lines=1),
 
225
  n_candidates = gr.Slider(1, 5, value=3, step=1, label="Automatic quality control. This number control the number of candidates (e.g., generate three audios and choose the best to show you). A Larger value usually lead to better quality with heavier computation")
226
  ############# Output
227
  # outputs=gr.Audio(label="Output", type="numpy")
228
+ outputs=gr.Video(label="Output", elem_id="output-video")
229
 
230
  # with gr.Group(elem_id="container-advanced-btns"):
231
  # # advanced_button = gr.Button("Advanced options", elem_id="advanced-btn")
 
242
  share_button = gr.Button("Share to community", elem_id="share-btn")
243
 
244
  btn.click(text2audio, inputs=[
245
+ textbox, duration, guidance_scale, seed, n_candidates], outputs=[outputs])
246
 
247
  share_button.click(None, [], [], _js=share_js)
248
  gr.HTML('''
 
263
  ],
264
  fn=text2audio,
265
  inputs=[textbox, duration, guidance_scale, seed, n_candidates],
266
+ outputs=[outputs],
267
  cache_examples=True,
268
  )
269
  gr.HTML('''