zoengjyutgaai / to_wav.sh
laubonghaudoi's picture
Initial commit
5b73ede
raw
history blame contribute delete
726 Bytes
#!/bin/bash
# Create the wav directory if it doesn't exist
mkdir -p wav
# Find all .opus files in the opus directory and loop through them
find opus/ -name "*.opus" -print0 | while IFS= read -r -d $'\0' opus_file; do
# Construct the corresponding .wav file path
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")"
# Convert the .opus file to .wav using ffmpeg, preserving original quality
ffmpeg -i "$opus_file" "$wav_file"
# Uncomment the line below to resample to 44100 Hz
# ffmpeg -i "$opus_file" -ar 44100 "$wav_file"
echo "Converted: $opus_file -> $wav_file"
done
echo "Conversion complete."