@aicopycoders/exodus 2026.11.1100-beta.8 → 2026.11.1100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/docs/CLAUDE.md +2 -0
- package/assets/docs/PIPELINES.md +2 -0
- package/assets/skills/exodus/SKILL.md +2 -0
- package/assets/skills/exodus-video/SKILL.md +8 -6
- package/assets/skills/exodus-video/scripts/first-cut.d.mts +5 -0
- package/assets/skills/exodus-video/scripts/first-cut.mjs +27 -6
- package/assets/skills/swipe/SKILL.md +1 -1
- package/assets/skills/timeline-ad-factory/AGENTS.md +8 -0
- package/assets/skills/timeline-ad-factory/README.md +38 -0
- package/assets/skills/timeline-ad-factory/SKILL.md +132 -0
- package/assets/skills/timeline-ad-factory/reference/00_hook_elements.md +71 -0
- package/assets/skills/timeline-ad-factory/reference/01_elements.md +53 -0
- package/assets/skills/timeline-ad-factory/reference/02_openers.md +83 -0
- package/assets/skills/timeline-ad-factory/reference/03_script_rules.md +83 -0
- package/assets/skills/timeline-ad-factory/reference/04_storyboard.md +153 -0
- package/assets/skills/timeline-ad-factory/reference/05_generation.md +57 -0
- package/assets/skills/timeline-ad-factory/scripts/assemble.py +86 -0
- package/assets/skills/timeline-ad-factory/scripts/contact_sheet.py +76 -0
- package/assets/skills/timeline-ad-factory/scripts/cost_report.py +25 -0
- package/assets/skills/timeline-ad-factory/scripts/gen_images.py +76 -0
- package/assets/skills/timeline-ad-factory/scripts/gen_music.py +36 -0
- package/assets/skills/timeline-ad-factory/scripts/gen_video.py +167 -0
- package/assets/skills/timeline-ad-factory/scripts/gen_vo.py +180 -0
- package/assets/skills/timeline-ad-factory/scripts/kie.py +168 -0
- package/assets/skills/timeline-ad-factory/scripts/review_clips.py +39 -0
- package/assets/skills/timeline-ad-factory/scripts/setup_check.py +54 -0
- package/assets/skills/timeline-ad-factory/scripts/voices.py +2 -0
- package/assets/skills/timeline-ad-factory/templates/project.json +38 -0
- package/assets/skills/ugc-ads/SKILL.md +32 -0
- package/assets/skills/ugc-ads/scripts/run.py +83 -0
- package/assets/skills/ugc-preproduction/SKILL.md +56 -0
- package/assets/skills/ugc-swipe/SKILL.md +34 -0
- package/assets/skills/ugc-template/SKILL.md +40 -0
- package/assets/skills/ugc-write/SKILL.md +33 -0
- package/dist/commands/video-swipe.d.ts +6 -2
- package/dist/commands/video-swipe.js +82 -12
- package/dist/commands/video.js +10 -2
- package/package.json +1 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"""Video clips for every shot. Omni (Google) by default; Seedance 2.5 as the upgrade.
|
|
2
|
+
python scripts/gen_video.py <project> --estimate (clip plan + cost for both models, spends nothing)
|
|
3
|
+
python scripts/gen_video.py <project> [--model omni|seedance] [--resolution 1080p|720p] [--only 3,7]
|
|
4
|
+
Run gen_vo.py first: shot lengths come from the voiceover timestamps.
|
|
5
|
+
"""
|
|
6
|
+
import argparse, json, math, os, subprocess, sys, threading, time
|
|
7
|
+
from PIL import Image
|
|
8
|
+
import kie
|
|
9
|
+
|
|
10
|
+
ap = argparse.ArgumentParser(); ap.add_argument("project"); ap.add_argument("--model", default="omni", choices=["omni", "seedance"])
|
|
11
|
+
ap.add_argument("--resolution", default=""); ap.add_argument("--only", default=""); ap.add_argument("--estimate", action="store_true")
|
|
12
|
+
a = ap.parse_args()
|
|
13
|
+
root, P = kie.project(a.project)
|
|
14
|
+
only = {x.strip() for x in a.only.split(",") if x.strip()}
|
|
15
|
+
AR = P.get("aspect_ratio", "9:16")
|
|
16
|
+
VID = os.path.join(root, "videos"); os.makedirs(VID, exist_ok=True)
|
|
17
|
+
lock = threading.Lock()
|
|
18
|
+
def log(*x):
|
|
19
|
+
with lock: print(*x, flush=True)
|
|
20
|
+
|
|
21
|
+
if any("t0" not in s for s in P["shots"]):
|
|
22
|
+
raise SystemExit("Shots aren't timed yet. Run: python scripts/gen_vo.py " + a.project)
|
|
23
|
+
|
|
24
|
+
def secs(b):
|
|
25
|
+
x, y = b[0].rstrip("s").split("-"); return float(x), float(y)
|
|
26
|
+
|
|
27
|
+
OMNI_LEN = (4, 6, 8, 10)
|
|
28
|
+
OMNI_CREDITS = {4: 63, 6: 84, 8: 105, 10: 126} # measured at 1080p, Nov 2026
|
|
29
|
+
SEED_CREDITS = {"1080p": 158, "720p": 63, "480p": 28} # per second, image input, Kie list price Nov 2026
|
|
30
|
+
|
|
31
|
+
def omni_len(span):
|
|
32
|
+
for d in OMNI_LEN:
|
|
33
|
+
if d >= span - 0.6: return d
|
|
34
|
+
return 10
|
|
35
|
+
|
|
36
|
+
def omni_plan(s):
|
|
37
|
+
"""Split a shot into Omni clips (each <= 10s), on beat boundaries."""
|
|
38
|
+
w = s["t1"] - s["t0"]; beats = s.get("beats") or [[f"0-{math.ceil(w)}s", " ".join(s["panels"])]]
|
|
39
|
+
if w <= 10.5 or len(beats) == 1:
|
|
40
|
+
return [(list(range(len(beats))), omni_len(w))]
|
|
41
|
+
groups, cur, cur0 = [], [], 0.0
|
|
42
|
+
scale = w / max(secs(beats[-1])[1], 0.1)
|
|
43
|
+
for i, b in enumerate(beats):
|
|
44
|
+
if cur and (secs(b)[1] - cur0) * scale > 10.4:
|
|
45
|
+
groups.append(cur); cur = []; cur0 = secs(b)[0]
|
|
46
|
+
cur.append(i)
|
|
47
|
+
groups.append(cur)
|
|
48
|
+
return [(g, omni_len((secs(beats[g[-1]])[1] - secs(beats[g[0]])[0]) * scale)) for g in groups]
|
|
49
|
+
|
|
50
|
+
def panel_paths(s):
|
|
51
|
+
return [os.path.join(root, "images", "panels", f"shot_{s['id']:02d}_p{i+1}.png") for i in range(len(s["panels"]))]
|
|
52
|
+
|
|
53
|
+
if a.estimate:
|
|
54
|
+
oc = 0; secs_seed = 0; n = 0
|
|
55
|
+
print(f"{'shot':>4} {'VO secs':>8} Omni clips")
|
|
56
|
+
for s in P["shots"]:
|
|
57
|
+
plan = omni_plan(s); oc += sum(OMNI_CREDITS[d] for _, d in plan); n += len(plan)
|
|
58
|
+
sd = max(5, min(15, math.ceil(s["t1"] - s["t0"]))); secs_seed += sd
|
|
59
|
+
print(f"{s['id']:>4} {s['t1']-s['t0']:8.1f} {[d for _, d in plan]}")
|
|
60
|
+
print(f"\nOmni 1080p: {n} clips, ~{oc} credits = ~${oc*0.005:.2f}")
|
|
61
|
+
for r in ("720p", "1080p"):
|
|
62
|
+
c = secs_seed * SEED_CREDITS[r]; print(f"Seedance {r:>5}: {len(P['shots'])} clips, ~{c} credits = ~${c*0.005:.2f}")
|
|
63
|
+
print("(Estimates from Kie prices as of Nov 2026. cost_report.py gives the real number after the run.)")
|
|
64
|
+
raise SystemExit
|
|
65
|
+
|
|
66
|
+
CHAR = P["character"]["lock"]
|
|
67
|
+
CAST = {c["name"]: c["lock"] for c in [P["character"]] + P.get("extra_cast", []) if c.get("lock")}
|
|
68
|
+
|
|
69
|
+
def who(s):
|
|
70
|
+
return " ".join(f"The {n} is {CAST[n]} and keeps exactly this design the whole time." for n in s.get("cast", [P["character"]["name"]]) if n in CAST)
|
|
71
|
+
|
|
72
|
+
def omni_prompt(s, idx, n_img, t0, scale, skip_desc=""):
|
|
73
|
+
roles = " ".join(f"Image {j+1} shows {'the opening moment' if j == 0 and n_img > 1 else ('the final moment' if j == n_img - 1 else 'a middle moment')} of this shot." for j in range(n_img))
|
|
74
|
+
beats = " ".join(f"[{(secs(s['beats'][i])[0]-t0)*scale:.0f}-{(secs(s['beats'][i])[1]-t0)*scale:.0f}s] {s['beats'][i][1]}." for i in idx) if s.get("beats") else ""
|
|
75
|
+
desc = " ".join(s["panels"][i] + "." for i in idx if i < len(s["panels"]))
|
|
76
|
+
return (f"One continuous animated shot. The reference images are the key moments of this shot, in order. {roles} "
|
|
77
|
+
f"Move smoothly from one key moment to the next as one flowing scene. {who(s)} Each character appears exactly once. "
|
|
78
|
+
f"Unless described otherwise the setting is {P['set']}. Scene: {desc} {skip_desc} Timing: {beats} "
|
|
79
|
+
"Energetic, continuous motion from the first frame to the last: every second has visible character action, camera movement "
|
|
80
|
+
"or a transformation in progress. Big cartoon acting with squash-and-stretch, anticipation and follow-through, smooth arcs and "
|
|
81
|
+
f"weighty comic impacts, at full frame rate. Biomechanics stay real: every character faces the direction they travel and walks forward, on stairs they face up the stairs while climbing and step onto the next higher step, weight shifts foot to foot, joints bend the natural way, and nothing moves in reverse. The frame stays purely visual: the animated scene is the only thing on screen, and "
|
|
82
|
+
f"every monitor, screen and sheet of paper shows only colorful pictures. {P['style']}, cinematic lighting.")
|
|
83
|
+
|
|
84
|
+
def run_omni(s, res):
|
|
85
|
+
panels = panel_paths(s); parts = []
|
|
86
|
+
for si, (idx, d) in enumerate(omni_plan(s)):
|
|
87
|
+
out = os.path.join(VID, f"shot_{s['id']:02d}_{si}.mp4"); parts.append(out)
|
|
88
|
+
if os.path.exists(out) and not only: continue
|
|
89
|
+
t0 = secs(s["beats"][idx[0]])[0] if s.get("beats") else 0
|
|
90
|
+
t1 = secs(s["beats"][idx[-1]])[1] if s.get("beats") else d
|
|
91
|
+
scale = d / max(t1 - t0, 0.1)
|
|
92
|
+
img_idx = [i for i in idx if i < len(panels) and os.path.exists(panels[i])] or [0]
|
|
93
|
+
refused = 0; redrawn = False
|
|
94
|
+
for t in range(7):
|
|
95
|
+
if refused >= 2 and not redrawn:
|
|
96
|
+
# Omni's copyright filter flagged the frame(s) (usually a skull that looks like Pixar's Coco).
|
|
97
|
+
# Redraw them automatically with the plain-skull rule and a wider framing, then try again.
|
|
98
|
+
ids = ",".join(f"{s['id']}.{i+1}" for i in img_idx)
|
|
99
|
+
log(f"[shot {s['id']}.{si}] Omni blocked the frame(s) as protected IP; redrawing {ids} and retrying")
|
|
100
|
+
subprocess.run([sys.executable, os.path.join(os.path.dirname(os.path.abspath(__file__)), "gen_images.py"),
|
|
101
|
+
root, "--panels", "--only", ids, "--wider"], check=False)
|
|
102
|
+
redrawn = True; refused = 0
|
|
103
|
+
use = img_idx if (refused < 2 or redrawn) else img_idx[-1:]
|
|
104
|
+
skip = "" if use == img_idx else "The earlier moment is described in words only."
|
|
105
|
+
try:
|
|
106
|
+
urls = [kie.upload(panels[i]) for i in use]
|
|
107
|
+
tid = kie.create("gemini-omni-video", {"prompt": omni_prompt(s, idx, len(use), t0, scale, skip), "image_urls": urls,
|
|
108
|
+
"duration": d, "aspect_ratio": AR, "resolution": res}, note=f"omni shot {s['id']}.{si} {d}s")
|
|
109
|
+
log(f"[shot {s['id']}.{si}] omni {d}s submitted")
|
|
110
|
+
kie.download(kie.first_url(kie.wait(tid, 1800, 10)), out); break
|
|
111
|
+
except Exception as e:
|
|
112
|
+
if "protected" in str(e).lower() or "restricted" in str(e).lower(): refused += 1
|
|
113
|
+
log(f"[shot {s['id']}.{si}] retry {t}: {e}"); time.sleep(10)
|
|
114
|
+
return parts
|
|
115
|
+
|
|
116
|
+
def strip(s):
|
|
117
|
+
"""Seedance takes ONE reference image: stitch the panels side by side into a shot-list strip."""
|
|
118
|
+
ims = [Image.open(p).convert("RGB") for p in panel_paths(s) if os.path.exists(p)]
|
|
119
|
+
h = 720; ims = [im.resize((int(im.width * h / im.height), h)) for im in ims]; gap = 16
|
|
120
|
+
S = Image.new("RGB", (sum(im.width for im in ims) + gap * (len(ims) - 1), h), "black"); x = 0
|
|
121
|
+
for im in ims: S.paste(im, (x, 0)); x += im.width + gap
|
|
122
|
+
out = os.path.join(VID, f"strip_{s['id']:02d}.png"); S.save(out); return out, len(ims)
|
|
123
|
+
|
|
124
|
+
def run_seedance(s, res):
|
|
125
|
+
out = os.path.join(VID, f"shot_{s['id']:02d}_0.mp4")
|
|
126
|
+
if os.path.exists(out) and not only: return [out]
|
|
127
|
+
sp, n = strip(s); d = max(5, min(15, math.ceil(s["t1"] - s["t0"])))
|
|
128
|
+
beats = " ".join(f"[{b[0]}] {b[1]}." for b in s.get("beats", []))
|
|
129
|
+
prompt = ("ABSOLUTELY NO SUBTITLES, NO CAPTIONS, NO OVERLAY TEXT, NO BURNED-IN TYPOGRAPHY OF ANY KIND. The output frame contains ONLY the rendered scene. "
|
|
130
|
+
"This is a SILENT video for separate audio overlay in post-production. "
|
|
131
|
+
f"The reference image is a SHOT LIST showing the {n} frames you must render in sequence as ONE continuous scene. Do NOT render the frame gaps "
|
|
132
|
+
"or any storyboard layout in your output. Animate ONLY the scene content, transitioning smoothly between the frames in order, full-frame single composition. "
|
|
133
|
+
"Aggressive motion throughout, NO static held frames longer than 0.5s, every second has visible character action OR camera movement OR transformation in progress. "
|
|
134
|
+
"PHYSICS: squash-and-stretch on every action, anticipation and follow-through, smooth arcs, weight-believable comic impacts. NO stop-motion, NO freeze frames. "
|
|
135
|
+
"BIOMECHANICS: every character faces the direction they travel and walks FORWARD, never backward; climbing stairs = facing up the stairs; joints bend naturally; nothing moves in reverse. "
|
|
136
|
+
f"{beats} GLOBAL: Maintain exact storyboard continuity. {who(s)} EXACTLY ONE of each character, NO twins. NO visible storyboard panel borders, NO panel numbers, "
|
|
137
|
+
"NO titles, NO subtitles, NO logos, NO letters on screens or papers. Continuous animated motion at full frame rate.")
|
|
138
|
+
for t in range(3):
|
|
139
|
+
try:
|
|
140
|
+
tid = kie.create("bytedance/seedance-2-5", {"prompt": prompt, "reference_image_urls": [kie.upload(sp)], "aspect_ratio": AR,
|
|
141
|
+
"resolution": res, "duration": d, "generate_audio": False}, note=f"seedance shot {s['id']} {d}s")
|
|
142
|
+
log(f"[shot {s['id']}] seedance {d}s submitted")
|
|
143
|
+
kie.download(kie.first_url(kie.wait(tid, 2400, 12)), out); break
|
|
144
|
+
except Exception as e:
|
|
145
|
+
log(f"[shot {s['id']}] retry {t}: {e}"); time.sleep(15)
|
|
146
|
+
return [out]
|
|
147
|
+
|
|
148
|
+
def run(s):
|
|
149
|
+
try:
|
|
150
|
+
res = a.resolution or ("1080p" if a.model == "omni" else "720p")
|
|
151
|
+
parts = run_omni(s, res) if a.model == "omni" else run_seedance(s, res)
|
|
152
|
+
if not all(os.path.exists(p) for p in parts): log(f"[shot {s['id']}] INCOMPLETE, re-run with --only {s['id']}"); return
|
|
153
|
+
lst = os.path.join(VID, f"shot_{s['id']:02d}_list.txt")
|
|
154
|
+
open(lst, "w").write("".join(f"file '{os.path.basename(p)}'\n" for p in parts))
|
|
155
|
+
subprocess.run(["ffmpeg", "-y", "-v", "error", "-f", "concat", "-safe", "0", "-i", lst, "-an", "-c:v", "libx264", "-preset", "fast",
|
|
156
|
+
"-crf", "18", "-pix_fmt", "yuv420p", os.path.join(VID, f"shot_{s['id']:02d}.mp4")], check=True)
|
|
157
|
+
log(f"[shot {s['id']}] DONE")
|
|
158
|
+
except Exception as e:
|
|
159
|
+
log(f"[shot {s['id']}] FAILED: {e}")
|
|
160
|
+
|
|
161
|
+
ths = []
|
|
162
|
+
for s in P["shots"]:
|
|
163
|
+
if only and str(s["id"]) not in only: continue
|
|
164
|
+
t = threading.Thread(target=run, args=(s,)); t.start(); ths.append(t); time.sleep(2)
|
|
165
|
+
for t in ths: t.join()
|
|
166
|
+
P["video_model"] = a.model; kie.save(root, P)
|
|
167
|
+
print("All shots attempted. Next: python scripts/gen_music.py " + a.project + " (optional), then python scripts/assemble.py " + a.project)
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"""Voiceover, then exact timing for every shot and stamp.
|
|
2
|
+
Two voice providers (project.json -> "voice": {"provider": "kie" | "elevenlabs", "name": ...}):
|
|
3
|
+
kie (default, needs only the Kie key): each script line is voiced separately (with the lines around it as
|
|
4
|
+
continuity hints so it reads as one performance), measured, and joined. Shot timing is exact.
|
|
5
|
+
elevenlabs (needs ELEVENLABS_API_KEY in .env): the whole script in one read, with exact word timestamps.
|
|
6
|
+
Usage:
|
|
7
|
+
python scripts/gen_vo.py <project> (reads script.txt -> audio/vo.mp3 + audio/words.json, times all shots)
|
|
8
|
+
python scripts/gen_vo.py <project> --test-voice NAME (one line in that voice -> audio/test_NAME.mp3)
|
|
9
|
+
python scripts/gen_vo.py <project> --retime (re-time shots from the existing audio files)
|
|
10
|
+
"""
|
|
11
|
+
import argparse, base64, json, os, re, subprocess, threading, time, urllib.request
|
|
12
|
+
import kie
|
|
13
|
+
from voices import VOICES # name -> voice ID (same IDs on Kie and ElevenLabs). Preview: https://static.aiquickdraw.com/elevenlabs/voice/<ID>.mp3
|
|
14
|
+
|
|
15
|
+
ap = argparse.ArgumentParser(); ap.add_argument("project"); ap.add_argument("--test-voice", default="")
|
|
16
|
+
ap.add_argument("--retime", action="store_true"); a = ap.parse_args()
|
|
17
|
+
root, P = kie.project(a.project)
|
|
18
|
+
AUD = os.path.join(root, "audio"); os.makedirs(AUD, exist_ok=True)
|
|
19
|
+
MODEL = "elevenlabs/text-to-speech-multilingual-v2"
|
|
20
|
+
ACR = set(P.get("acronyms", ["AI"]))
|
|
21
|
+
V = P.get("voice", {})
|
|
22
|
+
|
|
23
|
+
def voice_id(v):
|
|
24
|
+
if v in VOICES.values(): return v
|
|
25
|
+
k = next((n for n in VOICES if n.lower() == v.lower()), None)
|
|
26
|
+
if not k: raise SystemExit(f"Unknown voice '{v}'. Pick one of: {', '.join(VOICES)}")
|
|
27
|
+
return VOICES[k]
|
|
28
|
+
|
|
29
|
+
PRON = P.get("pronounce", {}) # e.g. {"softgels": "soft jells", "CoQ10": "co Q ten"}: what the VOICE says for tricky words
|
|
30
|
+
|
|
31
|
+
def speakable(line):
|
|
32
|
+
line = line.replace("(", "").replace(")", "")
|
|
33
|
+
for w, say in PRON.items():
|
|
34
|
+
line = re.sub(r"(?i)" + re.escape(w) + r"", say, line)
|
|
35
|
+
return re.sub(r"\b[A-Z][A-Z']+\b", lambda m: m.group(0) if m.group(0) in ACR else m.group(0).lower(), line).strip()
|
|
36
|
+
|
|
37
|
+
def norm(w):
|
|
38
|
+
return re.sub(r"[^a-z0-9']", "", w.lower())
|
|
39
|
+
|
|
40
|
+
def duration(p):
|
|
41
|
+
return float(subprocess.run(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", p],
|
|
42
|
+
capture_output=True, text=True).stdout.strip())
|
|
43
|
+
|
|
44
|
+
def eleven_key():
|
|
45
|
+
if os.environ.get("ELEVENLABS_API_KEY"): return os.environ["ELEVENLABS_API_KEY"].strip()
|
|
46
|
+
for pth in (os.path.join(os.getcwd(), ".env"), os.path.join(kie.SKILL, ".env")):
|
|
47
|
+
if os.path.exists(pth):
|
|
48
|
+
m = re.search(r"^[ \t]*ELEVENLABS_API_KEY[ \t]*=[ \t]*(\S[^\r\n]*?)[ \t\r]*$", open(pth, encoding="utf-8").read(), re.M)
|
|
49
|
+
if m: return m.group(1).strip().strip("\"'")
|
|
50
|
+
return None
|
|
51
|
+
|
|
52
|
+
def settings():
|
|
53
|
+
return {"stability": V.get("stability", 0.38), "similarity_boost": V.get("similarity_boost", 0.8),
|
|
54
|
+
"style": V.get("style", 0.4), "speed": V.get("speed", 1.0)}
|
|
55
|
+
|
|
56
|
+
def kie_line(text, voice, out, prev="", nxt=""):
|
|
57
|
+
inp = {"text": text, "voice": voice_id(voice), **settings(), "previous_text": prev[-1000:], "next_text": nxt[:1000]}
|
|
58
|
+
last = None
|
|
59
|
+
for t in range(4):
|
|
60
|
+
try:
|
|
61
|
+
tid = kie.create(MODEL, inp, note="voiceover line")
|
|
62
|
+
kie.download(kie.first_url(kie.wait(tid, 600, 4)), out); return
|
|
63
|
+
except Exception as e:
|
|
64
|
+
last = e; time.sleep(15 * (t + 1))
|
|
65
|
+
raise RuntimeError(f"Kie voice failed: {last}")
|
|
66
|
+
|
|
67
|
+
def eleven_full(text, voice, out):
|
|
68
|
+
st = settings()
|
|
69
|
+
body = {"text": text, "model_id": "eleven_multilingual_v2",
|
|
70
|
+
"voice_settings": {"stability": st["stability"], "similarity_boost": st["similarity_boost"], "style": st["style"],
|
|
71
|
+
"use_speaker_boost": True, "speed": st["speed"]}}
|
|
72
|
+
req = urllib.request.Request(f"https://api.elevenlabs.io/v1/text-to-speech/{voice_id(voice)}/with-timestamps",
|
|
73
|
+
data=json.dumps(body).encode(), headers={"xi-api-key": eleven_key(), "Content-Type": "application/json"})
|
|
74
|
+
j = json.loads(urllib.request.urlopen(req, timeout=300).read())
|
|
75
|
+
open(out, "wb").write(base64.b64decode(j["audio_base64"]))
|
|
76
|
+
al = j["alignment"]; words, cur = [], None
|
|
77
|
+
for c, s, e in zip(al["characters"], al["character_start_times_seconds"], al["character_end_times_seconds"]):
|
|
78
|
+
if c.isspace():
|
|
79
|
+
if cur: words.append(cur); cur = None
|
|
80
|
+
continue
|
|
81
|
+
if cur is None: cur = {"w": c, "s": s, "e": e}
|
|
82
|
+
else: cur["w"] += c; cur["e"] = e
|
|
83
|
+
if cur: words.append(cur)
|
|
84
|
+
return words
|
|
85
|
+
|
|
86
|
+
def spread(text, t0, t1):
|
|
87
|
+
"""Words inside one line, spread across the line's measured time by length."""
|
|
88
|
+
ws = text.split(); chars = sum(len(w) + 1 for w in ws) or 1; t = t0; out = []
|
|
89
|
+
for w in ws:
|
|
90
|
+
d = (t1 - t0) * (len(w) + 1) / chars; out.append({"w": w, "s": round(t, 3), "e": round(t + d * 0.92, 3)}); t += d
|
|
91
|
+
return out
|
|
92
|
+
|
|
93
|
+
provider = (V.get("provider") or "kie").lower()
|
|
94
|
+
voice = V.get("name") or "Brian"
|
|
95
|
+
if provider == "elevenlabs" and not eleven_key():
|
|
96
|
+
raise SystemExit("voice.provider is 'elevenlabs' but no ELEVENLABS_API_KEY is in .env. Add it, or set provider to 'kie'.")
|
|
97
|
+
|
|
98
|
+
if a.test_voice:
|
|
99
|
+
first = next(l for l in open(os.path.join(root, "script.txt"), encoding="utf-8").read().splitlines() if l.strip())
|
|
100
|
+
out = os.path.join(AUD, f"test_{a.test_voice.replace(' ', '_')}.mp3")
|
|
101
|
+
if provider == "elevenlabs": eleven_full(speakable(first), a.test_voice, out)
|
|
102
|
+
else: kie_line(speakable(first), a.test_voice, out)
|
|
103
|
+
print(out); raise SystemExit
|
|
104
|
+
|
|
105
|
+
lines = [l.strip() for l in open(os.path.join(root, "script.txt"), encoding="utf-8").read().splitlines() if l.strip()]
|
|
106
|
+
spoken = [speakable(l) for l in lines]
|
|
107
|
+
vo = os.path.join(AUD, "vo.mp3"); wj = os.path.join(AUD, "words.json"); lj = os.path.join(AUD, "lines.json")
|
|
108
|
+
|
|
109
|
+
if not a.retime:
|
|
110
|
+
if provider == "elevenlabs":
|
|
111
|
+
words = eleven_full("\n".join(spoken), voice, vo)
|
|
112
|
+
idx = 0; line_spans = []
|
|
113
|
+
for sp in spoken:
|
|
114
|
+
n = len(sp.split()); seg = words[idx: idx + n] or words[-1:]
|
|
115
|
+
line_spans.append([seg[0]["s"], seg[-1]["e"]]); idx += n
|
|
116
|
+
if abs(idx - len(words)) > 3:
|
|
117
|
+
print(f"[warn] script has {idx} words but the voice returned {len(words)}. Check numbers/acronyms were read right.")
|
|
118
|
+
else:
|
|
119
|
+
LD = os.path.join(AUD, "lines"); os.makedirs(LD, exist_ok=True)
|
|
120
|
+
outs = [os.path.join(LD, f"line_{i:02d}.mp3") for i in range(len(spoken))]
|
|
121
|
+
errs = []
|
|
122
|
+
def job(i):
|
|
123
|
+
try:
|
|
124
|
+
if not os.path.exists(outs[i]):
|
|
125
|
+
kie_line(spoken[i], voice, outs[i], " ".join(spoken[max(0, i - 2):i]), " ".join(spoken[i + 1:i + 3]))
|
|
126
|
+
except Exception as e:
|
|
127
|
+
errs.append((i, e))
|
|
128
|
+
ths = [threading.Thread(target=job, args=(i,)) for i in range(len(spoken))]
|
|
129
|
+
for t in ths: t.start(); time.sleep(0.5)
|
|
130
|
+
for t in ths: t.join()
|
|
131
|
+
if errs:
|
|
132
|
+
if eleven_key():
|
|
133
|
+
P.setdefault("voice", {})["provider"] = "elevenlabs"; kie.save(root, P)
|
|
134
|
+
raise SystemExit(f"Kie's voice service failed on {len(errs)} line(s). This ad is now set to use your ElevenLabs key: re-run gen_vo.py.")
|
|
135
|
+
raise SystemExit(f"Kie's voice service failed on {len(errs)} line(s): {errs[0][1]}. Re-run in a few minutes "
|
|
136
|
+
"(finished lines are kept), or add ELEVENLABS_API_KEY to .env and set voice.provider to 'elevenlabs'.")
|
|
137
|
+
# trim each line's leading/trailing silence, then join with a short natural pause
|
|
138
|
+
GAP = 0.18; parts = []; line_spans = []; t = 0.0
|
|
139
|
+
for i, o in enumerate(outs):
|
|
140
|
+
tr = os.path.join(LD, f"trim_{i:02d}.wav")
|
|
141
|
+
subprocess.run(["ffmpeg", "-y", "-v", "error", "-i", o, "-af",
|
|
142
|
+
"silenceremove=start_periods=1:start_threshold=-45dB,areverse,silenceremove=start_periods=1:start_threshold=-45dB,areverse",
|
|
143
|
+
"-ar", "44100", "-ac", "1", tr], check=True)
|
|
144
|
+
d = duration(tr); line_spans.append([round(t, 3), round(t + d, 3)]); t += d + GAP; parts.append(tr)
|
|
145
|
+
subprocess.run(["ffmpeg", "-y", "-v", "error", "-f", "lavfi", "-i", "anullsrc=r=44100:cl=mono", "-t", str(GAP),
|
|
146
|
+
os.path.join(LD, "gap.wav")], check=True)
|
|
147
|
+
lst = os.path.join(LD, "concat.txt")
|
|
148
|
+
open(lst, "w").write("".join(f"file '{os.path.basename(p)}'\nfile 'gap.wav'\n" for p in parts))
|
|
149
|
+
subprocess.run(["ffmpeg", "-y", "-v", "error", "-f", "concat", "-safe", "0", "-i", lst, "-c:a", "libmp3lame", "-q:a", "2", vo], check=True)
|
|
150
|
+
words = []
|
|
151
|
+
for sp, (s0, s1) in zip(spoken, line_spans): words += spread(sp, s0, s1)
|
|
152
|
+
json.dump(words, open(wj, "w", encoding="utf-8"), indent=1)
|
|
153
|
+
json.dump(line_spans, open(lj, "w"))
|
|
154
|
+
|
|
155
|
+
words = json.load(open(wj, encoding="utf-8")); line_spans = json.load(open(lj))
|
|
156
|
+
total = duration(vo)
|
|
157
|
+
|
|
158
|
+
# Shots consume script lines in order (works even when two lines are identical, like "Nothing.").
|
|
159
|
+
shots = P["shots"]; ptr = 0
|
|
160
|
+
for k, s in enumerate(shots):
|
|
161
|
+
start = None
|
|
162
|
+
for l in s["lines"]:
|
|
163
|
+
if ptr >= len(lines) or lines[ptr] != l.strip():
|
|
164
|
+
got = lines[ptr] if ptr < len(lines) else "(end of script)"
|
|
165
|
+
raise SystemExit(f"Shot {s['id']}: expected script line '{got}' but project.json has '{l}'. Shot lines must copy script.txt exactly, in order.")
|
|
166
|
+
if start is None: start = line_spans[ptr][0]
|
|
167
|
+
ptr += 1
|
|
168
|
+
s["t0"] = 0.0 if k == 0 else round(start, 3)
|
|
169
|
+
if ptr != len(lines): raise SystemExit(f"{len(lines) - ptr} script line(s) aren't in any shot. Every line needs a shot.")
|
|
170
|
+
for k, s in enumerate(shots):
|
|
171
|
+
s["t1"] = shots[k + 1]["t0"] if k + 1 < len(shots) else round(total, 3)
|
|
172
|
+
ws = [norm(w["w"]) for w in words]
|
|
173
|
+
for st in P.get("stamps", []):
|
|
174
|
+
target = [norm(w) for w in speakable(st["say"]).split()]
|
|
175
|
+
hit = next((i for i in range(len(ws)) if ws[i:i + len(target)] == target), None)
|
|
176
|
+
st["at"] = round(words[hit]["s"], 3) if hit is not None else None
|
|
177
|
+
if hit is None: print(f"[warn] stamp '{st['say']}' not found in the voiceover")
|
|
178
|
+
P["vo_seconds"] = round(total, 2); kie.save(root, P)
|
|
179
|
+
print(f"Voiceover ({provider}, {voice}): {total:.1f}s -> {vo}")
|
|
180
|
+
for s in shots: print(f" shot {s['id']:>2} {s.get('label',''):<10} {s['t0']:7.2f} - {s['t1']:7.2f} ({s['t1']-s['t0']:.1f}s)")
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"""Minimal Kie.ai client shared by every script. Reads KIE_API_KEY from the environment or a .env file
|
|
2
|
+
(current folder, then the skill folder). Logs every task id to <project>/tasks.log for cost_report.py."""
|
|
3
|
+
import json, os, re, shutil, subprocess, sys, threading, time, urllib.request
|
|
4
|
+
|
|
5
|
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
6
|
+
SKILL = os.path.dirname(HERE)
|
|
7
|
+
|
|
8
|
+
def _load_key():
|
|
9
|
+
if os.environ.get("KIE_API_KEY"):
|
|
10
|
+
return os.environ["KIE_API_KEY"].strip()
|
|
11
|
+
for p in (os.path.join(os.getcwd(), ".env"), os.path.join(SKILL, ".env")):
|
|
12
|
+
if os.path.exists(p):
|
|
13
|
+
m = re.search(r"^[ \t]*KIE_API_KEY[ \t]*=[ \t]*(\S[^\r\n]*?)[ \t\r]*$", open(p, encoding="utf-8").read(), re.M)
|
|
14
|
+
if m:
|
|
15
|
+
return m.group(1).strip().strip("\"'")
|
|
16
|
+
sys.exit("No Kie.ai API key found. Run: python scripts/setup_check.py")
|
|
17
|
+
|
|
18
|
+
KEY = _load_key()
|
|
19
|
+
|
|
20
|
+
def _env_value(name):
|
|
21
|
+
v = os.environ.get(name, "").strip()
|
|
22
|
+
for p in (os.path.join(os.getcwd(), ".env"), os.path.join(SKILL, ".env")):
|
|
23
|
+
if not v and os.path.exists(p):
|
|
24
|
+
m = re.search(rf"^[ \t]*{name}[ \t]*=[ \t]*(\S[^\r\n]*?)[ \t\r]*$", open(p, encoding="utf-8").read(), re.M)
|
|
25
|
+
v = m.group(1).strip().strip("\"'") if m else ""
|
|
26
|
+
return v
|
|
27
|
+
|
|
28
|
+
try: _ELEVEN = _env_value("ELEVENLABS_API_KEY")
|
|
29
|
+
except Exception: _ELEVEN = ""
|
|
30
|
+
|
|
31
|
+
def _hide_keys(text):
|
|
32
|
+
for v in (KEY, _ELEVEN):
|
|
33
|
+
if v: text = text.replace(v, "***")
|
|
34
|
+
return text
|
|
35
|
+
|
|
36
|
+
class _HideKeys:
|
|
37
|
+
# Everything the scripts print, errors and exit messages included, goes through here, so no key is ever shown.
|
|
38
|
+
def __init__(self, f): self._f = f
|
|
39
|
+
def write(self, s): return self._f.write(_hide_keys(s))
|
|
40
|
+
def __getattr__(self, n): return getattr(self._f, n)
|
|
41
|
+
sys.stdout, sys.stderr = _HideKeys(sys.stdout), _HideKeys(sys.stderr)
|
|
42
|
+
|
|
43
|
+
def _plain(t, e, tb):
|
|
44
|
+
# One plain sentence instead of a traceback.
|
|
45
|
+
where, msg = "", str(e)
|
|
46
|
+
while tb is not None:
|
|
47
|
+
if os.path.dirname(os.path.abspath(tb.tb_frame.f_code.co_filename)) == HERE:
|
|
48
|
+
where = f" in {os.path.basename(tb.tb_frame.f_code.co_filename)} line {tb.tb_lineno}"
|
|
49
|
+
tb = tb.tb_next
|
|
50
|
+
sys.stderr.write(f"Stopped{where}: {t.__name__}: {msg}\n")
|
|
51
|
+
sys.excepthook = _plain
|
|
52
|
+
threading.excepthook = lambda x: _plain(x.exc_type, x.exc_value, x.exc_traceback)
|
|
53
|
+
|
|
54
|
+
class _DropKeysOnRedirect(urllib.request.HTTPRedirectHandler):
|
|
55
|
+
# A redirect never carries the Kie or ElevenLabs key to another address.
|
|
56
|
+
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
|
57
|
+
new = super().redirect_request(req, fp, code, msg, headers, newurl)
|
|
58
|
+
if new is not None:
|
|
59
|
+
for h in ("Authorization", "Xi-api-key"):
|
|
60
|
+
new.headers.pop(h, None); new.unredirected_hdrs.pop(h, None)
|
|
61
|
+
return new
|
|
62
|
+
urllib.request.install_opener(urllib.request.build_opener(_DropKeysOnRedirect))
|
|
63
|
+
|
|
64
|
+
H = {"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"}
|
|
65
|
+
LOG = None # set by scripts to <project>/tasks.log
|
|
66
|
+
|
|
67
|
+
def _req(url, body=None, timeout=60):
|
|
68
|
+
data = json.dumps(body).encode() if body is not None else None
|
|
69
|
+
r = urllib.request.Request(url, data=data, headers=H, method="POST" if data else "GET")
|
|
70
|
+
with urllib.request.urlopen(r, timeout=timeout) as resp:
|
|
71
|
+
return json.loads(resp.read())
|
|
72
|
+
|
|
73
|
+
def _log(kind, tid, note=""):
|
|
74
|
+
if LOG:
|
|
75
|
+
with open(LOG, "a", encoding="utf-8") as f:
|
|
76
|
+
f.write(json.dumps({"t": time.time(), "kind": kind, "task": tid, "note": note}) + "\n")
|
|
77
|
+
|
|
78
|
+
def create(model, inp, note=""):
|
|
79
|
+
last = None
|
|
80
|
+
for a in range(5):
|
|
81
|
+
try:
|
|
82
|
+
j = _req("https://api.kie.ai/api/v1/jobs/createTask", {"model": model, "input": inp})
|
|
83
|
+
if j.get("code") == 200:
|
|
84
|
+
tid = j["data"]["taskId"]
|
|
85
|
+
try: _log(model, tid, note)
|
|
86
|
+
except OSError: pass # the task is already bought: a log failure must not buy it again
|
|
87
|
+
return tid
|
|
88
|
+
last = f"{j.get('code')} {j.get('msg')}"
|
|
89
|
+
if j.get("code") in (401, 402): # bad key / no credits: retrying won't help
|
|
90
|
+
break
|
|
91
|
+
except Exception as e:
|
|
92
|
+
last = str(e)
|
|
93
|
+
time.sleep(5 * (a + 1))
|
|
94
|
+
raise RuntimeError(f"createTask failed for {model}: {last}")
|
|
95
|
+
|
|
96
|
+
def wait(tid, timeout=1800, poll=8):
|
|
97
|
+
t0 = time.time()
|
|
98
|
+
while time.time() - t0 < timeout:
|
|
99
|
+
try:
|
|
100
|
+
d = _req(f"https://api.kie.ai/api/v1/jobs/recordInfo?taskId={tid}", timeout=30)["data"]
|
|
101
|
+
except Exception:
|
|
102
|
+
time.sleep(poll); continue
|
|
103
|
+
if d.get("state") == "success":
|
|
104
|
+
rj = d.get("resultJson"); rj = json.loads(rj) if isinstance(rj, str) else (rj or {})
|
|
105
|
+
return rj
|
|
106
|
+
if d.get("state") == "fail":
|
|
107
|
+
raise RuntimeError(f"task failed: {d.get('failMsg')}")
|
|
108
|
+
time.sleep(poll)
|
|
109
|
+
raise RuntimeError(f"timeout waiting for {tid}")
|
|
110
|
+
|
|
111
|
+
def first_url(rj):
|
|
112
|
+
for f in ("resultUrls", "urls", "imageUrls", "audioUrls", "output", "audio_url", "url"):
|
|
113
|
+
v = rj.get(f)
|
|
114
|
+
if v:
|
|
115
|
+
return v[0] if isinstance(v, list) else v
|
|
116
|
+
raise RuntimeError(f"no url in result: {str(rj)[:300]}")
|
|
117
|
+
|
|
118
|
+
def record(tid):
|
|
119
|
+
return _req(f"https://api.kie.ai/api/v1/jobs/recordInfo?taskId={tid}", timeout=30)["data"]
|
|
120
|
+
|
|
121
|
+
MAX_DOWNLOAD = 2 * 1024 ** 3 # 2 GB per file
|
|
122
|
+
def download(url, out):
|
|
123
|
+
# https only, into the file the caller names (always inside the project), with a size and a 20-minute limit.
|
|
124
|
+
if not str(url).startswith("https://"):
|
|
125
|
+
raise RuntimeError("Kie sent a download link that isn't https, so it wasn't downloaded")
|
|
126
|
+
t0, n, part = time.time(), 0, out + ".part"
|
|
127
|
+
try:
|
|
128
|
+
with urllib.request.urlopen(url, timeout=60) as resp, open(part, "wb") as f:
|
|
129
|
+
if not resp.geturl().startswith("https://"):
|
|
130
|
+
raise RuntimeError("Kie's download link redirected away from https, so it wasn't downloaded")
|
|
131
|
+
while True:
|
|
132
|
+
b = resp.read1(1 << 20) # returns as data arrives, so the time limit is checked while it trickles
|
|
133
|
+
if not b: break
|
|
134
|
+
n += len(b)
|
|
135
|
+
if n > MAX_DOWNLOAD or time.time() - t0 > 1200:
|
|
136
|
+
raise RuntimeError("the download was too big or too slow, so it was stopped")
|
|
137
|
+
f.write(b)
|
|
138
|
+
os.replace(part, out)
|
|
139
|
+
finally:
|
|
140
|
+
if os.path.exists(part): os.remove(part)
|
|
141
|
+
|
|
142
|
+
def upload(path, upath="timeline-ad-factory"):
|
|
143
|
+
curl = shutil.which("curl") or shutil.which("curl.exe")
|
|
144
|
+
if not curl:
|
|
145
|
+
sys.exit("curl is needed to upload images to Kie (it ships with Mac and Windows 10+).")
|
|
146
|
+
out = subprocess.run([curl, "-s", "--max-time", "120", "-X", "POST",
|
|
147
|
+
"https://kieai.redpandaai.co/api/file-stream-upload",
|
|
148
|
+
"-H", f"Authorization: Bearer {KEY}", "-F", 'file=@"' + path.replace("\\", "\\\\").replace('"', '\\"') + '"', "-F", f"uploadPath={upath}"],
|
|
149
|
+
capture_output=True, text=True).stdout
|
|
150
|
+
d = json.loads(out)["data"]
|
|
151
|
+
return d.get("downloadUrl") or d.get("fileUrl") or d.get("url")
|
|
152
|
+
|
|
153
|
+
def inside(base, p):
|
|
154
|
+
base, p = (os.path.normcase(os.path.realpath(x)) for x in (base, p))
|
|
155
|
+
try: return os.path.commonpath([base, p]) == base
|
|
156
|
+
except ValueError: return False
|
|
157
|
+
|
|
158
|
+
def project(path):
|
|
159
|
+
"""Load project.json and point the task log at the project folder."""
|
|
160
|
+
global LOG
|
|
161
|
+
path = os.path.abspath(path)
|
|
162
|
+
if not inside(os.getcwd(), path):
|
|
163
|
+
sys.exit("The project folder has to be inside the folder you're working in, e.g. projects/<name>.")
|
|
164
|
+
LOG = os.path.join(path, "tasks.log")
|
|
165
|
+
return path, json.load(open(os.path.join(path, "project.json"), encoding="utf-8"))
|
|
166
|
+
|
|
167
|
+
def save(path, P):
|
|
168
|
+
json.dump(P, open(os.path.join(path, "project.json"), "w", encoding="utf-8"), indent=2, ensure_ascii=False)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Director Test on the rendered clips, BEFORE final assembly.
|
|
2
|
+
python scripts/review_clips.py <project> [--only 3,7] -> <project>/review/shot_XX.jpg (one strip per shot, ~2 frames per second)
|
|
3
|
+
+ <project>/review/all_clips.jpg (every strip stacked, labeled)
|
|
4
|
+
Look at every strip and answer the Director Test for each shot (see reference/04_storyboard.md):
|
|
5
|
+
- Is each character FACING the direction they move? (No walking up stairs backwards, no moonwalking.)
|
|
6
|
+
- Do bodies move like real bodies? (Feet on the ground, knees and elbows bend the right way, weight supported, nobody floating.)
|
|
7
|
+
- Any extra or missing limbs/fingers, melting faces, duplicate characters, or a character who shouldn't be there?
|
|
8
|
+
- Any words, letters or logos that crept in?
|
|
9
|
+
- Does the clip act out its line? Right location, costume and props?
|
|
10
|
+
Re-render failures with: python scripts/gen_video.py <project> --only <ids> (fix the panel or beats first if the frame caused it)
|
|
11
|
+
"""
|
|
12
|
+
import glob, json, os, subprocess, sys
|
|
13
|
+
from PIL import Image, ImageDraw
|
|
14
|
+
|
|
15
|
+
root = os.path.abspath(sys.argv[1])
|
|
16
|
+
_cwd, _root = (os.path.normcase(os.path.realpath(x)) for x in (os.getcwd(), root))
|
|
17
|
+
try: _ok = os.path.commonpath([_cwd, _root]) == _cwd
|
|
18
|
+
except ValueError: _ok = False
|
|
19
|
+
if not _ok: raise SystemExit("The project folder has to be inside the folder you're working in, e.g. projects/<name>.")
|
|
20
|
+
only = set()
|
|
21
|
+
if "--only" in sys.argv: only = set(sys.argv[sys.argv.index("--only") + 1].split(","))
|
|
22
|
+
P = json.load(open(os.path.join(root, "project.json"), encoding="utf-8"))
|
|
23
|
+
R = os.path.join(root, "review"); os.makedirs(R, exist_ok=True)
|
|
24
|
+
strips = []
|
|
25
|
+
for s in P["shots"]:
|
|
26
|
+
if only and str(s["id"]) not in only: continue
|
|
27
|
+
src = os.path.join(root, "videos", f"shot_{s['id']:02d}.mp4")
|
|
28
|
+
if not os.path.exists(src): print(f"shot {s['id']}: no clip yet"); continue
|
|
29
|
+
out = os.path.join(R, f"shot_{s['id']:02d}.jpg")
|
|
30
|
+
subprocess.run(["ffmpeg", "-y", "-v", "error", "-i", src, "-vf", "fps=2,scale=180:-2,tile=10x1", "-frames:v", "1", out], check=True)
|
|
31
|
+
strips.append((s, out))
|
|
32
|
+
if strips:
|
|
33
|
+
ims = [(s, Image.open(p).convert("RGB")) for s, p in strips]
|
|
34
|
+
W = max(im.width for _, im in ims); H = sum(im.height + 30 for _, im in ims)
|
|
35
|
+
S = Image.new("RGB", (W, H), (20, 16, 12)); d = ImageDraw.Draw(S); y = 0
|
|
36
|
+
for s, im in ims:
|
|
37
|
+
d.text((6, y + 8), f"SHOT {s['id']} {s.get('label','')}: " + " / ".join(s["lines"])[:150], fill=(246, 198, 82))
|
|
38
|
+
S.paste(im, (0, y + 30)); y += im.height + 30
|
|
39
|
+
out = os.path.join(R, "all_clips.jpg"); S.save(out, quality=82); print(out)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""First-run setup: checks Python, Pillow, ffmpeg and curl, then saves the Kie.ai API key to .env.
|
|
2
|
+
Usage: python scripts/setup_check.py (run from the folder you'll keep your projects in)"""
|
|
3
|
+
import os, re, shutil, subprocess, sys
|
|
4
|
+
|
|
5
|
+
ok = True
|
|
6
|
+
print("Checking your setup...\n")
|
|
7
|
+
if sys.version_info < (3, 9):
|
|
8
|
+
print(f"[X] Python {sys.version.split()[0]} is too old. Install Python 3.9 or newer from python.org."); ok = False
|
|
9
|
+
else:
|
|
10
|
+
print(f"[ok] Python {sys.version.split()[0]}")
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
import PIL # noqa
|
|
14
|
+
print("[ok] Pillow (image tools)")
|
|
15
|
+
except ImportError:
|
|
16
|
+
print("[..] Installing Pillow (image tools)...")
|
|
17
|
+
r = subprocess.run([sys.executable, "-m", "pip", "install", "--quiet", "pillow"])
|
|
18
|
+
print("[ok] Pillow installed" if r.returncode == 0 else "[X] Could not install Pillow. Run: pip install pillow"); ok &= r.returncode == 0
|
|
19
|
+
|
|
20
|
+
for tool, how in (("ffmpeg", "Mac: brew install ffmpeg | Windows: winget install Gyan.FFmpeg (then close and reopen the terminal)"),
|
|
21
|
+
("ffprobe", "comes with ffmpeg"),
|
|
22
|
+
("curl", "ships with Mac and Windows 10+")):
|
|
23
|
+
if shutil.which(tool) or shutil.which(tool + ".exe"):
|
|
24
|
+
print(f"[ok] {tool}")
|
|
25
|
+
else:
|
|
26
|
+
print(f"[X] {tool} not found. {how}"); ok = False
|
|
27
|
+
|
|
28
|
+
env = os.path.join(os.getcwd(), ".env")
|
|
29
|
+
have = os.path.exists(env) and re.search(r"^[ \t]*KIE_API_KEY[ \t]*=[ \t]*\S", open(env, encoding="utf-8").read(), re.M) is not None
|
|
30
|
+
if have:
|
|
31
|
+
print("[ok] Kie.ai API key already saved in .env")
|
|
32
|
+
else:
|
|
33
|
+
# Exodus install: never prompt for a key (Claude can't type into a prompt, and a key must never go through the chat).
|
|
34
|
+
print("\n[X] No Kie.ai API key in .env yet (kie.ai -> sign in -> API Keys). Add it one of two ways, then run this again:")
|
|
35
|
+
print(" 1. If the key is saved in the Exodus dashboard: npx @aicopycoders/exodus keys pull")
|
|
36
|
+
print(" 2. Or open .env in this folder yourself and add the line: KIE_API_KEY=your-key")
|
|
37
|
+
print(" Never paste the key into the chat."); ok = False
|
|
38
|
+
|
|
39
|
+
if ok and "ELEVENLABS_API_KEY" not in open(env, encoding="utf-8").read():
|
|
40
|
+
print()
|
|
41
|
+
print("Optional: an ElevenLabs API key. With it you can voice ads on ElevenLabs directly (exact word timing),")
|
|
42
|
+
print("and it backs up Kie if Kie's voice service is down. To add it, open .env yourself and add the line")
|
|
43
|
+
print("ELEVENLABS_API_KEY=your-key (or save it in the Exodus dashboard and run: npx @aicopycoders/exodus keys pull).")
|
|
44
|
+
|
|
45
|
+
if ok:
|
|
46
|
+
try:
|
|
47
|
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
48
|
+
import kie
|
|
49
|
+
bal = kie._req("https://api.kie.ai/api/v1/chat/credit").get("data")
|
|
50
|
+
print(f"[ok] Kie.ai key works. Credits on the account: {bal} (about ${float(bal) * 0.005:.2f})")
|
|
51
|
+
except Exception as e:
|
|
52
|
+
print(f"[X] The key didn't work: {e}"); ok = False
|
|
53
|
+
|
|
54
|
+
print("\nAll set." if ok else "\nFix the [X] items above, then run this again.")
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
# Kie / ElevenLabs voice IDs by name (from docs.kie.ai, Nov 2026). Preview: https://static.aiquickdraw.com/elevenlabs/voice/<ID>.mp3
|
|
2
|
+
VOICES = {"James": "EkK5I93UQWFDigLMpZcX", "Arabella": "Z3R5wn05IrDiVCyEkUrK", "Bradford": "NNl6r8mD7vthiJatiJt1", "Xavier": "YOq2y2Up4RgXP2HyXjE5", "Kuon": "B8gJV1IhpuegLxdpXFOE", "Monika Sogam": "2zRM7PkgwBPiau2jvVXc", "Mark": "1SM7GgM6IMuvQlz2BwM3", "Adeline": "5l5f8iK3YPeGga21rQIX", "Sam": "scOwDtmlUjD3prqpp97I", "Spuds Oxley": "NOpBlnGInO9m6vDvFkFC", "Eve": "BZgkqPqms7Kj9ulSkVzn", "Northern Terry": "wo6udizrrtpIxWGp2qJk", "British Football Announcer": "gU0LNdkMOQCOrPrwtbee", "Brock": "DGzg6RaUqxGRTHSBjfgF", "Nathan": "x70vRnQBMBu4FAYhjJbO", "Anika": "Sm1seazb4gs7RSlUVw7c", "Viraj": "P1bg08DkjqiVEzOn76yG", "Taksh": "qDuRKMlYmrm8trt5QyBn", "Horatius": "qXpMhyvQqiRxWQs4qSSB", "Liam": "TX3LPaxmHKxFdv7VOQHJ", "Callum": "N2lVS1w4EtoT3dr4eOWO", "Laura": "FGY2WhTYpPnrIDTdsKH5", "Brittney": "kPzsL2i3teMYv0FxEYQ6", "Mark 2": "UgBBYS2sOqTuMpoF3BR0", "Bella": "hpp4J3VqNfWAUOO0d1Us", "Brian": "nPczCjzI2devNBz1zQrb", "Hope": "uYXf8XasLslADfZ2MB4u", "Jeff": "gs0tAILXbY5DNrJrsM6F", "Jamahal": "DTKMou8ccj1ZaWGBiotd", "Finn": "vBKc2FfBKJfcZNyEt1n6", "Tom": "DYkrAHD8iwork3YSUBbs", "Cassidy": "56AoDkrOh6qfVPDXZ7Pt", "Addison 2.0": "eR40ATw9ArzDf9h3v7t7", "Jessica Anne Bogart": "g6xIsTj2HwM6VR4iXFCw", "Lucy": "lcMyyd2HUfFzxdCaC4Ta", "Tiffany": "6aDn1KB0hjpdcocrUkmq", "Felix": "Sq93GQT4X1lKDXsQcixO", "Jessica Anne Bogart Villain": "flHkNRp1BlvT73UL6gyz", "Lutz": "9yzdeviXkFddZ4Oz8Mok", "Emma": "pPdl9cQBQq4p6mRkZy2Z", "Edward": "zYcjlYFOd3taleS0gkk3", "Marshal": "nzeAacJi50IvxcyDnMXa", "John Morgan": "ruirxsoakN0GWmGNIo04", "Aria": "TC0Zp7WVFzhA8zpTlRqV", "Viking Bjorn": "ljo9gAlSqKOvF6D8sOsX", "Pirate Marshal": "PPzYpIqttlTYA83688JI", "Johnny Kid": "8JVbfL6oEdmuxKn5DK2C", "Hope 2": "iCrDUkL56s3C8sCRl7wb", "Ana Rita": "wJqPPQ618aTW29mptyoc", "John Doe": "EiNlNiXeDU1pqqOPrYMO", "Burt Reynolds": "4YYIPFl9wE5c4L2eu2Gb", "Hank": "6F5Zhi321D3Oq7v1oNT4", "Wyatt": "YXpFCvM1S3JbWEJhoskW", "Phil": "LG95yZDEHg6fCZdQjLqj", "Johnny Dynamite": "CeNX9CMwmxDxUF5Q2Inm", "Rachel M": "aD6riP1btT197c6dACmy", "Rex Thunder": "mtrellq69YZsNwzUSyXh", "Ed": "dHd5gvgSOzSfduK4CvEg", "Jean": "eVItLK1UvXctxuaRV2Oq", "Britney": "esy0r39YPLQjOczyOib8", "Sven": "Tsns2HvNFKfGiNjllgqo", "Viraj 2": "1U02n4nD6AdIZ9CjF053", "Nathaniel": "AeRdCCKzvd23BpJoofzx", "Benjamin": "LruHrtVF6PSyGItzMNHS", "Allison": "1wGbFxmAM3Fgw63G1zZJ", "Theodore HQ": "hqfrgApggtO1785R4Fsn", "Leon": "MJ0RnG71ty4LH3dvNfSd"}
|