feat: 将视频转写重构为纯文字异步语音识别
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import "dotenv/config";
|
||||
import { setTimeout as sleep } from "node:timers/promises";
|
||||
import { prisma } from "../lib/prisma";
|
||||
import { workerTick } from "../lib/stt/worker";
|
||||
|
||||
let stopping = false;
|
||||
const controller = new AbortController();
|
||||
for (const signal of ["SIGTERM", "SIGINT"] as const)
|
||||
process.on(signal, () => {
|
||||
stopping = true;
|
||||
controller.abort();
|
||||
});
|
||||
async function main() {
|
||||
console.log("[ASR] 后台执行器已启动,最大并发 2");
|
||||
try {
|
||||
while (!stopping) {
|
||||
try {
|
||||
await workerTick();
|
||||
} catch {
|
||||
console.error("[ASR] 数据库调度失败,稍后重试");
|
||||
}
|
||||
if (!stopping)
|
||||
await sleep(1000, undefined, { signal: controller.signal }).catch(
|
||||
() => {},
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
}
|
||||
main().catch(() => {
|
||||
console.error("[ASR] 执行器退出");
|
||||
process.exitCode = 1;
|
||||
});
|
||||
Reference in New Issue
Block a user