import streamlit as st import os from IPython.display import clear_output # 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 with open("/content/sample_data/input_audio.wav", "wb") as audio_writer: audio_writer.write(audio_file.read()) # Save video file with open("/content/sample_data/input_vid.mp4", "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 rescaleFactor = 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 '/content/sample_data/input_vid.mp4' --audio '/content/sample_data/input_audio.wav' --pads {pad_top} {pad_bottom} {pad_left} {pad_right} --resize_factor {rescaleFactor}" if nosmooth: cmd += " --nosmooth" os.system(cmd) output_file_path = '/content/Wav2Lip/results/result_voice.mp4' # Display output video if os.path.exists(output_file_path): clear_output() st.video(output_file_path) else: st.error("Processing failed. Output video not found.") if __name__ == "__main__": main()