File size: 2,783 Bytes
d01b62e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""
UGC Studio preflight check.

Verifies system tools and reports which providers are configured, so you know
exactly what the pipeline will use (and what will fall back) before spending.

Usage:
    uv run python scripts/preflight.py
"""
import os
import shutil
import sys

# Allow running from the repo root.
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__))))

from app.services.providers import registry  # noqa: E402


def _ok(flag: bool) -> str:
    return "OK " if flag else "-- "


def main() -> int:
    print("== System tools ==")
    ffmpeg = shutil.which("ffmpeg") or os.environ.get("IMAGEIO_FFMPEG_EXE")
    magick = shutil.which("magick") or shutil.which("convert")
    print(f"[{_ok(bool(ffmpeg))}] ffmpeg        {ffmpeg or 'NOT FOUND'}")
    print(f"[{_ok(bool(magick))}] imagemagick   {magick or 'NOT FOUND (optional)'}")

    print("\n== Avatar engines ==")
    for name in registry.avatar_provider_names():
        p = registry.get_avatar_provider(name)
        configured = bool(p and p.is_configured())
        print(f"[{_ok(configured)}] {name}")

    print("\n== B-roll engines ==")
    for name in registry.broll_provider_names():
        if name == "stock":
            print(f"[{_ok(True)}] stock (Pexels/Pixabay key in config.toml)")
            continue
        p = registry.get_broll_provider(name)
        print(f"[{_ok(bool(p and p.is_configured()))}] {name}")

    print("\n== Image engines (generative avatar) ==")
    for name in registry.image_provider_names():
        p = registry.get_image_provider(name)
        print(f"[{_ok(bool(p and p.is_configured()))}] {name}")

    print("\n== Lip-sync engines ==")
    for name in registry.lipsync_provider_names():
        if name == "none":
            continue
        p = registry.get_lipsync_provider(name)
        print(f"[{_ok(bool(p and p.is_configured()))}] {name}")

    print("\n== Active selection (env/config) ==")
    av = registry.get_avatar_provider()
    br = registry.get_broll_provider()
    im = registry.get_image_provider()
    lp = registry.get_lipsync_provider()
    print(f"  avatar : {getattr(av, 'name', None)} (configured={bool(av and av.is_configured())})")
    print(f"  b-roll : {getattr(br, 'name', 'stock')} (configured={bool(br and br.is_configured())})")
    print(f"  image  : {getattr(im, 'name', None)} (configured={bool(im and im.is_configured())})")
    print(f"  lipsync: {getattr(lp, 'name', 'none')} (configured={bool(lp and lp.is_configured())})")

    print(
        "\nTip: with no keys the studio still works in stock-fallback mode. "
        "Set UGC_AVATAR_PROVIDER=generative + GEMINI_API_KEY + FAL_KEY for the "
        "ultra-realistic path."
    )
    return 0


if __name__ == "__main__":
    raise SystemExit(main())