diff --git a/src/common/audio.ts b/src/common/audio.ts index 92b22365..9f91eb2a 100644 --- a/src/common/audio.ts +++ b/src/common/audio.ts @@ -47,6 +47,7 @@ export async function encodeSilk(filePath: string, TEMP_DIR: string, logger: Log ? (await handleWavFile(file, filePath, pcmPath)) : { input: await FFmpegService.convert(filePath, pcmPath), sampleRate: 24000 }; const silk = await piscina.run({ input: input, sampleRate: sampleRate }); + fsPromise.unlink(pcmPath).catch((e) => logger.logError('删除临时文件失败', pcmPath, e)); await fsPromise.writeFile(pttPath, Buffer.from(silk.data)); logger.log(`语音文件${filePath}转换成功!`, pttPath, '时长:', silk.duration); return { diff --git a/src/core/apis/file.ts b/src/core/apis/file.ts index 81afbfb0..0f56c514 100644 --- a/src/core/apis/file.ts +++ b/src/core/apis/file.ts @@ -214,8 +214,7 @@ export class NTQQFileApi { throw new Error('文件异常,大小为0'); } if (converted) { - fsPromises.unlink(silkPath).then().catch((e) => this.context.logger.logError('删除临时文件失败', e) - ); + fsPromises.unlink(silkPath).then().catch((e) => this.context.logger.logError('删除临时文件失败', e)); } return { elementType: ElementType.PTT,