Files
TanTan f954252a34
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
Release Tag / validate-version (push) Waiting to run
NapCatQQ source snapshot
2026-11-13 09:01:47 +08:00

17 lines
770 B
TypeScript

import path from 'node:path';
import { randomUUID } from 'crypto';
import { LogWrapper } from '@/napcat-core/helper/log';
import { FFmpegService } from '@/napcat-core/helper/ffmpeg/ffmpeg';
export async function encodeSilk (filePath: string, temporaryDirectory: string, logger: LogWrapper) {
const converted = !(await FFmpegService.isSilk(filePath));
const pttPath = converted ? path.join(temporaryDirectory, randomUUID()) : filePath;
if (converted) {
logger.log(`语音文件${filePath}需要转换成silk`);
await FFmpegService.convertToNTSilkTct(filePath, pttPath);
}
const duration = await FFmpegService.getDuration(pttPath);
logger.log('语音文件已就绪:', pttPath, '时长:', duration);
return { converted, path: pttPath, duration };
}