Search code examples
shelltensorflowspeech

How does a shell script read the data in a batch test folder


I recently replicated a SEGAN experiment based on TensorFlow0.12.1.The author provides a shell script for testing (clean_wav.sh), as shown in the figure below:

enter image description here

This is the original version provided by the author. According to the path of my test data, the modified version is as follows:

enter image description here

Noisy_testset_wav_16k is my test data folder, but running the script system will report an error:

enter image description here

This folder is a directory, but when I change the path to:

NOISY_WAVNAME='/home/zyf/SEGAN/ SEGAN/segan-master1/noisy_testset_wav_16k/p232_023.wav'

the script runs normally and the program function can also be achieved.

However, only one audio file can be processed at a time and cannot be processed in batches.Hope everybody knows reason or have opinion, can give me give advice or two, thank very much.


Solution

  • The code is written in the way it only processes file, you can add a loop in shell script to process all files in the folder:

    for f in $NOISY_WAVDIR/*.wav; do
          python main.py --init_noise_std 0. --save_path segan_v1.1 \
                   --batch_size 100 --g_nl prelu --weights SEGAN-41700 \
                   --preemph 0.95 --bias_deconv True \
                   --bias_downconv True --bias_D_conv True \
                   --test_wav $f --save_clean_path $SAVE_PATH
    done
    

    but that would not be optimal use of the GPU since you do not process audio in batch. Ideally you'd want to modify python code to process audio in batches but that would not be a trivial task.