stt: make the golden tests fail where they used to disappear
The file comment named four regressions caught here. Three were not. Nothing on this path resamples, because PCMFromWAV refuses anything that is not already 16 kHz mono s16. Nothing exercises language selection, because the hint comes out of the manifest already correct. And a bad model path was the one condition that made the whole test vanish behind a skip nobody reads. The comment now claims the two things that are real, an explicitly set MAVEN_WHISPER_MODEL that does not exist is a failure, and a missing fixture is a failure rather than a skip. looseWordMatch accepted a different word. Four retained runes of "воды" is "вод", so whisper hearing "выпил водки" satisfied the ru_fact keyword, and "dis" let display, distance and discuss all stand in for "disk". A case ending adds a rune, not a syllable, so the hypothesis is capped in length as well as matched on prefix. The spoken text lived in the generator and in the manifest with nothing tying them together. Editing one left the other describing audio that no longer existed, and at a flat ceiling of 0.34 over a five-word reference a one-word drift passed silently. The script reads text out of the manifest now, and the ceilings are set just above what each case really measures against ggml-small, with the measurement recorded beside them. Also: the test carried its own copy of the PCM to float32 conversion, so a regression in the daemon's copy left the silence-gate assertion green, and the manifest was validated for keywords but not for text, where an empty reference makes every hypothesis score a WER of 1. Found in review of #75.
This commit is contained in:
@@ -10,6 +10,13 @@
|
||||
# Usage:
|
||||
# scripts/gen-stt-fixtures.sh
|
||||
#
|
||||
# The spoken text is NOT written here. It is read out of
|
||||
# cmd/mavsttd/testdata/golden_v1.json, which is the same file the test scores
|
||||
# against. It used to live in both places, so editing this script and running
|
||||
# make stt-fixtures left the manifest describing audio that no longer existed —
|
||||
# and at a WER ceiling of 0.34 over a five-word reference, a one-word drift
|
||||
# passed silently. Punctuation does not matter: normalizeTranscript strips it.
|
||||
#
|
||||
# Voices are picked up from, in order, $PIPER_VOICE_RU / $PIPER_VOICE_EN, then
|
||||
# the repo's models/tts, then ~/esp-server/voices. The English voice is not
|
||||
# vendored; if it is missing the English fixture is skipped and the existing
|
||||
@@ -34,6 +41,26 @@ ru="$(pick_voice "${PIPER_VOICE_RU:-}" "$root/models/tts/ru_RU-irina-medium.onnx
|
||||
}
|
||||
en="$(pick_voice "${PIPER_VOICE_EN:-}" "$root/models/tts/en_US-lessac-medium.onnx" "$HOME/esp-server/voices/en_US-lessac-medium.onnx")" || en=""
|
||||
|
||||
manifest="$root/cmd/mavsttd/testdata/golden_v1.json"
|
||||
command -v jq >/dev/null || { echo "jq is required to read $manifest" >&2; exit 1; }
|
||||
[ -f "$manifest" ] || { echo "missing $manifest" >&2; exit 1; }
|
||||
|
||||
# case_text <name> — the reference transcript for one manifest case.
|
||||
case_text() {
|
||||
local name="$1" text
|
||||
text="$(jq -r --arg n "$name" '.cases[] | select(.name==$n) | .text' "$manifest")"
|
||||
[ -n "$text" ] && [ "$text" != "null" ] || { echo "no case named $name in $manifest" >&2; exit 1; }
|
||||
printf '%s' "$text"
|
||||
}
|
||||
|
||||
# case_wav <name> — the file name the manifest expects for one case.
|
||||
case_wav() {
|
||||
local name="$1" wav
|
||||
wav="$(jq -r --arg n "$name" '.cases[] | select(.name==$n) | .wav' "$manifest")"
|
||||
[ -n "$wav" ] && [ "$wav" != "null" ] || { echo "no case named $name in $manifest" >&2; exit 1; }
|
||||
printf '%s' "$wav"
|
||||
}
|
||||
|
||||
# synth <voice> <out.wav> <text>
|
||||
# piper emits raw 22050 Hz s16le on stdout; ffmpeg resamples to the canonical
|
||||
# 16 kHz mono and writes a plain 44-byte-header WAV (-fflags bitexact keeps
|
||||
@@ -51,15 +78,15 @@ synth() {
|
||||
echo "wrote $dest ($(stat -c%s "$dest") bytes)"
|
||||
}
|
||||
|
||||
synth "$ru" "$out/ru_reminder.wav" "Напомни мне через час позвонить маме."
|
||||
synth "$ru" "$out/ru_fact.wav" "Отметь, что я выпил воды."
|
||||
synth "$ru" "$out/ru_query.wav" "Что у меня сегодня по календарю?"
|
||||
for name in ru_reminder ru_fact ru_query; do
|
||||
synth "$ru" "$out/$(case_wav "$name")" "$(case_text "$name")"
|
||||
done
|
||||
|
||||
if [ -n "$en" ]; then
|
||||
# Keep the English line free of words piper spells out letter by letter —
|
||||
# "nginx" comes out of lessac as "engine X", which is a TTS artefact and
|
||||
# would make the fixture assert on the wrong thing.
|
||||
synth "$en" "$out/en_act.wav" "Restart the web server and check the disk space."
|
||||
# Keep the English line in the manifest free of words piper spells out
|
||||
# letter by letter — "nginx" comes out of lessac as "engine X", which is a
|
||||
# TTS artefact and would make the fixture assert on the wrong thing.
|
||||
synth "$en" "$out/$(case_wav en_act)" "$(case_text en_act)"
|
||||
else
|
||||
echo "no english piper voice found — skipping en_act.wav" >&2
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user