from huggingface_hub import snapshot_download import gradio as gr import subprocess import os import uuid def setup_models(): if not os.path.exists("checkpoints"): print("Downloading model...") snapshot_download(repo_id="deepinsight/first-order-model", local_dir="checkpoints") setup_models() def generate(text, image): session = str(uuid.uuid4())[:8] os.makedirs(f"results/{session}", exist_ok=True) image_path = f"results/{session}/avatar.jpg" image.save(image_path) audio_path = f"results/{session}/audio.wav" tts_cmd = f'tts --text "{text}" --out_path {audio_path}' subprocess.run(tts_cmd, shell=True, check=True) video_cmd = f'python checkpoints/inference.py --driven_audio {audio_path} --source_image {image_path} --result_dir results/{session}' subprocess.run(video_cmd, shell=True, check=True) return f"results/{session}/video.mp4" gr.Interface( fn=generate, inputs=[gr.Textbox(label="Script"), gr.Image(label="Avatar Image", type="pil")], outputs=gr.Video(label="Generated Video"), title="Faceless Video Generator (Free)", description="Type your message + upload an image. Get a talking avatar video!" ).launch()