File size: 1,335 Bytes
b67dfdb
 
 
 
 
 
 
d749140
b67dfdb
d749140
394c760
5a2068e
d749140
 
b67dfdb
 
 
 
 
 
5a2068e
b67dfdb
 
 
 
 
 
 
f025aa6
d749140
 
8ee11d6
d749140
 
 
b67dfdb
 
 
 
 
 
 
d749140
b67dfdb
 
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 random
import subprocess
import os
import gradio
import gradio as gr


current_dir = os.path.dirname(os.path.abspath(__file__))

def predict(video, audio):
    print(f"Processing video {video} and audio {audio}")
    output_file = f"{current_dir}/results/{random.randint(10,100000)}.mp4"
    command = ["python", "inference.py", "--face", video,
               "--audio", audio, "--outfile", output_file]
    subprocess.run(command, check=True)

    return output_file


with gradio.Blocks(
    title="Video Retalking SpaceAI",
    theme=gr.themes.Base(
        primary_hue=gr.themes.colors.green,
        font=["Source Sans Pro", "Arial", "sans-serif"],
        font_mono=['JetBrains mono', "Consolas", 'Courier New']
    ),
) as demo:
    with gradio.Row():
        gradio.Markdown("# Video Retalking SpaceAI")
        with gradio.Row():
            with gradio.Column():
                v = gradio.Video(label='Source image/video')
            with gradio.Column():
                a = gradio.Audio(
                    type='filepath', label='Target Audio')

            with gradio.Row():
                btn = gradio.Button(value="Synthesize",variant="primary")

        with gradio.Column():
            o = gradio.Video(label="Output Video")

    btn.click(fn=predict, inputs=[v, a], outputs=[o])

demo.queue().launch()