Skip to content

Instantly share code, notes, and snippets.

@yuygfgg
Last active March 10, 2025 10:01
Show Gist options
  • Save yuygfgg/55973093c548b61b9f34caf1a21f82ef to your computer and use it in GitHub Desktop.
Save yuygfgg/55973093c548b61b9f34caf1a21f82ef to your computer and use it in GitHub Desktop.
asmr_one_organize_command.sh
# export COVER=/path/to/cover
# organizes wav + vtt to flac(embedded lrc & cover) + lrc
for wav in *.wav; do [ -f "$wav" ] && ffmpeg -i "$wav" -compression_level 12 "${wav%.wav}.flac" -y && rm "$wav"; done && for vtt in *.vtt; do [ -f "$vtt" ] && lrc="${vtt%.vtt}.lrc" && echo -e "[ti:]\n[ar:]\n[al:]\n[by:]\n[00:00.00]" > "$lrc" && grep -n "^[0-9][0-9]:[0-9][0-9]:[0-9][0-9]" "$vtt" | while IFS=: read -r ln line; do start=$(echo "$line" | awk '{print $1}') && h=$(echo "$start" | cut -d: -f1) && m=$(echo "$start" | cut -d: -f2) && s=$(echo "$start" | cut -d: -f3 | cut -d. -f1) && ms=$(echo "$start" | cut -d: -f3 | cut -d. -f2 | cut -c1-2) && tm=$((10#$h*60+10#$m)) && txt=$(sed -n "$((ln+1))p" "$vtt") && printf "[%02d:%02d.%s]%s\n" "$tm" "$s" "$ms" "$txt" >> "$lrc"; done && rm "$vtt"; done && for flac in *.flac; do [ -f "$flac" ] && metaflac --import-picture-from="$COVER" "$flac" && lrc="${flac%.flac}.lrc" && [ -f "$lrc" ] && metaflac --set-tag="LYRICS=$(cat "$lrc" | tr '\n' '|' | sed 's/|/\\n/g')" "$flac"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment