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

最后都变了- 提交于 2020-01-05 14:03:13

问题


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:

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

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

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.


回答1:


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.



来源:https://stackoverflow.com/questions/54237865/how-does-a-shell-script-read-the-data-in-a-batch-test-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!