jjjimim commited on
Commit
4ab38ea
·
verified ·
1 Parent(s): 02cadab

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md.txt +13 -0
  2. app.py +32 -0
  3. requirements.txt +6 -0
README.md.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Faceless Video Generator (Free)
3
+ emoji: 🎥
4
+ colorFrom: indigo
5
+ colorTo: purple
6
+ sdk: gradio
7
+ sdk_version: "3.39"
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ Generate AI talking avatar videos from text and image.
13
+ Upload an image and enter your script, then click generate.
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import snapshot_download
2
+ import gradio as gr
3
+ import subprocess
4
+ import os
5
+ import uuid
6
+
7
+ def setup_models():
8
+ if not os.path.exists("checkpoints"):
9
+ print("Downloading model...")
10
+ snapshot_download(repo_id="deepinsight/first-order-model", local_dir="checkpoints")
11
+
12
+ setup_models()
13
+
14
+ def generate(text, image):
15
+ session = str(uuid.uuid4())[:8]
16
+ os.makedirs(f"results/{session}", exist_ok=True)
17
+ image_path = f"results/{session}/avatar.jpg"
18
+ image.save(image_path)
19
+ audio_path = f"results/{session}/audio.wav"
20
+ tts_cmd = f'tts --text "{text}" --out_path {audio_path}'
21
+ subprocess.run(tts_cmd, shell=True, check=True)
22
+ video_cmd = f'python checkpoints/inference.py --driven_audio {audio_path} --source_image {image_path} --result_dir results/{session}'
23
+ subprocess.run(video_cmd, shell=True, check=True)
24
+ return f"results/{session}/video.mp4"
25
+
26
+ gr.Interface(
27
+ fn=generate,
28
+ inputs=[gr.Textbox(label="Script"), gr.Image(label="Avatar Image", type="pil")],
29
+ outputs=gr.Video(label="Generated Video"),
30
+ title="Faceless Video Generator (Free)",
31
+ description="Type your message + upload an image. Get a talking avatar video!"
32
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ gradio
2
+ huggingface_hub
3
+ tts
4
+ torch
5
+ opencv-python
6
+ numpy