simplify speech bootstrap and clean daemon startup locking
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
import { fileURLToPath } from "url";
|
||||
import { existsSync } from "node:fs";
|
||||
import dotenv from "dotenv";
|
||||
import { runSupervisor } from "./supervisor.js";
|
||||
|
||||
dotenv.config({
|
||||
path: fileURLToPath(new URL("../.env", import.meta.url)),
|
||||
quiet: true,
|
||||
});
|
||||
|
||||
const WORKER_ENTRY = fileURLToPath(new URL("../src/server/index.ts", import.meta.url));
|
||||
if (!existsSync(WORKER_ENTRY)) {
|
||||
throw new Error(`Dev worker entry not found: ${WORKER_ENTRY}`);
|
||||
|
||||
@@ -42,5 +42,5 @@ function parseArgs(argv: string[]): { modelsDir: string; modelIds: LocalSpeechMo
|
||||
const logger = createRootLogger({ level: "info", format: "pretty" });
|
||||
|
||||
const { modelsDir, modelIds } = parseArgs(process.argv.slice(2));
|
||||
await ensureLocalSpeechModels({ modelsDir, modelIds, autoDownload: true, logger });
|
||||
await ensureLocalSpeechModels({ modelsDir, modelIds, logger });
|
||||
logger.info({ modelsDir, modelIds }, "Done downloading speech models");
|
||||
|
||||
@@ -284,7 +284,6 @@ logger.info(
|
||||
await ensureLocalSpeechModels({
|
||||
modelsDir: options.modelsDir,
|
||||
modelIds: options.modelIds,
|
||||
autoDownload: true,
|
||||
logger,
|
||||
});
|
||||
|
||||
|
||||
@@ -18,12 +18,11 @@ type CliOptions = {
|
||||
outPath?: string;
|
||||
model: LocalSttModelId;
|
||||
modelsDir: string;
|
||||
autoDownload: boolean;
|
||||
};
|
||||
|
||||
function usage(): string {
|
||||
return [
|
||||
"Usage: npm run speech:transcribe:local -- <wavPath> [--out <outPath>] [--model <modelId>] [--models-dir <dir>] [--no-auto-download]",
|
||||
"Usage: npm run speech:transcribe:local -- <wavPath> [--out <outPath>] [--model <modelId>] [--models-dir <dir>]",
|
||||
"",
|
||||
"Examples:",
|
||||
" npm run speech:transcribe:local -- ./sample.wav",
|
||||
@@ -52,7 +51,6 @@ function parseArgs(argv: string[]): CliOptions {
|
||||
let outPath: string | undefined;
|
||||
let model = LocalSttModelIdSchema.parse(process.env.PASEO_LOCAL_STT_MODEL ?? DEFAULT_LOCAL_STT_MODEL);
|
||||
let modelsDir = defaultModelsDir;
|
||||
let autoDownload = true;
|
||||
|
||||
for (let i = 0; i < argv.length; i++) {
|
||||
const arg = argv[i];
|
||||
@@ -87,11 +85,6 @@ function parseArgs(argv: string[]): CliOptions {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (arg === "--no-auto-download") {
|
||||
autoDownload = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (arg.startsWith("-")) {
|
||||
throw new Error(`Unknown option: ${arg}`);
|
||||
}
|
||||
@@ -108,7 +101,6 @@ function parseArgs(argv: string[]): CliOptions {
|
||||
...(outPath ? { outPath } : {}),
|
||||
model,
|
||||
modelsDir,
|
||||
autoDownload,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -139,7 +131,6 @@ async function main(): Promise<void> {
|
||||
providers,
|
||||
local: {
|
||||
modelsDir: options.modelsDir,
|
||||
autoDownload: options.autoDownload,
|
||||
models: {
|
||||
dictationStt: options.model,
|
||||
voiceStt: options.model,
|
||||
|
||||
Reference in New Issue
Block a user