Skip to content

chore(voice): report real wav duration, ignoring a streaming placeholder header#27

Merged
wine-fall merged 2 commits into
mainfrom
zachg-0715--fix-wav-duration
Jul 15, 2026
Merged

chore(voice): report real wav duration, ignoring a streaming placeholder header#27
wine-fall merged 2 commits into
mainfrom
zachg-0715--fix-wav-duration

Conversation

@wine-fall

Copy link
Copy Markdown
Owner

What

wav_seconds reported a bogus, constant duration (~48695s seen in the dev log)
for every remote synth, which pinned the synth log's rtf to 0.00 — making
"is TTS keeping up with real time?" unreadable.

Root cause: fish.audio streams the wav and can't know the final length up
front, so it writes a placeholder/oversized data-chunk size (0xFFFFFFFF) in the
header. wave.getnframes() trusts that placeholder → a huge, clip-independent
frame count. 48695.77 × 44100 ≈ 0xFFFFFFFF / 2 frames confirms it.

Fix: measure the PCM actually on disk (readframes stops at EOF) instead of
trusting the header's declared frame count, so the duration is real regardless of
what the header claims.

Verification

  • Unit: a wav with the RIFF + data-chunk sizes overwritten to 0xFFFFFFFF still
    reports its true 2.0s (regression test).
  • Real boundary: one real fish.audio synth now reports ~3.7s (was ~48695s),
    so rtf is meaningful again.
  • Full suite: 232 passed, 12 deselected.

Scope

Pure observability fix (dev-log audio_s / rtf) — no runtime behavior change.
Independent of the cold-start PRs (#24/#25/#26); branches off main.

AI coding brief

  • Original request: While analyzing the cold-start dev-log timings, the
    synth events showed audio_s=48695.77 rtf=0.00 on every clip — obviously
    wrong. User asked to fix this log bug first.
  • Manual interventions: None on the fix itself; it fell out of the timing
    analysis the user asked for.
  • Retro: The constant-across-clips value was the tell (a real duration would
    vary with text length) — a fast way to spot "reading a header field, not the
    data." Worth checking derived metrics against a couple of different inputs
    before trusting them in an analysis.

🤖 Generated with Claude Code

wine-fall and others added 2 commits July 15, 2026 11:29
…der header

fish.audio streams the wav and writes a placeholder/oversized data-chunk size in
the header (the final length isn't known up front), so wav_seconds trusting
getnframes() reported a bogus constant (~48695s) — pinning the synth log's rtf
to 0.00 and making "is TTS real-time?" unreadable. Measure the PCM actually on
disk (readframes stops at EOF) so the duration is real regardless of the header.
Verified: a real fish.audio clip now reports ~3.7s.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@wine-fall wine-fall merged commit 6bec82f into main Jul 15, 2026
4 checks passed
@wine-fall wine-fall deleted the zachg-0715--fix-wav-duration branch July 15, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant