fffiloni commited on
Commit
a122777
1 Parent(s): c1cbddf

add a hidden audio component output

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -26,11 +26,12 @@ 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
  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,7 +226,7 @@ with iface:
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")
 
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
  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")