import gradio as gr ‎import os ‎ ‎ ‎def generate_lipsync(image, audio): ‎ os.makedirs("input", exist_ok=True) ‎ os.makedirs("output", exist_ok=True) ‎ ‎ image_path = "input/image.jpg" ‎ audio_path = "input/audio.wav" ‎ video_path = "input/video.mp4" ‎ result_path = "output/result_voice.mp4" ‎ ‎ image.save(image_path) ‎ ‎ os.system(f"cp '{audio}' {audio_path}") ‎ ‎ os.system( ‎ f"ffmpeg -loop 1 -i {image_path} -c:v libx264 -t 5 -pix_fmt yuv420p -vf scale=512:512 {video_path} -y" ‎ ) ‎ ‎ command = f''' ‎ python wav2lip/inference.py \ ‎ --checkpoint_path checkpoints/wav2lip_gan.pth \ ‎ --face {video_path} \ ‎ --audio {audio_path} \ ‎ --outfile {result_path} ‎ ''' ‎ ‎ os.system(command) ‎ ‎ return result_path ‎ ‎ ‎iface = gr.Interface( ‎ fn=generate_lipsync, ‎ inputs=[ ‎ gr.Image(type="pil", label="Upload Image"), ‎ gr.Audio(type="filepath", label="Upload Audio") ‎ ], ‎ outputs=gr.Video(label="Generated Video"), ‎ title="TikTok AI LipSync" ‎) ‎ ‎iface.launch(server_name="0.0.0.0", server_port=7860)