Spaces:
Running
on
T4
Running
on
T4
Phil Sobrepena
commited on
Commit
·
56a9322
1
Parent(s):
d15bc7d
fix
Browse files
app.py
CHANGED
@@ -98,36 +98,36 @@ def video_to_audio(video: gr.Video, prompt: str, negative_prompt: str, seed: int
|
|
98 |
return video_save_path
|
99 |
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
|
132 |
|
133 |
video_to_audio_tab = gr.Interface(
|
|
|
98 |
return video_save_path
|
99 |
|
100 |
|
101 |
+
@spaces.GPU(duration=120)
|
102 |
+
@torch.inference_mode()
|
103 |
+
def text_to_audio(prompt: str, negative_prompt: str, seed: int, num_steps: int, cfg_strength: float,
|
104 |
+
duration: float):
|
105 |
+
|
106 |
+
rng = torch.Generator(device=device)
|
107 |
+
if seed >= 0:
|
108 |
+
rng.manual_seed(seed)
|
109 |
+
else:
|
110 |
+
rng.seed()
|
111 |
+
fm = FlowMatching(min_sigma=0, inference_mode='euler', num_steps=num_steps)
|
112 |
+
|
113 |
+
clip_frames = sync_frames = None
|
114 |
+
seq_cfg.duration = duration
|
115 |
+
net.update_seq_lengths(seq_cfg.latent_seq_len, seq_cfg.clip_seq_len, seq_cfg.sync_seq_len)
|
116 |
+
|
117 |
+
audios = generate(clip_frames,
|
118 |
+
sync_frames, [prompt],
|
119 |
+
negative_text=[negative_prompt],
|
120 |
+
feature_utils=feature_utils,
|
121 |
+
net=net,
|
122 |
+
fm=fm,
|
123 |
+
rng=rng,
|
124 |
+
cfg_strength=cfg_strength)
|
125 |
+
audio = audios.float().cpu()[0]
|
126 |
+
|
127 |
+
audio_save_path = tempfile.NamedTemporaryFile(delete=False, suffix='.flac').name
|
128 |
+
torchaudio.save(audio_save_path, audio, seq_cfg.sampling_rate)
|
129 |
+
log.info(f'Saved audio to {audio_save_path}')
|
130 |
+
return audio_save_path
|
131 |
|
132 |
|
133 |
video_to_audio_tab = gr.Interface(
|