mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
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
This commit is contained in:
@@ -628,6 +628,9 @@ npx hyperframes media-use resolve --type bgm --reuse 06e052c0
|
||||
# Bring in a file you already have
|
||||
npx hyperframes media-use resolve --type image --from ./photo.jpg
|
||||
|
||||
# The voice clones on the account that makes the film
|
||||
npx hyperframes media-use voices
|
||||
|
||||
# Check the setup, and see what has been used
|
||||
npx hyperframes media-use doctor
|
||||
npx hyperframes media-use stats --days 7
|
||||
@@ -644,6 +647,7 @@ file yourself.
|
||||
| `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` |
|
||||
| `adopt` | Record the files already in `assets/` so later requests find them, with duration and size read by `ffprobe` |
|
||||
| `analyze` | Measure an image or video and print suggested exposure and color corrections, saving nothing. Needs `--type grade --for <file>` |
|
||||
| `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 |
|
||||
| `doctor` | Check ffmpeg, ffprobe, Node.js, the bundled sound library, and the `heygen` CLI (installed, v0.3.0 or newer, signed in). Changes nothing |
|
||||
| `stats` | Count requests, misses, and reuse from the project's `.media/` and the global `~/.media/` |
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ export function createMediaUseCommand(invoke: InvokeMediaUse = invokeEngine) {
|
||||
const subCommands = {
|
||||
...Object.fromEntries(MEDIA_USE_VERBS.map((name) => [name, () => subcommand(name, invoke)])),
|
||||
generate: () => import("./media-use/generate.js").then((m) => m.default),
|
||||
voices: () => import("./media-use/voices.js").then((m) => m.default),
|
||||
};
|
||||
return defineCommand({
|
||||
meta: { name: "media-use", description: "Resolve and operate on project media" },
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { defineCommand } from "../../utils/defineCommand.js";
|
||||
import type { Example } from "../_examples.js";
|
||||
import { jsonArg, num, runMeasure } from "../../measure/command.js";
|
||||
import { ownVoices } from "../../heygen/v3.js";
|
||||
|
||||
export const examples: Example[] = [
|
||||
["The voice clones the film's own account can speak with", "hyperframes media-use voices"],
|
||||
];
|
||||
|
||||
export default defineCommand({
|
||||
meta: {
|
||||
name: "voices",
|
||||
description:
|
||||
"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",
|
||||
},
|
||||
args: {
|
||||
limit: { type: "string", description: "How many to list (default 20)" },
|
||||
json: jsonArg,
|
||||
},
|
||||
async run({ args }) {
|
||||
await runMeasure(async () => ({
|
||||
voices: await ownVoices(num(args.limit, "--limit", 20)),
|
||||
}));
|
||||
},
|
||||
});
|
||||
@@ -1069,7 +1069,7 @@ describe("pickVoice", () => {
|
||||
);
|
||||
await expect(pickVoice({ type: "voice", out: "vo.mp3" })).rejects.toMatchObject({
|
||||
message: "HeyGen 401 listing its voices",
|
||||
fix: "run the same command again",
|
||||
fix: "npx hyperframes auth login",
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ vi.mock("../cloud/auth.js", () => ({
|
||||
resolveCloudBaseUrl: () => "https://api.test",
|
||||
}));
|
||||
|
||||
const { idempotencyKey, runJob } = await import("./v3.js");
|
||||
const { idempotencyKey, ownVoices, runJob } = await import("./v3.js");
|
||||
|
||||
/** A job route through the generated client: the create and the status GET it polls. */
|
||||
const X: JobRoute = {
|
||||
@@ -428,3 +428,29 @@ describe("runJob", () => {
|
||||
expect(idempotencyKey("/v3/x", ["a"])).not.toBe(idempotencyKey("/v3/y", ["a"]));
|
||||
});
|
||||
});
|
||||
|
||||
describe("ownVoices", () => {
|
||||
it("lists the clones of the HyperFrames sign-in's workspace only, never another account's", async () => {
|
||||
const asked: { url: string; key: string | null }[] = [];
|
||||
const clonesByKey: Record<string, string> = {
|
||||
k: "film-account-clone",
|
||||
"heygen-cli-login": "other-account-clone",
|
||||
};
|
||||
vi.stubGlobal("fetch", async (url: string, init: RequestInit) => {
|
||||
const key = new Headers(init.headers).get("x-api-key");
|
||||
asked.push({ url, key });
|
||||
return reply(200, { data: [{ voice_id: "v1", name: clonesByKey[key ?? ""] }] });
|
||||
});
|
||||
expect(await ownVoices(5)).toEqual([
|
||||
{ voice_id: "v1", name: "film-account-clone", language: undefined, gender: undefined },
|
||||
]);
|
||||
expect(asked).toHaveLength(1);
|
||||
expect(new URL(asked[0]!.url).searchParams.get("type")).toBe("private");
|
||||
expect(asked[0]!.key).toBe("k");
|
||||
});
|
||||
|
||||
it("refuses with the sign-in fix when the HyperFrames account cannot be reached, instead of listing anything", async () => {
|
||||
vi.stubGlobal("fetch", async () => reply(401, { message: "no" }));
|
||||
await expect(ownVoices(5)).rejects.toMatchObject({ fix: "npx hyperframes auth login" });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -277,14 +277,18 @@ export interface Voice {
|
||||
const isVoice = (v: unknown): v is Voice =>
|
||||
isRecord(v) && typeof v.voice_id === "string" && typeof v.name === "string";
|
||||
|
||||
/** HeyGen's public voices for a language, best first; a language it does not know gets multilingual ones. */
|
||||
export async function publicVoices(language: string, limit: number): Promise<Voice[]> {
|
||||
async function listVoices(query: { type: "public" | "private"; language?: string }, limit: number) {
|
||||
const client = clientFor(await resolveCloudAuthHeaders().catch(noSignIn));
|
||||
const value = await client
|
||||
.listVoicesV3({ type: "public", language, limit, signal: AbortSignal.timeout(30_000) })
|
||||
.listVoicesV3({ ...query, limit, signal: AbortSignal.timeout(30_000) })
|
||||
.catch((err: unknown) => {
|
||||
if (err instanceof HyperframesApiError)
|
||||
throw new Fix(`HeyGen ${err.status} listing its voices`, "run the same command again");
|
||||
throw new Fix(
|
||||
`HeyGen ${err.status} listing its voices`,
|
||||
err.status === 401 || err.status === 403
|
||||
? "npx hyperframes auth login"
|
||||
: "run the same command again",
|
||||
);
|
||||
throw new Fix(
|
||||
`no answer from HeyGen for its voices (${err instanceof Error ? err.message : String(err)})`,
|
||||
"run the same command again",
|
||||
@@ -297,6 +301,13 @@ export async function publicVoices(language: string, limit: number): Promise<Voi
|
||||
.map(({ voice_id, name, language, gender }) => ({ voice_id, name, language, gender }));
|
||||
}
|
||||
|
||||
/** HeyGen's public voices for a language, best first; a language it does not know gets multilingual ones. */
|
||||
export const publicVoices = (language: string, limit: number): Promise<Voice[]> =>
|
||||
listVoices({ type: "public", language }, limit);
|
||||
|
||||
export const ownVoices = (limit: number): Promise<Voice[]> =>
|
||||
listVoices({ type: "private" }, limit);
|
||||
|
||||
/** Who a paid job bills: the same scope a job's failures and keys belong to. */
|
||||
export async function senderScope(): Promise<string | null> {
|
||||
return (await jobSender()).scope;
|
||||
|
||||
@@ -77,3 +77,12 @@ test("flags a path the skill does not ship, and skips placeholders", () => {
|
||||
const content = "`references/a.md`, `references/b.md`, `references/routes/<workflow>.md`";
|
||||
assert.deepEqual(missingPaths(content, dir), ["references/b.md"]);
|
||||
});
|
||||
|
||||
test("style-sampling picks a voice from the HyperFrames account, never the separate heygen sign-in", () => {
|
||||
const remix = readFileSync(
|
||||
new URL("../skills/style-sampling/references/remix.md", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(remix, /`npx hyperframes media-use voices`/);
|
||||
assert.doesNotMatch(remix.replace(/never `heygen voice list`/, ""), /heygen voice list/);
|
||||
});
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"files": 2
|
||||
},
|
||||
"style-sampling": {
|
||||
"hash": "2c7a5d72f475437c",
|
||||
"hash": "33f02d97fdf789c0",
|
||||
"files": 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ The person's message carries what it carries. Ask once, together, only what is s
|
||||
|
||||
- **Never the creator's face, voice, footage, wordmark or show name.**
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- 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`.
|
||||
|
||||
Reference in New Issue
Block a user