Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -85,27 +85,31 @@ tango.model.to(device_type)
|
|
85 |
|
86 |
@spaces.GPU(duration=120)
|
87 |
def gradio_generate(prompt, output_format, steps, guidance):
|
88 |
-
|
89 |
-
|
|
|
|
|
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")
|
101 |
output_filename_1 = "tmp1.mp3"
|
102 |
-
AudioSegment.from_wav("
|
103 |
-
|
104 |
-
AudioSegment.from_wav("
|
105 |
-
|
|
|
|
|
106 |
|
107 |
-
return [output_filename_1, output_filename_2, output_filename_3]
|
108 |
-
|
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/>
|
|
|
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_1 = "tmp.wav"
|
90 |
+
wavio.write(output_filename_1, output_wave[0], rate=16000, sampwidth=2)
|
91 |
+
# output_wave = tango.generate_for_batch([prompt], steps, guidance, samples=3)
|
92 |
# output_filename = f"{prompt.replace(' ', '_')}_{steps}_{guidance}"[:250] + ".wav"
|
93 |
|
94 |
+
# output_filename_1 = "tmp1.wav"
|
95 |
+
# wavio.write(output_filename_1, output_wave[0][0], rate=16000, sampwidth=2)
|
96 |
+
# output_filename_2 = "tmp2.wav"
|
97 |
+
# wavio.write(output_filename_2, output_wave[0][1], rate=16000, sampwidth=2)
|
98 |
+
# output_filename_3 = "tmp3.wav"
|
99 |
+
# wavio.write(output_filename_3, output_wave[0][2], rate=16000, sampwidth=2)
|
100 |
|
101 |
if (output_format == "mp3"):
|
102 |
AudioSegment.from_wav("tmp1.wav").export("tmp1.mp3", format = "mp3")
|
103 |
output_filename_1 = "tmp1.mp3"
|
104 |
+
# AudioSegment.from_wav("tmp1.wav").export("tmp1.mp3", format = "mp3")
|
105 |
+
# output_filename_1 = "tmp1.mp3"
|
106 |
+
# AudioSegment.from_wav("tmp2.wav").export("tmp2.mp3", format = "mp3")
|
107 |
+
# output_filename_2 = "tmp2.mp3"
|
108 |
+
# AudioSegment.from_wav("tmp3.wav").export("tmp3.mp3", format = "mp3")
|
109 |
+
# output_filename_3 = "tmp3.mp3"
|
110 |
|
111 |
+
# return [output_filename_1, output_filename_2, output_filename_3]
|
112 |
+
return output_filename_1
|
113 |
|
114 |
# description_text = """
|
115 |
# <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/>
|