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()