File size: 1,093 Bytes
a470e25 79bee9d | 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 | 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 -y -loop 1 -i {image_path} "
f"-c:v libx264 -t 5 -pix_fmt yuv420p "
f"-vf scale=512:512 {video_path}"
)
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, share=True) |