add audio files

This commit is contained in:
2021-11-02 14:46:59 +01:00
parent 1cb91892cc
commit 94477dff2c
1803 changed files with 41 additions and 0 deletions

21
oxford_api/get_audio Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
for file in json/*.json
do
echo "file:$file"
no="$(echo "$file" | cut -d'_' -f1 | sed 's|json/||')"
word="$(echo "$file" | cut -d'_' --complement -f1 | sed 's/\.json$//')"
links="$(jq -r '.results[].lexicalEntries[].entries[].pronunciations[] | .audioFile' "$file" | awk '!seen[$0]++')"
if [ -z "$links" ]; then
echo "ERROR: no links for $word found!"
continue
fi
i=1
echo "$links" | while read -r link; do
ext="$(echo "$link" | awk -F'.' '{print $NF}')"
dl_loc=audio/"$no"_"$word"_$i."$ext"
curl -L -s "$link" -o "$dl_loc"
echo "downloaded $word to $dl_loc"
i=$((i+1))
done
done