Spaces:
Runtime error
Runtime error
Commit
·
df6c3f5
1
Parent(s):
9477214
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,17 +26,26 @@ tangoflux = TangoFluxInference(name="declare-lab/TangoFlux")
|
|
| 26 |
@spaces.GPU(duration=15)
|
| 27 |
def gradio_generate(prompt, steps, guidance,duration=10):
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
#wavio.write(output_filename, output_wave, rate=44100, sampwidth=2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
#if (output_format == "mp3"):
|
| 36 |
# AudioSegment.from_wav("temp.wav").export("temp.mp3", format = "mp3")
|
| 37 |
# output_filename = "temp.mp3"
|
| 38 |
|
| 39 |
-
return output_filename
|
| 40 |
|
| 41 |
description_text = """
|
| 42 |
<p><a href="https://huggingface.co/spaces/declare-lab/tango2/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/>
|
|
|
|
| 26 |
@spaces.GPU(duration=15)
|
| 27 |
def gradio_generate(prompt, steps, guidance,duration=10):
|
| 28 |
|
| 29 |
+
output = tangoflux.generate(prompt,steps=steps,guidance_scale=guidance,duration=duration)
|
| 30 |
+
output = output.to(torch.float32).div(torch.max(torch.abs(output))).clamp(-1, 1).mul(32767).to(torch.int16).cpu()
|
| 31 |
+
|
| 32 |
|
| 33 |
#wavio.write(output_filename, output_wave, rate=44100, sampwidth=2)
|
| 34 |
+
unique_filename = f"output_{uuid.uuid4().hex}.wav"
|
| 35 |
+
print(f"Saving audio to file: {unique_filename}")
|
| 36 |
+
|
| 37 |
+
# Save to file
|
| 38 |
+
torchaudio.save(unique_filename, output, sample_rate)
|
| 39 |
+
print(f"Audio saved: {unique_filename}")
|
| 40 |
+
|
| 41 |
+
# Return the path to the generated audio file
|
| 42 |
+
return unique_filename
|
| 43 |
|
| 44 |
#if (output_format == "mp3"):
|
| 45 |
# AudioSegment.from_wav("temp.wav").export("temp.mp3", format = "mp3")
|
| 46 |
# output_filename = "temp.mp3"
|
| 47 |
|
| 48 |
+
#return output_filename
|
| 49 |
|
| 50 |
description_text = """
|
| 51 |
<p><a href="https://huggingface.co/spaces/declare-lab/tango2/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/>
|