Rex Cheng
commited on
Commit
•
c8ca0bd
1
Parent(s):
03013d2
use tempfile
Browse files
app.py
CHANGED
@@ -20,6 +20,7 @@ from mmaudio.model.flow_matching import FlowMatching
|
|
20 |
from mmaudio.model.networks import MMAudio, get_my_mmaudio
|
21 |
from mmaudio.model.sequence_config import SequenceConfig
|
22 |
from mmaudio.model.utils.features_utils import FeaturesUtils
|
|
|
23 |
|
24 |
torch.backends.cuda.matmul.allow_tf32 = True
|
25 |
torch.backends.cudnn.allow_tf32 = True
|
@@ -81,18 +82,18 @@ def video_to_audio(video: gr.Video, prompt: str, negative_prompt: str, seed: int
|
|
81 |
cfg_strength=cfg_strength)
|
82 |
audio = audios.float().cpu()[0]
|
83 |
|
84 |
-
current_time_string = datetime.now().strftime('%Y%m%d_%H%M%S')
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
92 |
return video_save_path
|
93 |
|
94 |
|
95 |
-
@spaces.GPU
|
96 |
@torch.inference_mode()
|
97 |
def text_to_audio(prompt: str, negative_prompt: str, seed: int, num_steps: int, cfg_strength: float,
|
98 |
duration: float):
|
@@ -115,9 +116,10 @@ def text_to_audio(prompt: str, negative_prompt: str, seed: int, num_steps: int,
|
|
115 |
cfg_strength=cfg_strength)
|
116 |
audio = audios.float().cpu()[0]
|
117 |
|
118 |
-
current_time_string = datetime.now().strftime('%Y%m%d_%H%M%S')
|
119 |
-
output_dir.mkdir(exist_ok=True, parents=True)
|
120 |
-
audio_save_path = output_dir / f'{current_time_string}.flac'
|
|
|
121 |
torchaudio.save(audio_save_path, audio, seq_cfg.sampling_rate)
|
122 |
return audio_save_path
|
123 |
|
|
|
20 |
from mmaudio.model.networks import MMAudio, get_my_mmaudio
|
21 |
from mmaudio.model.sequence_config import SequenceConfig
|
22 |
from mmaudio.model.utils.features_utils import FeaturesUtils
|
23 |
+
import tempfile
|
24 |
|
25 |
torch.backends.cuda.matmul.allow_tf32 = True
|
26 |
torch.backends.cudnn.allow_tf32 = True
|
|
|
82 |
cfg_strength=cfg_strength)
|
83 |
audio = audios.float().cpu()[0]
|
84 |
|
85 |
+
# current_time_string = datetime.now().strftime('%Y%m%d_%H%M%S')
|
86 |
+
video_save_path = tempfile.mktemp(suffix='.mp4')
|
87 |
+
# output_dir.mkdir(exist_ok=True, parents=True)
|
88 |
+
# video_save_path = output_dir / f'{current_time_string}.mp4'
|
89 |
+
# make_video(video,
|
90 |
+
# video_save_path,
|
91 |
+
# audio,
|
92 |
+
# sampling_rate=seq_cfg.sampling_rate,
|
93 |
+
# duration_sec=seq_cfg.duration)
|
94 |
return video_save_path
|
95 |
|
96 |
|
|
|
97 |
@torch.inference_mode()
|
98 |
def text_to_audio(prompt: str, negative_prompt: str, seed: int, num_steps: int, cfg_strength: float,
|
99 |
duration: float):
|
|
|
116 |
cfg_strength=cfg_strength)
|
117 |
audio = audios.float().cpu()[0]
|
118 |
|
119 |
+
# current_time_string = datetime.now().strftime('%Y%m%d_%H%M%S')
|
120 |
+
# output_dir.mkdir(exist_ok=True, parents=True)
|
121 |
+
# audio_save_path = output_dir / f'{current_time_string}.flac'
|
122 |
+
audio_save_path = tempfile.mktemp(suffix='.flac')
|
123 |
torchaudio.save(audio_save_path, audio, seq_cfg.sampling_rate)
|
124 |
return audio_save_path
|
125 |
|