Skip to content

Instantly share code, notes, and snippets.

@seungwonpark
Created May 26, 2019 22:52
Show Gist options
  • Save seungwonpark/4f273739beef2691cd53b5c39629d830 to your computer and use it in GitHub Desktop.
Save seungwonpark/4f273739beef2691cd53b5c39629d830 to your computer and use it in GitHub Desktop.
VoxCeleb2 m4a to wav converter
# copy this to root directory of data and
# chmod a+x convert.sh
# ./convert.sh
# https://unix.stackexchange.com/questions/103920/parallelize-a-bash-for-loop
open_sem(){
mkfifo pipe-$$
exec 3<>pipe-$$
rm pipe-$$
local i=$1
for((;i>0;i--)); do
printf %s 000 >&3
done
}
run_with_lock(){
local x
read -u 3 -n 3 x && ((0==x)) || exit $x
(
( "$@"; )
printf '%.3d' $? >&3
)&
}
N=32 # number of vCPU
open_sem $N
for f in $(find . -name "*.m4a"); do
run_with_lock ffmpeg -loglevel panic -i "$f" -ar 16000 "${f%.*}.wav"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment