Datasets:
File size: 870 Bytes
e5552aa 9e73582 e5552aa 9e73582 e5552aa 9e73582 e5552aa 9e73582 e5552aa 9e73582 e5552aa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#!/bin/bash
# Set the number of parallel processes
NUM_PROCESSES=16
# Create the wav directory if it doesn't exist
mkdir -p wav
# Function to convert a single file
convert_file() {
local opus_file="$1"
local wav_file=$(echo "$opus_file" | sed 's|opus/|wav/|; s|\.opus$|\.wav|')
# Create the subdirectory in wav/ if it doesn't exist
mkdir -p "$(dirname "$wav_file")"
# Use the line below to keep the original sample rate 48kHz
# ffmpeg -i "$opus_file" "$wav_file" -loglevel error
# Or change the -ar 16000 to other sample rates
ffmpeg -i "$opus_file" -ar 16000 "$wav_file" -loglevel error
echo "Converted: $opus_file -> $wav_file"
}
export -f convert_file
# Find all .opus files and process them in parallel
find opus/ -name "*.opus" -print0 | xargs -0 -P "$NUM_PROCESSES" -I{} bash -c 'convert_file "$@"' _ {}
echo "Conversion complete." |