Skip to content

feat: read G.711 A-law/μ-law WAVs in from_wav#32

Merged
wavekat-eason merged 2 commits into
mainfrom
feat/g711-wav-read
Jul 18, 2026
Merged

feat: read G.711 A-law/μ-law WAVs in from_wav#32
wavekat-eason merged 2 commits into
mainfrom
feat/g711-wav-read

Conversation

@wavekat-eason

Copy link
Copy Markdown
Contributor

Why

The WaveKat platform freezes flow prompt audio "phone-ready" as G.711 μ-law WAV (format tag 7). AudioFrame::from_wav delegates entirely to hound, which only parses integer and float PCM — so every one of those files failed to decode, and downstream flow playback aborted at the first prompt.

What

  • from_wav now sniffs the RIFF fmt chunk first: format tags 6 (A-law) and 7 (μ-law) are decoded through the existing codec::g711 module and normalised to f32 like the i16 path; everything else falls through to hound unchanged (including its more descriptive parse errors for non-WAV bytes).
  • The RIFF walker handles the shapes real telephony encoders emit: 18-byte fmt chunks (cbSize), fact chunks, odd-size chunk padding, and declared sizes that overrun the file.
  • Docs (docs/01-wav-io.md) updated.

mp3 is deliberately not supported — it would pull a decoder dependency into a zero-dep crate, and the platform only stores mp3 as a browser-preview convenience (telephony formats are always WAV).

Tests

  • μ-law and A-law round-trips through a hand-built G.711 WAV (18-byte fmt + fact chunk, exercising unknown-chunk skipping).
  • Missing data chunk → descriptive error; non-RIFF bytes still error via hound.
  • Verified against the real platform-cached assets that triggered the original failure: both decode to 8 kHz audio with the expected durations.
  • cargo test --all-features (76 + 7 doc tests), clippy -D warnings, fmt --check all clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Hj93UCb3RKjF6mBwzhsp9f

Platform-generated phone-ready prompts are stored as G.711 μ-law WAVs
(format tag 7), which hound cannot parse — from_wav failed on every
frozen flow asset the WaveKat Voice daemon cached. Sniff the fmt chunk
and decode format tags 6 (A-law) and 7 (μ-law) through codec::g711,
falling through to hound for everything else.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hj93UCb3RKjF6mBwzhsp9f
@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hj93UCb3RKjF6mBwzhsp9f
@wavekat-eason
wavekat-eason merged commit e8c0b5a into main Jul 18, 2026
3 checks passed
@wavekat-eason
wavekat-eason deleted the feat/g711-wav-read branch July 18, 2026 09:50
@github-actions github-actions Bot mentioned this pull request Jul 18, 2026
wavekat-eason pushed a commit that referenced this pull request Jul 18, 2026
## 🤖 New release

* `wavekat-core`: 0.0.13 -> 0.0.14 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.0.14](v0.0.13...v0.0.14)
- 2026-07-18

### Added

- read G.711 A-law/μ-law WAVs in from_wav
([#32](#32))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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