update add asr config

This commit is contained in:
2025-12-29 01:53:07 +08:00
parent 9f580a7709
commit f1f2d81201
2 changed files with 20 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ import { QwenAsrRelatime } from "@kevisual/video-tools/src/asr/index.ts";
import { Listener, WebSocketListenerFun, WebSocketReq } from "@kevisual/router";
import { lightHA } from "@/routes/ha-api/ha.ts";
import { assistantConfig } from "@/app.ts";
const func: WebSocketListenerFun = async (req: WebSocketReq<{ asr: QwenAsrRelatime, msgId: string, startTime?: number }>, res) => {
const { ws, emitter, id, data } = req;
@@ -13,7 +14,19 @@ const func: WebSocketListenerFun = async (req: WebSocketReq<{ asr: QwenAsrRelati
return;
}
if (!asr) {
const token = process.env.BAILIAN_API_KEY || ''
const confg = assistantConfig.getConfig();
const asrConfig = confg?.asr;
if (!asrConfig?.enabled) {
ws.send(JSON.stringify({ type: 'error', message: 'asr服务未启用' }));
ws.close();
return;
}
const token = asrConfig?.token;
if (!token) {
ws.send(JSON.stringify({ type: 'error', message: 'asr服务未配置token' }));
ws.close();
return;
}
// 第一次请求
asr = new QwenAsrRelatime({
token,