Skip to content

Commit

Permalink
feat: 音频分离支持更多分支
Browse files Browse the repository at this point in the history
  • Loading branch information
pansong291 committed Oct 31, 2023
1 parent 97cb767 commit 959f25c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions separate-audios/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,13 @@ const commandSupplier = {
*/
ffmpegConcat() {
const cmds = []
const instruments = ['vocals', 'accompaniment']
const originFileName = {}
fs.readdirSync(downloadsDir).forEach(f => {
const order = f.substring(0, f.indexOf('_'))
originFileName[order] = f
})
fs.readdirSync(separatesDir).forEach(order => {
for (const instrument of instruments) {
fs.readdirSync(`${separatesDir}/${order}`).forEach(instrument => {
const instPath = `${separatesDir}/${order}/${instrument}`
const audioFiles = fs.readdirSync(instPath)
const count = audioFiles.length
Expand All @@ -82,7 +81,7 @@ const commandSupplier = {
fs.writeFileSync(filepath, segmentPaths.join('\n'))
const outputName = utils.cmdEscape(`${outputsDir}/${originFileName[order]}_${instrument}.${ext}`)
cmds.push(`ffmpeg -f concat -safe 0 -i ${filepath} -c copy ${outputName}`)
}
})
})
return cmds.join('\n')
},
Expand Down

0 comments on commit 959f25c

Please sign in to comment.