Spaces:
Running
Running
gradio
Browse files- MMAudio/demo.py +4 -2
- app.py +8 -4
MMAudio/demo.py
CHANGED
@@ -178,7 +178,8 @@ def main():
|
|
178 |
audio = audios.float().cpu()[0]
|
179 |
if video_path is not None:
|
180 |
####save_path = output_dir / f'{video_path.stem}.flac'
|
181 |
-
save_path = str(output_dir) + "/" + str(video_path).replace("/", "__").strip(".") + ".flac"
|
|
|
182 |
else:
|
183 |
safe_filename = prompt.replace(' ', '_').replace('/', '_').replace('.', '')
|
184 |
save_path = output_dir / f'{safe_filename}.flac'
|
@@ -209,7 +210,8 @@ def main():
|
|
209 |
log.info(f'Audio saved to {save_path}')
|
210 |
if video_path is not None and not skip_video_composite:
|
211 |
####video_save_path = output_dir / f'{video_path.stem}.mp4'
|
212 |
-
video_save_path = str(output_dir) + "/" + str(video_path).replace("/", "__").strip(".") + ".mp4"
|
|
|
213 |
make_video(video_info, video_save_path, audio, sampling_rate=seq_cfg.sampling_rate)
|
214 |
log.info(f'Video saved to {video_save_path}')
|
215 |
|
|
|
178 |
audio = audios.float().cpu()[0]
|
179 |
if video_path is not None:
|
180 |
####save_path = output_dir / f'{video_path.stem}.flac'
|
181 |
+
####save_path = str(output_dir) + "/" + str(video_path).replace("/", "__").strip(".") + ".flac"
|
182 |
+
save_path = str(output_dir) + "/__" + os.path.basename(video_path).strip(".") + ".flac"
|
183 |
else:
|
184 |
safe_filename = prompt.replace(' ', '_').replace('/', '_').replace('.', '')
|
185 |
save_path = output_dir / f'{safe_filename}.flac'
|
|
|
210 |
log.info(f'Audio saved to {save_path}')
|
211 |
if video_path is not None and not skip_video_composite:
|
212 |
####video_save_path = output_dir / f'{video_path.stem}.mp4'
|
213 |
+
####video_save_path = str(output_dir) + "/" + str(video_path).replace("/", "__").strip(".") + ".mp4"
|
214 |
+
video_save_path = str(output_dir) + "/__" + os.path.basename(video_path).strip(".") + ".mp4"
|
215 |
make_video(video_info, video_save_path, audio, sampling_rate=seq_cfg.sampling_rate)
|
216 |
log.info(f'Video saved to {video_save_path}')
|
217 |
|
app.py
CHANGED
@@ -17,6 +17,7 @@ import torchaudio
|
|
17 |
import tempfile
|
18 |
|
19 |
import requests
|
|
|
20 |
|
21 |
log = logging.getLogger()
|
22 |
|
@@ -26,8 +27,8 @@ def video_to_audio(video: gr.Video, prompt: str):
|
|
26 |
|
27 |
video_path = tempfile.NamedTemporaryFile(delete=False, suffix='.mp4').name
|
28 |
|
29 |
-
output_dir =
|
30 |
-
video_save_path = str(output_dir)
|
31 |
|
32 |
print("paths", video, video_path, output_dir, video_save_path)
|
33 |
|
@@ -36,9 +37,12 @@ def video_to_audio(video: gr.Video, prompt: str):
|
|
36 |
with open(video_path, "wb") as fw:
|
37 |
fw.write(data)
|
38 |
else:
|
39 |
-
|
40 |
|
41 |
-
|
|
|
|
|
|
|
42 |
|
43 |
return video_save_path
|
44 |
|
|
|
17 |
import tempfile
|
18 |
|
19 |
import requests
|
20 |
+
import shutil
|
21 |
|
22 |
log = logging.getLogger()
|
23 |
|
|
|
27 |
|
28 |
video_path = tempfile.NamedTemporaryFile(delete=False, suffix='.mp4').name
|
29 |
|
30 |
+
output_dir = os.path.dirname(video_path)
|
31 |
+
video_save_path = os.path.join(str(output_dir), "__" + os.path.basename(video_path).strip(".") + ".mp4")
|
32 |
|
33 |
print("paths", video, video_path, output_dir, video_save_path)
|
34 |
|
|
|
37 |
with open(video_path, "wb") as fw:
|
38 |
fw.write(data)
|
39 |
else:
|
40 |
+
shutil.copy(video, video_path)
|
41 |
|
42 |
+
if prompt == "":
|
43 |
+
os.system("cd ./MMAudio; python ./demo.py --variant small_44k --output %s --video %s --calc_energy 1" % (output_dir, video_path))
|
44 |
+
else:
|
45 |
+
os.system("cd ./MMAudio; python ./demo.py --variant small_44k --output %s --video %s --prompt %s --calc_energy 1" % (output_dir, video_path, prompt))
|
46 |
|
47 |
return video_save_path
|
48 |
|