From c20a0793f0962fb5eb7c32f77c7f7223ad25163a Mon Sep 17 00:00:00 2001 From: "284991289@qq.com" <284991289@qq.com> Date: Mon, 8 Jul 2024 20:36:29 +0800 Subject: [PATCH 1/2] fix: resolve "data" callback audio incorrect issue --- packages/_common/src/real-time-vad.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/_common/src/real-time-vad.ts b/packages/_common/src/real-time-vad.ts index c8ab3d3..0e663d1 100644 --- a/packages/_common/src/real-time-vad.ts +++ b/packages/_common/src/real-time-vad.ts @@ -147,7 +147,7 @@ export class RealTimeVAD extends EventEmitter { } else if (this.inputType === "buffer") { const buffer = Buffer.alloc(audio.length * 2) for (let i = 0; i < audio.length; i++) { - buffer.writeInt16LE(Math.floor(audio[i] ?? 0 * 32767), i * 2) + buffer.writeInt16LE(Math.floor(audio[i] * 32767), i * 2) } return buffer } From 7a0e6fe2176765c372a75315a708392f46f863d4 Mon Sep 17 00:00:00 2001 From: "284991289@qq.com" <284991289@qq.com> Date: Mon, 8 Jul 2024 20:50:18 +0800 Subject: [PATCH 2/2] fix: resolve "data" callback audio incorrect issue --- packages/_common/src/real-time-vad.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/_common/src/real-time-vad.ts b/packages/_common/src/real-time-vad.ts index 0e663d1..df4e6f3 100644 --- a/packages/_common/src/real-time-vad.ts +++ b/packages/_common/src/real-time-vad.ts @@ -147,7 +147,7 @@ export class RealTimeVAD extends EventEmitter { } else if (this.inputType === "buffer") { const buffer = Buffer.alloc(audio.length * 2) for (let i = 0; i < audio.length; i++) { - buffer.writeInt16LE(Math.floor(audio[i] * 32767), i * 2) + buffer.writeInt16LE(Math.floor((audio[i] ?? 0) * 32767), i * 2) } return buffer }