Download code/run_asr_v3.sh from phamhai/lifemate-data: direct link, hf CLI and curl.
- Browser
- Download file 1.91 kB
-
https://huggingface.co/datasets/phamhai/lifemate-data/resolve/main/code/run_asr_v3.sh
- Command line
-
hf download hf://datasets/phamhai/lifemate-data/code/run_asr_v3.sh
-
curl -L -o run_asr_v3.sh https://huggingface.co/datasets/phamhai/lifemate-data/resolve/main/code/run_asr_v3.sh
1.91 kB
| # ASR v3 = PhoWhisper-large-ft-v1 continued on train audio (dev300 excluded) + filtered VieNeu-TTS speech of synth texts. | |
| # Ship only if dev300 beam-4 WER beats v1 (11.89% on the 875 dev clips). | |
| set -x | |
| . ~/venv/bin/activate; cd ~/lifemate | |
| D=~/data/train+public_test; V1=~/dctx/models/asr; OUT=~/asr_v3 | |
| [ -s ~/tts_v1/extra_ok.jsonl ] || python tts_filter.py --asr $V1 --inp ~/tts_v1/extra.jsonl --out ~/tts_v1/extra_ok.jsonl --max-wer 0.3 | |
| [ -f $OUT/config.json ] || python asr_ft.py --root $D --model $V1 --exclude dev300.txt --out $OUT --epochs 2 --lr 5e-6 --bs 16 --holdout-every 0 --extra ~/tts_v1/extra_ok.jsonl > ~/asr_v3_train.log 2>&1 | |
| python asr.py --root $D --split train --ids dev300.txt --model $OUT --out ~/asr_dev_v3.json --nbest 2 --beams 4 > ~/asr_dev_v3.log 2>&1 | |
| python asr.py --root $D --split train --ids dev300.txt --model $V1 --out ~/asr_dev_v1.json --nbest 2 --beams 4 > ~/asr_dev_v1.log 2>&1 | |
| python - <<'PY' | |
| import json, re, unicodedata | |
| D = "/home/hai/data/train+public_test"; ids = {l.strip() for l in open("dev300.txt")} | |
| gold = {} | |
| for r in map(json.loads, open(f"{D}/train/train.jsonl", encoding="utf-8")): | |
| if r["id"] in ids: | |
| gold[r["audio"]] = r["audio_text"] | |
| for t in r["history"]: | |
| if t.get("audio"): gold[t["audio"]] = t["audio_text"] | |
| tok = lambda s: re.findall(r"[^\W_]+", unicodedata.normalize("NFC", s.lower())) | |
| def wer(r, h): | |
| d = list(range(len(h) + 1)) | |
| for i in range(1, len(r) + 1): | |
| q, d[0] = d[0], i | |
| for j in range(1, len(h) + 1): q, d[j] = d[j], min(d[j] + 1, d[j - 1] + 1, q + (r[i - 1] != h[j - 1])) | |
| return d[-1] | |
| for n in ["v1", "v3"]: | |
| h = json.load(open(f"/home/hai/asr_dev_{n}.json", encoding="utf-8")); E = N = 0 | |
| for k, g in gold.items(): | |
| if k in h: gt = tok(g); E += wer(gt, tok(h[k])); N += len(gt) | |
| print(f"DEV300 WER {n}: {E / N:.2%} ({len(h)} clips)") | |
| PY | |
| echo ASRV3_DONE | |