Download app.py from Okutsu1/Lipsync: direct link, hf CLI and curl.
- Browser
- Download file 1.61 kB
-
https://huggingface.co/spaces/Okutsu1/Lipsync/resolve/main/app.py
- Command line
-
hf download hf://spaces/Okutsu1/Lipsync/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Okutsu1/Lipsync/resolve/main/app.py
1.61 kB
| import gradio as gr | |
| from lipsync import run_lipsync_pipeline | |
| import os | |
| from pathlib import Path | |
| def sync(video_file, audio_file, hf_token): | |
| if not video_file: | |
| return None, "β Please upload a video" | |
| if not audio_file: | |
| return None, "β Please upload an audio file" | |
| if not hf_token: | |
| return None, "β Please enter your HuggingFace token" | |
| try: | |
| output_path = f"/tmp/lipsynced_{Path(video_file).stem}.mp4" | |
| run_lipsync_pipeline(video_file, audio_file, output_path, hf_token=hf_token) | |
| return output_path, "β Done!" | |
| except Exception as e: | |
| import traceback | |
| traceback.print_exc() | |
| return None, f"β Error: {str(e)}" | |
| demo = gr.Interface( | |
| fn=sync, | |
| inputs=[ | |
| gr.Video(label="Original video (with visible face)"), | |
| gr.Audio(label="Dubbed audio (e.g. Khmer mp3/wav)", type="filepath"), | |
| gr.Textbox(label="HuggingFace Token", type="password", | |
| info="Required for LatentSync GPU access. Get yours at huggingface.co/settings/tokens (read access is enough)"), | |
| ], | |
| outputs=[ | |
| gr.Video(label="Lip-synced video"), | |
| gr.Textbox(label="Status"), | |
| ], | |
| title="π¬ Video Lip Sync", | |
| description=( | |
| "Upload a video of a speaking person and a dubbed audio track. " | |
| "Gets back a full video with mouth movements synced to the new audio.\n\n" | |
| "Powered by LatentSync (ByteDance) via remote GPU β no local GPU needed.\n" | |
| "β οΈ Long videos are processed in 8s chunks and stitched together." | |
| ), | |
| ) | |
| demo.launch(ssr_mode=False) |