feat(etapa2): transcriber sherpa-onnx-offline em Rust

This commit is contained in:
Evandro committed 2026-06-11 03:42:53 -03:00
1 parent c5baf7a23f
commit 695a0d5c42
11 files changed
+1585 -173

No files matched your search

+37 -30
View File
@@ -11,43 +11,50 @@ const repoRoot = join(__dirname, "..");
const SUPPORTED_HOST = "x86_64-pc-windows-msvc";
function detectHostTriple() {
try {
const output = execFileSync("rustc", ["-vV"], { encoding: "utf8" });
const line = output.split("\n").find((l) => l.startsWith("host:"));
return line ? line.replace("host:", "").trim() : null;
} catch {
return null;
}
try {
const output = execFileSync("rustc", ["-vV"], { encoding: "utf8" });
const line = output.split("\n").find((l) => l.startsWith("host:"));
return line ? line.replace("host:", "").trim() : null;
} catch {
return null;
}
}
describe("setup-sidecar", () => {
const hostTriple = detectHostTriple();
const hostTriple = detectHostTriple();
beforeAll(() => {
if (!hostTriple) {
console.warn("rustc não disponível; pulando teste de sidecar");
}
});
beforeAll(() => {
if (!hostTriple) {
console.warn("rustc não disponível; pulando teste de sidecar");
}
});
it("baixa o binário oficial e o coloca em src-tauri/binaries com o target triple", async () => {
if (!hostTriple) return;
if (hostTriple !== SUPPORTED_HOST) {
console.log(`host triple ${hostTriple} fora da matriz de testes; pulando`);
return;
}
it("baixa o binário oficial e o coloca em src-tauri/binaries com o target triple", async () => {
if (!hostTriple) return;
if (hostTriple !== SUPPORTED_HOST) {
console.log(
`host triple ${hostTriple} fora da matriz de testes; pulando`,
);
return;
}
const binaryPath = join(repoRoot, "src-tauri", "binaries", `sherpa-onnx-offline-${hostTriple}.exe`);
const binaryPath = join(
repoRoot,
"src-tauri",
"binaries",
`sherpa-onnx-offline-${hostTriple}.exe`,
);
if (existsSync(binaryPath)) {
rmSync(binaryPath, { force: true });
}
if (existsSync(binaryPath)) {
rmSync(binaryPath, { force: true });
}
execFileSync("node", [join(repoRoot, "scripts", "setup-sidecar.mjs")], {
stdio: "pipe",
env: { ...process.env, SHERPA_ONNX_VERSION: "v1.12.23" },
});
execFileSync("node", [join(repoRoot, "scripts", "setup-sidecar.mjs")], {
stdio: "pipe",
env: { ...process.env, SHERPA_ONNX_VERSION: "v1.12.23" },
});
expect(existsSync(binaryPath)).toBe(true);
expect(statSync(binaryPath).size).toBeGreaterThan(1024 * 1024);
}, 180_000);
expect(existsSync(binaryPath)).toBe(true);
expect(statSync(binaryPath).size).toBeGreaterThan(1024 * 1024);
}, 180_000);
});