fix(fish-s2): reference_id was a silent no-op — populate per-voice dirs + guard the regression

reference_id=<name> resolves against the DIRECTORY references/<name>/
(audio + same-basename .lab), not a flat references/<name>.wav. Voices
were staged flat with the per-name dirs left empty, so every
reference_id resolved to nothing and Fish fell back to its default
speaker — every dropdown voice produced byte-identical audio (proven:
Abigail == Imogen == no-ref, same text+seed). This was the real "no
accent" root cause, independent of the asset-engine "undefined" select
bug.

Server fix (applied to irv-ml1): populated references/<name>/<name>.wav
+ <name>.lab for all 32 voices; re-test confirms Imogen/Eleanor/
Beatrice/Abigail/no-ref now all distinct.

Durable hardening + record correction:
- playbook: normalize-layout step (flat <name>.wav -> nested dir, cp -u
  idempotent, when-gated on count mismatch) + an A/B verify gate that
  hard-fails the deploy if two reference_ids yield identical output.
- services.yaml: correct the reference_id resolution doc (dir + .lab,
  not flat wav).
- README + persistent-memory: correct the "reference_id-by-name is THE
  working path, verified" claim — it was a no-op until this fix; the
  prior ECAPA 0.79 result came through the inline base64 path.
This commit is contained in:
vh
2026-06-01 16:42:30 -07:00
parent 3b54519d60
commit c5bbb90980
4 changed files with 100 additions and 26 deletions
+42 -3
View File
@@ -36,6 +36,27 @@ steps:
shell: mkdir -p {{ references_dir }}
creates: "{{ references_dir }}"
- name: Normalize reference layout (flat <name>.wav → <name>/<name>.wav + .lab)
# fish-speech resolves reference_id=<name> against the DIRECTORY
# references/<name>/ (audio + a same-basename .lab transcript), NOT a
# flat references/<name>.wav. A flat-only layout makes every
# reference_id silently resolve to nothing → Fish falls back to its
# default speaker, so every voice in the dropdown sounds identical
# (this was the 2026-06-01 "no accent" root cause). External voice
# imports drop flat <name>.wav + <name>.txt here; this step mirrors
# each into references/<name>/<name>.wav + <name>/<name>.lab. `cp -u`
# makes it idempotent; the `when:` skips it once every flat wav has a
# matching nested wav (audio-only voices like glados need no .lab).
shell: |
cd {{ references_dir }} || exit 1
for w in *.wav; do
[ -e "$w" ] || continue
n="${w%.wav}"; mkdir -p "$n"
cp -u "$w" "$n/$n.wav"
[ -e "$n.txt" ] && cp -u "$n.txt" "$n/$n.lab" || true
done
when: "[ \"$(cd {{ references_dir }} 2>/dev/null && ls *.wav 2>/dev/null | wc -l)\" -ne \"$(cd {{ references_dir }} 2>/dev/null && ls */*.wav 2>/dev/null | wc -l)\" ]"
- name: Ensure checkpoints dir exists
shell: mkdir -p {{ checkpoints_dir }}
creates: "{{ checkpoints_dir }}"
@@ -106,9 +127,10 @@ verify:
- name: /v1/tts returns a real WAV (POST with text body)
# Fish's API is NOT OpenAI-compatible — there's no /v1/audio/speech
# and no /v1/audio/voices. The single TTS endpoint is POST /v1/tts
# with at minimum {"text":"..."} returning audio/wav. Voice cloning
# is via reference= field in the body (paths under /app/references).
# Verify by POST + asserting the response is a real RIFF WAV.
# with at minimum {"text":"..."} returning audio/wav. Named-voice
# cloning is via the reference_id field, which resolves against the
# references/<name>/ directory (audio + .lab) — see the A/B gate
# below. Verify by POST + asserting the response is a real RIFF WAV.
shell: |
out=$(mktemp --suffix=.wav)
curl -sf -X POST http://localhost:{{ host_port }}/v1/tts \
@@ -119,6 +141,23 @@ verify:
rm -f "$out"
changed_when: "false"
- name: reference_id actually changes the voice (A/B — guards the empty-dir regression)
# Two different reference_ids with identical text+seed MUST yield
# different audio. If byte-identical, reference_id is being ignored
# (empty references/<id>/ dirs) and every voice has silently
# collapsed to Fish's default speaker — the 2026-06-01 root cause.
# Hard-fail the deploy so the regression can never ship silently.
shell: |
a=$(mktemp); b=$(mktemp)
curl -sf -X POST http://localhost:{{ host_port }}/v1/tts -H 'Content-Type: application/json' \
-d '{"text":"The quick brown fox.","seed":42,"reference_id":"Abigail"}' -o "$a" --max-time 60
curl -sf -X POST http://localhost:{{ host_port }}/v1/tts -H 'Content-Type: application/json' \
-d '{"text":"The quick brown fox.","seed":42,"reference_id":"Imogen"}' -o "$b" --max-time 60
rc=0; [ "$(md5sum < "$a")" = "$(md5sum < "$b")" ] && rc=1
rm -f "$a" "$b"
exit $rc
changed_when: "false"
- name: Container is running
shell: docker inspect fish-s2 --format '{{.State.Status}}' | grep -q running
changed_when: "false"