diff --git a/package.json b/package.json index 4d69e7a..c9ef365 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kevisual/video-tools", - "version": "0.0.7", + "version": "0.0.8", "description": "", "main": "index.js", "basename": "/root/video-tools", diff --git a/src/asr/provider/aliyun/base.ts b/src/asr/provider/aliyun/base.ts index 4bc3d4b..bea108e 100644 --- a/src/asr/provider/aliyun/base.ts +++ b/src/asr/provider/aliyun/base.ts @@ -115,6 +115,14 @@ export class AsrRelatime extends WSServer { console.log('error', error); } } + async onClose(event: CloseEvent) { + let { code } = event; + if (code === 1007) { + // reason: Idle timeout + code = 0; // 超时不重连 + } + super.onClose({ ...event, code }); + } async isEnd(type: string) { const types = ['conversation.item.input_audio_transcription.text', 'conversation.item.input_audio_transcription.completed']; if (type === types[1]) { diff --git a/src/asr/provider/aliyun/test/get-text.ts b/src/asr/provider/aliyun/test/get-text.ts index 17d4fa1..f0194b1 100644 --- a/src/asr/provider/aliyun/test/get-text.ts +++ b/src/asr/provider/aliyun/test/get-text.ts @@ -24,18 +24,19 @@ async function main() { }); ws.emitter.on('close', (event) => { const { code, reason, type } = event || {}; - console.log('Connection closed:', code, reason, type); + console.log('close envent', event); + console.log('Connection closed:', code) if (typeof code === 'number' && code !== 0) { ws.reconnect({ timeout: 1000 }); } }); await ws.start(); - const audioContent = await fs.readFile(videoTestPath); + // const audioContent = await fs.readFile(videoTestPath); - ws.sendBuffer(audioContent); - ws.sendBlank(); - ws.sendBuffer(await fs.readFile(videoTestPath2)); - ws.sendBlank(); + // ws.sendBuffer(audioContent); + // ws.sendBlank(); + // ws.sendBuffer(await fs.readFile(videoTestPath2)); + // ws.sendBlank(); }, });