Skip to content

Add a pcm_to_wav helper to pipecat.audio.utils - #5284

Closed
jamsea wants to merge 2 commits into
mainfrom
jh/pcm-to-wav
Closed

jamsea wants to merge 2 commits into
mainfrom
jh/pcm-to-wav

Conversation

@jamsea

@jamsea jamsea commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

What

Adds pcm_to_wav(pcm, sample_rate, num_channels=1) to pipecat.audio.utils, wrapping raw s16le PCM in a WAV container.

Why

Every example that persists or uploads audio from AudioBufferProcessor hand-rolls the same wave.open block, including the pipecat init server template (src/pipecat/cli/templates/server/_macros/event_handlers.jinja2). audio/utils.py already holds the other PCM helpers (mix, interleave, ulaw/alaw), so this gives the WAV wrap a home next to them.

Extracted from the Langfuse call-recording example (pipecat-ai/pipecat-examples#240), where it is one of three pieces of generic glue the example carries because core lacks them.

Test plan

  • New tests/test_audio_utils.py: mono, stereo, and empty PCM round-trip through wave.open with the expected channels, width, rate, and frames.
  • uv run pytest tests/test_audio_utils.py → 3 passed.

jamsea added 2 commits August 11, 2026 12:22
Every example that persists or uploads audio from AudioBufferProcessor
hand-rolls the same wave.open block, including the pipecat init template.
Give it a home next to the other PCM helpers.
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/pipecat/audio/utils.py 76.69% <100.00%> (+2.50%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jamsea

jamsea commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Folded into #5285, which brings the whole Langfuse call-recording integration into core and includes this commit. Closing to avoid the same commit living in two PRs.

@jamsea jamsea closed this Aug 11, 2026
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