Spaces:
Running on Zero
Running on Zero
[Admin maintenance] Support new ZeroGPU hardware
#9
by multimodalart HF Staff - opened
- app.py +10 -2
- requirements.txt +2 -3
app.py
CHANGED
|
@@ -15,7 +15,7 @@ from typing import Union
|
|
| 15 |
from diffusers.utils.torch_utils import randn_tensor
|
| 16 |
from tqdm import tqdm
|
| 17 |
from TangoFlux import TangoFluxInference
|
| 18 |
-
import
|
| 19 |
|
| 20 |
# Define the description text
|
| 21 |
description_text = """
|
|
@@ -43,7 +43,15 @@ def gradio_generate(prompt, steps, guidance, duration):
|
|
| 43 |
output = tangoflux.generate(prompt, steps=steps, guidance_scale=guidance, duration=duration)
|
| 44 |
filename = 'temp.wav'
|
| 45 |
output = output[:,:int(duration*44100)]
|
| 46 |
-
torchaudio.save(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
return filename
|
| 48 |
|
| 49 |
# Create custom interface with HTML badges
|
|
|
|
| 15 |
from diffusers.utils.torch_utils import randn_tensor
|
| 16 |
from tqdm import tqdm
|
| 17 |
from TangoFlux import TangoFluxInference
|
| 18 |
+
import soundfile as sf
|
| 19 |
|
| 20 |
# Define the description text
|
| 21 |
description_text = """
|
|
|
|
| 43 |
output = tangoflux.generate(prompt, steps=steps, guidance_scale=guidance, duration=duration)
|
| 44 |
filename = 'temp.wav'
|
| 45 |
output = output[:,:int(duration*44100)]
|
| 46 |
+
# torchaudio.save replaced with soundfile.write (Step 5: torchaudio 2.10+ delegates .save to torchcodec)
|
| 47 |
+
# output is (C, F) torch tensor; soundfile expects (F,) for mono or (F, C) for multi-channel
|
| 48 |
+
audio = output.detach().cpu().numpy()
|
| 49 |
+
if audio.ndim == 2:
|
| 50 |
+
if audio.shape[0] == 1:
|
| 51 |
+
audio = audio[0]
|
| 52 |
+
else:
|
| 53 |
+
audio = audio.T # (C, F) -> (F, C)
|
| 54 |
+
sf.write(filename, audio, 44100)
|
| 55 |
return filename
|
| 56 |
|
| 57 |
# Create custom interface with HTML badges
|
requirements.txt
CHANGED
|
@@ -1,7 +1,4 @@
|
|
| 1 |
-
torch==2.4.0
|
| 2 |
-
torchaudio===2.4.0
|
| 3 |
torchlibrosa==0.1.0
|
| 4 |
-
torchvision==0.19.0
|
| 5 |
transformers==4.44.0
|
| 6 |
diffusers==0.32.0
|
| 7 |
accelerate==0.34.2
|
|
@@ -9,3 +6,5 @@ datasets==2.21.0
|
|
| 9 |
librosa
|
| 10 |
tqdm
|
| 11 |
wavio==0.0.7
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
torchlibrosa==0.1.0
|
|
|
|
| 2 |
transformers==4.44.0
|
| 3 |
diffusers==0.32.0
|
| 4 |
accelerate==0.34.2
|
|
|
|
| 6 |
librosa
|
| 7 |
tqdm
|
| 8 |
wavio==0.0.7
|
| 9 |
+
soundfile
|
| 10 |
+
pydub
|