0

I am writing a bash script that mixes audio files for a Speech Recognition task. Following is the folder structure:

-folder1
    -- file1.wav
    -- file2.wav
    -- file3.wav
-folder2
    -- noise1.wav
    -- noise2.wav
    -- noise3.wav

What my code is doing right now is combining file1.wav with all the .wav files in folder 2. Then file2.wav with all the wav files in folder2. What I want is to combine file1.wav with noise1.wav. Then increment both the loops and combine file2.wav with noise2.wav.

I don't know how to increment the filename variable in the for loop. Following is my code:

#!/bin/sh

number=0 #initialize number

for f1 in selected/*/wav/*; do
    for f2 in backgroundnoise/output/*; do
        sox -m $f1 $f2 output/{$number}.wav
        number=$((number+1))
    done

done
Saad
  • 159
  • 1
  • 2
  • 14
  • You have this error `{$number}`. It must be `${number}` instead. And you don't need to reassign `number` in `number=$((number+1))`. Just do `((++number))` – accdias Dec 31 '19 at 08:29
  • 1
    If your files differs only by a number, and you need to mix your files with corresponding numbers, then all you need to do is to loop over number only. No need to loop over the file names – Zelnes Dec 31 '19 at 08:32

0 Answers0