Skip to content

refactor(web): replace lamejs mp3 encoding#38173

Draft
hyoban wants to merge 2 commits into
mainfrom
codex/replace-lamejs-with-mediabunny
Draft

refactor(web): replace lamejs mp3 encoding#38173
hyoban wants to merge 2 commits into
mainfrom
codex/replace-lamejs-with-mediabunny

Conversation

@hyoban

@hyoban hyoban commented Jun 29, 2026

Copy link
Copy Markdown
Member

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Fixes #38172

  • Replace lamejs voice input MP3 encoding with Mediabunny and @mediabunny/mp3-encoder.
  • Encode recorder PCM data through AudioSampleSource and Mp3OutputFormat while preserving the audio/mp3 upload behavior.
  • Remove the local lamejs type declarations and update voice input tests for mono, stereo, native encoder detection, and invalid channel data.

Screenshots

Before After
N/A N/A

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Validation

  • pnpm -C web test app/components/base/voice-input/__tests__/utils.spec.ts
  • pnpm -C web test app/components/base/voice-input/__tests__/index.spec.tsx
  • pnpm -C web type-check
  • pnpm -C web lint:tss
  • pnpm -C web exec tsx -e "..." smoke test for real Mediabunny MP3 encoding: audio/mp3 3060

pnpm -C web exec vp staged was attempted, but this repository currently reports: No "staged" config found in vite.config.ts.

From Codex

@github-actions github-actions Bot added the web This relates to changes on the web. label Jun 29, 2026
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.38%. Comparing base (49a92f0) to head (b252f4f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #38173      +/-   ##
==========================================
+ Coverage   85.32%   85.38%   +0.05%     
==========================================
  Files        4967     5122     +155     
  Lines      258518   262867    +4349     
  Branches    49059    50117    +1058     
==========================================
+ Hits       220593   224442    +3849     
- Misses      33632    34132     +500     
  Partials     4293     4293              
Flag Coverage Δ
cli 88.45% <ø> (?)
dify-ui 94.93% <ø> (ø)
web 85.05% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor/Chore] Replace lamejs MP3 encoding with Mediabunny

1 participant