refactor: UUID

This commit is contained in:
手瓜一十雪
2024-07-24 10:44:55 +08:00
parent 37bd51e138
commit f784363696
5 changed files with 8 additions and 10 deletions

View File

@@ -3,7 +3,7 @@ import { encode, getDuration, getWavFileInfo, isWav, isSilk } from 'silk-wasm';
import fsPromise from 'fs/promises';
import { log, logError } from './log';
import path from 'node:path';
import { v4 as uuidv4 } from 'uuid';
import { randomUUID } from 'crypto';
import { spawn } from 'node:child_process';
import { getTempDir } from '@/common/utils/file';
@@ -64,7 +64,7 @@ export async function encodeSilk(filePath: string) {
try {
const file = await fsPromise.readFile(filePath);
const pttPath = path.join(TEMP_DIR, uuidv4());
const pttPath = path.join(TEMP_DIR, randomUUID());
if (!isSilk(file)) {
log(`语音文件${filePath}需要转换成silk`);
const _isWav = isWav(file);