File size: 1,871 Bytes
b7658fb
6b64262
3f97053
 
6b64262
 
 
 
 
3f97053
6b64262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import os
import subprocess
import sys

# --- 1. Clone the VibeVoice Repository ---
# Check if the repository directory already exists
repo_dir = "VibeVoice"
if not os.path.exists(repo_dir):
    print("Cloning the VibeVoice repository...")
    try:
        subprocess.run(
            ["git", "clone", "https://github.com/microsoft/VibeVoice.git"],
            check=True,
            capture_output=True,
            text=True
        )
        print("Repository cloned successfully.")
    except subprocess.CalledProcessError as e:
        print(f"Error cloning repository: {e.stderr}")
        sys.exit(1)
else:
    print("Repository already exists. Skipping clone.")

# --- 2. Install the Package ---
# Navigate into the repository directory
os.chdir(repo_dir)
print(f"Changed directory to: {os.getcwd()}")

print("Installing the VibeVoice package...")
try:
    # Use pip to install the package in editable mode
    subprocess.run(
        [sys.executable, "-m", "pip", "install", "-e", "."],
        check=True,
        capture_output=True,
        text=True
    )
    print("Package installed successfully.")
except subprocess.CalledProcessError as e:
    print(f"Error installing package: {e.stderr}")
    sys.exit(1)

# --- 3. Launch the Gradio Demo ---
# Define the path to the demo script and the model to use
demo_script_path = "demo/gradio_demo.py"
model_id = "microsoft/VibeVoice-1.5B"

# Construct the command to run the demo
# The --share flag is necessary to make the Gradio app accessible within the Hugging Face Space environment
command = [
    "python",
    demo_script_path,
    "--model_path",
    model_id,
    "--share"
]

print(f"Launching Gradio demo with command: {' '.join(command)}")
# Run the command. This will start the Gradio server and launch the demo.
# The process will remain active, serving the web interface.
subprocess.run(command)