forked from dunstad/lilypond
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlilyToAnki.sh
executable file
·29 lines (23 loc) · 969 Bytes
/
lilyToAnki.sh
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
#!/bin/bash
tmpFolder=tmp
inputFolder=src
outputFolder=output
# Generate output from lilypond files to be use inside genanki
find ./$inputFolder -name '*.ly' -print0 |
while IFS= read -r -d '' filePath; do
deckName=$(basename "${filePath%/*}")
fileName=$(echo "$(basename "$filePath")" | cut -f 1 -d '.')
# Create temporary folder for given deck (if it doesn't exist)
mkdir -p "$tmpFolder/$deckName"
# Create outputs for every lilypond file inside given deck
lilypond -H titleHtml -H descriptionHtml --png -dpreview -dcrop -o "$tmpFolder/$deckName/" "$filePath"
# Convert midi to ogg
timidity "$tmpFolder/$deckName/$fileName.midi" -Ow -o - | ffmpeg -i - -acodec libmp3lame -ab 128k "$tmpFolder/$deckName/$fileName.mp3"
done
# Create Anki decks
for d in $tmpFolder/*/ ; do
deckName=$(basename "$d")
python3 createAnkiDeck.py "$deckName" "$inputFolder" "$tmpFolder" "$outputFolder"
done
# Clean tmp folder
rm -rf $tmpFolder