Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
-
from IPython.display import clear_output
|
4 |
|
5 |
# Your Lipsync code here
|
6 |
def main():
|
@@ -18,34 +17,35 @@ def main():
|
|
18 |
if st.sidebar.button("Sync Lips"):
|
19 |
if audio_file and video_file:
|
20 |
# Save audio file
|
21 |
-
|
|
|
22 |
audio_writer.write(audio_file.read())
|
23 |
|
24 |
# Save video file
|
25 |
-
|
|
|
26 |
video_writer.write(video_file.read())
|
27 |
|
28 |
# Run Lipsync code
|
29 |
-
pad_top =
|
30 |
-
pad_bottom =
|
31 |
-
pad_left =
|
32 |
-
pad_right =
|
33 |
-
|
34 |
nosmooth = True
|
35 |
use_hd_model = False
|
36 |
checkpoint_path = 'checkpoints/wav2lip.pth' if not use_hd_model else 'checkpoints/wav2lip_gan.pth'
|
37 |
|
38 |
-
cmd = f"
|
39 |
if nosmooth:
|
40 |
cmd += " --nosmooth"
|
41 |
|
42 |
os.system(cmd)
|
43 |
|
44 |
-
output_file_path = '
|
45 |
|
46 |
# Display output video
|
47 |
if os.path.exists(output_file_path):
|
48 |
-
clear_output()
|
49 |
st.video(output_file_path)
|
50 |
else:
|
51 |
st.error("Processing failed. Output video not found.")
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
|
|
3 |
|
4 |
# Your Lipsync code here
|
5 |
def main():
|
|
|
17 |
if st.sidebar.button("Sync Lips"):
|
18 |
if audio_file and video_file:
|
19 |
# Save audio file
|
20 |
+
audio_file_path = "input_audio.wav"
|
21 |
+
with open(audio_file_path, "wb") as audio_writer:
|
22 |
audio_writer.write(audio_file.read())
|
23 |
|
24 |
# Save video file
|
25 |
+
video_file_path = "input_vid.mp4"
|
26 |
+
with open(video_file_path, "wb") as video_writer:
|
27 |
video_writer.write(video_file.read())
|
28 |
|
29 |
# Run Lipsync code
|
30 |
+
pad_top = 0
|
31 |
+
pad_bottom = 10
|
32 |
+
pad_left = 0
|
33 |
+
pad_right = 0
|
34 |
+
rescale_factor = 1
|
35 |
nosmooth = True
|
36 |
use_hd_model = False
|
37 |
checkpoint_path = 'checkpoints/wav2lip.pth' if not use_hd_model else 'checkpoints/wav2lip_gan.pth'
|
38 |
|
39 |
+
cmd = f"python inference.py --checkpoint_path {checkpoint_path} --face '{video_file_path}' --audio '{audio_file_path}' --pads {pad_top} {pad_bottom} {pad_left} {pad_right} --resize_factor {rescale_factor}"
|
40 |
if nosmooth:
|
41 |
cmd += " --nosmooth"
|
42 |
|
43 |
os.system(cmd)
|
44 |
|
45 |
+
output_file_path = 'results/result_voice.mp4'
|
46 |
|
47 |
# Display output video
|
48 |
if os.path.exists(output_file_path):
|
|
|
49 |
st.video(output_file_path)
|
50 |
else:
|
51 |
st.error("Processing failed. Output video not found.")
|