From d68a39b49eace0366566c7bae0d62819d4f38ae2 Mon Sep 17 00:00:00 2001 From: Alen <33656288+cnxysoft@users.noreply.github.com> Date: Sat, 14 Sep 2024 10:49:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E5=AE=9A=E4=B9=89=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/onebot/api/quick-action.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/onebot/api/quick-action.ts b/src/onebot/api/quick-action.ts index 6ba910fb..6434b26f 100644 --- a/src/onebot/api/quick-action.ts +++ b/src/onebot/api/quick-action.ts @@ -47,7 +47,7 @@ export class OneBotQuickActionApi { const peerContextMode = msg.message_type == 'private' ? ContextMode.Private : ContextMode.Group; const peer: Peer = await createContext(this.core, { - message: "", + message_type: undefined, group_id: msg.group_id?.toString(), user_id: msg.user_id?.toString(), }, peerContextMode); From 15a240006995e67b01c12e5df359863fb442dd18 Mon Sep 17 00:00:00 2001 From: Alen <33656288+cnxysoft@users.noreply.github.com> Date: Sat, 14 Sep 2024 11:12:43 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 此处为重复插入待删列表 --- src/onebot/api/msg.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/onebot/api/msg.ts b/src/onebot/api/msg.ts index 826e1d00..7cfff9d5 100644 --- a/src/onebot/api/msg.ts +++ b/src/onebot/api/msg.ts @@ -466,7 +466,6 @@ export class OneBotMsgApi { sendMsg.data.summary, sendMsg.data.sub_type, ); - context.deleteAfterSentFiles.push(sendPicElement.picElement.sourcePath); return sendPicElement; }, From 401b0e2bd0647b816ee72e416e7d447b347df18e Mon Sep 17 00:00:00 2001 From: Alen <33656288+cnxysoft@users.noreply.github.com> Date: Sat, 14 Sep 2024 17:50:09 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E9=83=A8=E5=88=86=E8=AF=AD=E9=9F=B3?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E9=80=9F=E7=8E=87=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/audio.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/common/audio.ts b/src/common/audio.ts index 4dd82afd..388c0cfd 100644 --- a/src/common/audio.ts +++ b/src/common/audio.ts @@ -40,12 +40,14 @@ async function convert(filePath: string, pcmPath: string, logger: LogWrapper): P }); } -async function handleWavFile(file: Buffer, filePath: string, pcmPath: string, logger: LogWrapper): Promise { +async function handleWavFile( + file: Buffer, filePath: string, pcmPath: string, logger: LogWrapper +): Promise<{input: Buffer, sampleRate: number}> { const { fmt } = getWavFileInfo(file); if (!ALLOW_SAMPLE_RATE.includes(fmt.sampleRate)) { - return await convert(filePath, pcmPath, logger); + return {input: await convert(filePath, pcmPath, logger), sampleRate: 24000}; } - return file; + return {input: file, sampleRate: fmt.sampleRate}; } export async function encodeSilk(filePath: string, TEMP_DIR: string, logger: LogWrapper) { @@ -55,8 +57,10 @@ export async function encodeSilk(filePath: string, TEMP_DIR: string, logger: Log if (!isSilk(file)) { logger.log(`语音文件${filePath}需要转换成silk`); const pcmPath = `${pttPath}.pcm`; - const input = isWav(file) ? await handleWavFile(file, filePath, pcmPath, logger) : await convert(filePath, pcmPath, logger); - const silk = await encode(input, 24000); + const { input, sampleRate } = isWav(file) + ? (await handleWavFile(file, filePath, pcmPath, logger)) + : {input: await convert(filePath, pcmPath, logger), sampleRate: 24000}; + const silk = await encode(input, sampleRate); await fsPromise.writeFile(pttPath, silk.data); logger.log(`语音文件${filePath}转换成功!`, pttPath, '时长:', silk.duration); return {