#!/usr/bin/env bash
# fetch_sets.sh [dir]: the open test sets, into dir (default ~/.cache/cotton-voice/downloads-sets);
# then prepare_sets.py
lays them out for pnpm voice:measure.
# FLEURS test (google/fleurs, CC-BY-4.0), EdAcc test (edinburghcstr/edacc, CC-BY-SA-4.0),
# CS-FLEURS read test Telugu/Hindi-English (byan/cs-fleurs, CC-BY-NC-4.0: measuring only),
# MUCS 2021 Hindi-English test (OpenSLR 104).
set -u
D="${1:-$HOME/.cache/cotton-voice/downloads-sets}"
mkdir -p "$D/fleurs" "$D/edacc"
cd "$D/fleurs"
for l in en_us te_in hi_in ja_jp es_419 fr_fr de_de ta_in kn_in ml_in bn_in mr_in gu_in ur_pk pa_in it_it pt_br; do
mkdir -p $l; cd $l
[ -f test.tsv ] || curl -sSLf -o test.tsv https://huggingface.co/datasets/google/fleurs/resolve/main/data/$l/test.tsv
[ -d test ] || { curl -sSLf https://huggingface.co/datasets/google/fleurs/resolve/main/data/$l/audio/test.tar.gz | tar xz; }
echo "fleurs $l $(ls test 2>/dev/null | wc -l)"; cd ..
done
cd ../edacc
for f in $(curl -s https://huggingface.co/api/datasets/edinburghcstr/edacc/tree/main/data | python3 -c "import json,sys;print(' '.join(x['path'] for x in json.load(sys.stdin) if '/test-' in x['path']))"); do
[ -f $(basename $f) ] || curl -sSLf -o $(basename $f) https://huggingface.co/datasets/edinburghcstr/edacc/resolve/main/$f; echo "edacc $f"
done
echo FETCH-DONE
# CS-FLEURS read test (CC-BY-NC-4.0: measuring only), Telugu-English and Hindi-English.
cd "$D"
mkdir -p csfleurs && cd csfleurs
[ -f metadata.jsonl ] || curl -sSLf -o metadata.jsonl https://huggingface.co/datasets/byan/cs-fleurs/resolve/main/read/test/metadata.jsonl
python3 - <<'PY'
import json, os, subprocess
for l in open('metadata.jsonl'):
r = json.loads(l)
if r['language'] in ('tel-eng', 'hin-eng'):
f = r['file_name']
if not os.path.exists(f):
os.makedirs(os.path.dirname(f), exist_ok=True)
subprocess.run(['curl', '-sSLf', '-o', f, 'https://huggingface.co/datasets/byan/cs-fleurs/resolve/main/read/test/' + f], check=True)
print('csfleurs done')
PY
# MUCS 2021 Hindi-English code-switched test (OpenSLR 104).
cd "$D"
[ -d mucs-hi-en ] || { mkdir -p mucs-hi-en && curl -sSLf https://www.openslr.org/resources/104/Hindi-English_test.tar.gz | tar xz -C mucs-hi-en; }
echo SETS-DONE