Skip to content

Commit 8548eeb

Browse files
committed
feature:删除已经合并了的音频文件。
1 parent c76ab0a commit 8548eeb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/com/xiaozhi/utils/AudioUtils.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ public static void mergeAudioFiles(Path path, List<String> audioPaths) {
184184
byte[] pcmData = readAsPcm(fullPath);
185185
totalPcmSize += pcmData.length;
186186
audioChunks.add(pcmData);
187+
187188
}
188189

189190
// 创建输出WAV文件
@@ -217,11 +218,14 @@ public static void mergeAudioFiles(Path path, List<String> audioPaths) {
217218
dos.write(pcmData);
218219
}
219220
}
221+
// 目前采用的处理策略是删除已经合并了的文件。
222+
for (var audioPath : audioPaths) {
223+
var fullPath = audioPath.startsWith(AUDIO_PATH) ? audioPath : AUDIO_PATH + audioPath;
224+
Files.deleteIfExists(Paths.get(fullPath));
225+
}
220226

221-
// return outputFileName;
222227
} catch (Exception e) {
223228
logger.error("合并音频文件时发生错误", e);
224-
225229
}
226230
}
227231

0 commit comments

Comments
 (0)