Repository navigation
Decode mu-law and A-law WAV files before resampling - #30
Merged
Merged
Conversation
sipbot serve's play command rejected 8 kHz mu-law WAV files with "not a readable WAV ... decode produced no PCM", although AGENTS.md and --help say mu-law is accepted. AudioAlgos passed the WaveFileReader to NAudio's ToSampleProvider(), which only takes PCM and IEEE float and throws "Unsupported source encoding" for G.711 data. WAV readers now go through WavSampleProvider, which decodes mu-law and A-law data to 16-bit PCM with NAudio's managed decoders first. This covers ConvertWavToPcm (sipbot play) and both ReadWelcomeWav* helpers. Closes #29 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SGcDAANyU5QKVK2Vtur1xc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #29.
sipbot serve'splayrejected 8 kHz μ-law WAV files ("not a readable WAV … decode produced no PCM"), although AGENTS.md and--helpsay μ-law is accepted.AudioAlgospassed theWaveFileReaderto NAudio'sToSampleProvider(), which only takes PCM and IEEE float and throws "Unsupported source encoding" on G.711 data.Changes
AudioAlgos.WavSampleProvider(private): decodes μ-law and A-law WAV data to 16-bit PCM with NAudio's managedMuLawDecoder/ALawDecoder, then builds the sample provider. Other encodings go toToSampleProvider()as before.ConvertWavToPcm(sipbot play),ReadWelcomeWavBytesAsPcmu, andReadWelcomeWavBytesAsPcm16kHz.Tests
WavDecodeTests(8 tests):ReadWelcomeWavBytesAsPcmureads a μ-law file andReadWelcomeWavBytesAsPcm16kHzreads an A-law file.AgentAudioEndPoint.PlayWavaccepts a μ-law file, which is the reported symptom.Without the fix, 7 of the 8 fail; the PCM check passes either way. The full suite passes: 114/114.
Live check against a VitalPBX (Asterisk 20.14) lab PBX, extension to extension. A
sipbot servebuilt from this branch played an 8 kHz μ-law WAV written by ffmpeg into an answered call. v0.1.5 had returned the error above for the same file. The far end's recording matched the clip: correlation 0.997, and 1.000 in every 1 s window.🤖 Generated with Claude Code