mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-07 18:26:17 +00:00
fix(transcribe): select multilingual model before download (#2303)
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
} from "./init.js";
|
||||
|
||||
const cliEntry = resolve(fileURLToPath(import.meta.url), "..", "..", "cli.ts");
|
||||
const initSource = readFileSync(new URL("./init.ts", import.meta.url), "utf-8");
|
||||
const tailwindScript =
|
||||
'<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.2.4/dist/index.global.js" integrity="sha384-v5YF9xS+gLRWdvrQ0u/WRbCkjSIH0NjHIPe8tBL1ZRrmI7PiSH6LLdzs0aAIMCuh" crossorigin="anonymous"></script>';
|
||||
|
||||
@@ -47,6 +48,14 @@ function expectScaffoldedScripts(target: string): void {
|
||||
}
|
||||
|
||||
describe("hyperframes init flag rename", () => {
|
||||
it("selects the language-compatible model before both eager init downloads", () => {
|
||||
expect(initSource).toMatch(
|
||||
/const initialTranscriptionModel = initialModelForLanguage\(\s*modelFlag \?\? DEFAULT_MODEL,\s*languageFlag,?\s*\);/,
|
||||
);
|
||||
expect(initSource.match(/await ensureModel\(initialTranscriptionModel/g)).toHaveLength(2);
|
||||
expect(initSource).not.toMatch(/await ensureModel\(modelFlag/g);
|
||||
});
|
||||
|
||||
it("requires an explicit source in non-interactive mode", () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), "hf-init-test-"));
|
||||
const target = join(dir, "proj");
|
||||
|
||||
@@ -45,7 +45,8 @@ import {
|
||||
} from "../templates/generators.js";
|
||||
import { fetchRemoteTemplate } from "../templates/remote.js";
|
||||
import { trackInitTemplate } from "../telemetry/events.js";
|
||||
import { hasFFmpeg } from "../whisper/manager.js";
|
||||
import { DEFAULT_MODEL, hasFFmpeg } from "../whisper/manager.js";
|
||||
import { initialModelForLanguage } from "../whisper/transcribe.js";
|
||||
import { findFFmpeg, findFFprobe, getFFmpegInstallHint } from "../browser/ffmpeg.js";
|
||||
import { VERSION } from "../version.js";
|
||||
import {
|
||||
@@ -769,6 +770,10 @@ export default defineCommand({
|
||||
const nonInteractive = args["non-interactive"] === true;
|
||||
const modelFlag = args.model;
|
||||
const languageFlag = args.language;
|
||||
const initialTranscriptionModel = initialModelForLanguage(
|
||||
modelFlag ?? DEFAULT_MODEL,
|
||||
languageFlag,
|
||||
);
|
||||
const interactive = !nonInteractive && process.stdout.isTTY === true;
|
||||
|
||||
if (skipSkillsFlagIgnored) {
|
||||
@@ -866,7 +871,7 @@ export default defineCommand({
|
||||
try {
|
||||
const { ensureWhisper, ensureModel } = await import("../whisper/manager.js");
|
||||
await ensureWhisper();
|
||||
await ensureModel(modelFlag);
|
||||
await ensureModel(initialTranscriptionModel);
|
||||
console.log("Transcribing...");
|
||||
const { transcribe: runTranscribe } = await import("../whisper/transcribe.js");
|
||||
const result = await runTranscribe(sourceFilePath, destDir, {
|
||||
@@ -1044,7 +1049,7 @@ export default defineCommand({
|
||||
await ensureWhisper({
|
||||
onProgress: (msg) => spin.message(msg),
|
||||
});
|
||||
await ensureModel(modelFlag, {
|
||||
await ensureModel(initialTranscriptionModel, {
|
||||
onProgress: (msg) => spin.message(msg),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user