soujanyaporia commited on
Commit
9d05e2e
·
verified ·
1 Parent(s): 3e45609

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -85,15 +85,16 @@ tango.model.to(device_type)
85
 
86
  @spaces.GPU(duration=120)
87
  def gradio_generate(prompt, output_format, steps, guidance):
88
- output_wave = tango.generate(prompt, steps, guidance)
 
89
  # output_filename = f"{prompt.replace(' ', '_')}_{steps}_{guidance}"[:250] + ".wav"
90
 
91
  output_filename_1 = "tmp1.wav"
92
- wavio.write(output_filename_1, output_wave[0], rate=16000, sampwidth=2)
93
  output_filename_2 = "tmp2.wav"
94
- wavio.write(output_filename_2, output_wave[1], rate=16000, sampwidth=2)
95
  output_filename_3 = "tmp3.wav"
96
- wavio.write(output_filename_3, output_wave[2], rate=16000, sampwidth=2)
97
 
98
  if (output_format == "mp3"):
99
  AudioSegment.from_wav("tmp1.wav").export("tmp1.mp3", format = "mp3")
@@ -104,6 +105,7 @@ def gradio_generate(prompt, output_format, steps, guidance):
104
  output_filename_3 = "tmp3.mp3"
105
 
106
  return [output_filename_1, output_filename_2, output_filename_3]
 
107
 
108
  # description_text = """
109
  # <p><a href="https://huggingface.co/spaces/declare-lab/tango/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/>
 
85
 
86
  @spaces.GPU(duration=120)
87
  def gradio_generate(prompt, output_format, steps, guidance):
88
+ # output_wave = tango.generate(prompt, steps, guidance)
89
+ output_wave = tango.generate_for_batch(prompt, steps, guidance, samples=3)
90
  # output_filename = f"{prompt.replace(' ', '_')}_{steps}_{guidance}"[:250] + ".wav"
91
 
92
  output_filename_1 = "tmp1.wav"
93
+ wavio.write(output_filename_1, output_wave[0][0], rate=16000, sampwidth=2)
94
  output_filename_2 = "tmp2.wav"
95
+ wavio.write(output_filename_2, output_wave[0][1], rate=16000, sampwidth=2)
96
  output_filename_3 = "tmp3.wav"
97
+ wavio.write(output_filename_3, output_wave[0][2], rate=16000, sampwidth=2)
98
 
99
  if (output_format == "mp3"):
100
  AudioSegment.from_wav("tmp1.wav").export("tmp1.mp3", format = "mp3")
 
105
  output_filename_3 = "tmp3.mp3"
106
 
107
  return [output_filename_1, output_filename_2, output_filename_3]
108
+ # return [output_filename_1]
109
 
110
  # description_text = """
111
  # <p><a href="https://huggingface.co/spaces/declare-lab/tango/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/>