Spaces:
Running
Running
File size: 1,890 Bytes
88c69aa a368f0e 88c69aa a368f0e 88c69aa a368f0e 88c69aa a368f0e 88c69aa a368f0e 88c69aa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import streamlit as st
import os
# Your Lipsync code here
def main():
st.title("Lipsync App")
st.markdown("Upload your video and audio files to create a lipsynced video.")
# Audio upload
st.sidebar.markdown("### Upload Audio")
audio_file = st.sidebar.file_uploader("Upload Audio File", type=["wav"])
# Video upload
st.sidebar.markdown("### Upload Video")
video_file = st.sidebar.file_uploader("Upload Video File", type=["mp4"])
if st.sidebar.button("Sync Lips"):
if audio_file and video_file:
# Save audio file
audio_file_path = "input_audio.wav"
with open(audio_file_path, "wb") as audio_writer:
audio_writer.write(audio_file.read())
# Save video file
video_file_path = "input_vid.mp4"
with open(video_file_path, "wb") as video_writer:
video_writer.write(video_file.read())
# Run Lipsync code
pad_top = 0
pad_bottom = 10
pad_left = 0
pad_right = 0
rescale_factor = 1
nosmooth = True
use_hd_model = False
checkpoint_path = 'checkpoints/wav2lip.pth' if not use_hd_model else 'checkpoints/wav2lip_gan.pth'
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}"
if nosmooth:
cmd += " --nosmooth"
os.system(cmd)
output_file_path = 'results/result_voice.mp4'
# Display output video
if os.path.exists(output_file_path):
st.video(output_file_path)
else:
st.error("Processing failed. Output video not found.")
if __name__ == "__main__":
main()
|