Skip to content

Commit 19be35a

Browse files
fix(cli): the voice a film uses is listed from the HyperFrames account, never the heygen sign-in (#7144)
* fix(cli): the voice a film uses is listed from the HyperFrames account, never the heygen sign-in * fix(cli): drop a comment line and an unenforced range from the voices command
1 parent 183614b commit 19be35a

9 files changed

Lines changed: 84 additions & 8 deletions

File tree

‎docs/packages/cli.mdx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@ npx hyperframes media-use resolve --type bgm --reuse 06e052c0
628628
# Bring in a file you already have
629629
npx hyperframes media-use resolve --type image --from ./photo.jpg
630630

631+
# The voice clones on the account that makes the film
632+
npx hyperframes media-use voices
633+
631634
# Check the setup, and see what has been used
632635
npx hyperframes media-use doctor
633636
npx hyperframes media-use stats --days 7
@@ -644,6 +647,7 @@ file yourself.
644647
| `candidates` | List assets already in the project and the global cache for `--type`, best match for `--intent` first. Downloads nothing and changes nothing. Same as `resolve --candidates` |
645648
| `adopt` | Record the files already in `assets/` so later requests find them, with duration and size read by `ffprobe` |
646649
| `analyze` | Measure an image or video and print suggested exposure and color corrections, saving nothing. Needs `--type grade --for <file>` |
650+
| `voices` | List the voice clones on the HyperFrames account you are signed in with, for `--voice` in `generate`. Never lists the separate `heygen` CLI's account |
647651
| `doctor` | Check ffmpeg, ffprobe, Node.js, the bundled sound library, and the `heygen` CLI (installed, v0.3.0 or newer, signed in). Changes nothing |
648652
| `stats` | Count requests, misses, and reuse from the project's `.media/` and the global `~/.media/` |
649653

‎packages/cli/src/commands/media-use.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export function createMediaUseCommand(invoke: InvokeMediaUse = invokeEngine) {
103103
const subCommands = {
104104
...Object.fromEntries(MEDIA_USE_VERBS.map((name) => [name, () => subcommand(name, invoke)])),
105105
generate: () => import("./media-use/generate.js").then((m) => m.default),
106+
voices: () => import("./media-use/voices.js").then((m) => m.default),
106107
};
107108
return defineCommand({
108109
meta: { name: "media-use", description: "Resolve and operate on project media" },
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { defineCommand } from "../../utils/defineCommand.js";
2+
import type { Example } from "../_examples.js";
3+
import { jsonArg, num, runMeasure } from "../../measure/command.js";
4+
import { ownVoices } from "../../heygen/v3.js";
5+
6+
export const examples: Example[] = [
7+
["The voice clones the film's own account can speak with", "hyperframes media-use voices"],
8+
];
9+
10+
export default defineCommand({
11+
meta: {
12+
name: "voices",
13+
description:
14+
"List the voice clones on the HyperFrames account that makes the film. Never use `heygen voice list` for this: that is a separate sign-in and can be another account",
15+
},
16+
args: {
17+
limit: { type: "string", description: "How many to list (default 20)" },
18+
json: jsonArg,
19+
},
20+
async run({ args }) {
21+
await runMeasure(async () => ({
22+
voices: await ownVoices(num(args.limit, "--limit", 20)),
23+
}));
24+
},
25+
});

‎packages/cli/src/heygen/generate.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ describe("pickVoice", () => {
10691069
);
10701070
await expect(pickVoice({ type: "voice", out: "vo.mp3" })).rejects.toMatchObject({
10711071
message: "HeyGen 401 listing its voices",
1072-
fix: "run the same command again",
1072+
fix: "npx hyperframes auth login",
10731073
});
10741074
});
10751075

‎packages/cli/src/heygen/v3.test.ts‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ vi.mock("../cloud/auth.js", () => ({
1414
resolveCloudBaseUrl: () => "https://api.test",
1515
}));
1616

17-
const { idempotencyKey, runJob } = await import("./v3.js");
17+
const { idempotencyKey, ownVoices, runJob } = await import("./v3.js");
1818

1919
/** A job route through the generated client: the create and the status GET it polls. */
2020
const X: JobRoute = {
@@ -428,3 +428,29 @@ describe("runJob", () => {
428428
expect(idempotencyKey("/v3/x", ["a"])).not.toBe(idempotencyKey("/v3/y", ["a"]));
429429
});
430430
});
431+
432+
describe("ownVoices", () => {
433+
it("lists the clones of the HyperFrames sign-in's workspace only, never another account's", async () => {
434+
const asked: { url: string; key: string | null }[] = [];
435+
const clonesByKey: Record<string, string> = {
436+
k: "film-account-clone",
437+
"heygen-cli-login": "other-account-clone",
438+
};
439+
vi.stubGlobal("fetch", async (url: string, init: RequestInit) => {
440+
const key = new Headers(init.headers).get("x-api-key");
441+
asked.push({ url, key });
442+
return reply(200, { data: [{ voice_id: "v1", name: clonesByKey[key ?? ""] }] });
443+
});
444+
expect(await ownVoices(5)).toEqual([
445+
{ voice_id: "v1", name: "film-account-clone", language: undefined, gender: undefined },
446+
]);
447+
expect(asked).toHaveLength(1);
448+
expect(new URL(asked[0]!.url).searchParams.get("type")).toBe("private");
449+
expect(asked[0]!.key).toBe("k");
450+
});
451+
452+
it("refuses with the sign-in fix when the HyperFrames account cannot be reached, instead of listing anything", async () => {
453+
vi.stubGlobal("fetch", async () => reply(401, { message: "no" }));
454+
await expect(ownVoices(5)).rejects.toMatchObject({ fix: "npx hyperframes auth login" });
455+
});
456+
});

‎packages/cli/src/heygen/v3.ts‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,14 +277,18 @@ export interface Voice {
277277
const isVoice = (v: unknown): v is Voice =>
278278
isRecord(v) && typeof v.voice_id === "string" && typeof v.name === "string";
279279

280-
/** HeyGen's public voices for a language, best first; a language it does not know gets multilingual ones. */
281-
export async function publicVoices(language: string, limit: number): Promise<Voice[]> {
280+
async function listVoices(query: { type: "public" | "private"; language?: string }, limit: number) {
282281
const client = clientFor(await resolveCloudAuthHeaders().catch(noSignIn));
283282
const value = await client
284-
.listVoicesV3({ type: "public", language, limit, signal: AbortSignal.timeout(30_000) })
283+
.listVoicesV3({ ...query, limit, signal: AbortSignal.timeout(30_000) })
285284
.catch((err: unknown) => {
286285
if (err instanceof HyperframesApiError)
287-
throw new Fix(`HeyGen ${err.status} listing its voices`, "run the same command again");
286+
throw new Fix(
287+
`HeyGen ${err.status} listing its voices`,
288+
err.status === 401 || err.status === 403
289+
? "npx hyperframes auth login"
290+
: "run the same command again",
291+
);
288292
throw new Fix(
289293
`no answer from HeyGen for its voices (${err instanceof Error ? err.message : String(err)})`,
290294
"run the same command again",
@@ -297,6 +301,13 @@ export async function publicVoices(language: string, limit: number): Promise<Voi
297301
.map(({ voice_id, name, language, gender }) => ({ voice_id, name, language, gender }));
298302
}
299303

304+
/** HeyGen's public voices for a language, best first; a language it does not know gets multilingual ones. */
305+
export const publicVoices = (language: string, limit: number): Promise<Voice[]> =>
306+
listVoices({ type: "public", language }, limit);
307+
308+
export const ownVoices = (limit: number): Promise<Voice[]> =>
309+
listVoices({ type: "private" }, limit);
310+
300311
/** Who a paid job bills: the same scope a job's failures and keys belong to. */
301312
export async function senderScope(): Promise<string | null> {
302313
return (await jobSender()).scope;

‎scripts/check-core-skills.test.mjs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,12 @@ test("flags a path the skill does not ship, and skips placeholders", () => {
7777
const content = "`references/a.md`, `references/b.md`, `references/routes/<workflow>.md`";
7878
assert.deepEqual(missingPaths(content, dir), ["references/b.md"]);
7979
});
80+
81+
test("style-sampling picks a voice from the HyperFrames account, never the separate heygen sign-in", () => {
82+
const remix = readFileSync(
83+
new URL("../skills/style-sampling/references/remix.md", import.meta.url),
84+
"utf8",
85+
);
86+
assert.match(remix, /`npx hyperframes media-use voices`/);
87+
assert.doesNotMatch(remix.replace(/never `heygen voice list`/, ""), /heygen voice list/);
88+
});

‎skills-manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"files": 2
3535
},
3636
"style-sampling": {
37-
"hash": "2c7a5d72f475437c",
37+
"hash": "33f02d97fdf789c0",
3838
"files": 2
3939
}
4040
}

‎skills/style-sampling/references/remix.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The person's message carries what it carries. Ask once, together, only what is s
2323

2424
- **Never the creator's face, voice, footage, wordmark or show name.**
2525
- **A presenter runs on the plan.** Their own HeyGen avatar if they have one, otherwise Avatar IV from their photo, both through `npx hyperframes media-use generate --type avatar` with the finished voice, so the lips land on it. HeyGen Video 1 is the fallback when neither works.
26-
- **Settle the voice before any research.** A HeyGen voice id the person gave is the voice: use it and ask nothing. Anything else: with `heygen` signed in, look in `heygen voice list`. One clone: use it. Several: ask which. None, or no `heygen`: ask once for their voice id, a clone they make in HeyGen from 30 s to 3 min of their own reading, or their own recorded narration; with none of these, say in one line that you'll use a HeyGen stock voice (`npx hyperframes media-use resolve --type voice`), name it in the credits as AI-generated, and go on. Nothing else starts until this is settled.
26+
- **Settle the voice before any research.** A HeyGen voice id the person gave is the voice: use it and ask nothing. Anything else: run `npx hyperframes media-use voices`, which lists the clones on the HyperFrames account making the film; never `heygen voice list`, a separate sign-in that can be another account. One clone: use it. Several: ask which. None, or not signed in: ask once for their voice id, a clone they make in HeyGen from 30 s to 3 min of their own reading, or their own recorded narration; with none of these, say in one line that you'll use a HeyGen stock voice (`npx hyperframes media-use resolve --type voice`), name it in the credits as AI-generated, and go on. Nothing else starts until this is settled.
2727
- **Then say what's coming** in one short message that is not a question, and go on without waiting: the working title and hook, the length, and roughly how long it takes. No prices.
2828
- **The length is the person's, and it beats the template's runtime.** Offer about 1 minute first: the cold open, the title beat and one chapter, the end card short. 2 to 4 minutes: REMIX.md's short cut. A full episode: the series' own runtime. Their own words ("90 seconds", "5 min"): that length. No length answered and none in the topic: about 1 minute, and offer the longer cut in the reply. Scale everything to it: script words (the template's script stats at that runtime), facts, sections, music cues, review rounds (one for a minute, two for a full episode); never pad or trim to reach the series' runtime instead.
2929
- Everything else REMIX.md §0 asks (chapters, language) takes REMIX.md's default; write each one, and the length, with why, in the project's `CLAUDE.md`.

0 commit comments

Comments
 (0)