Skip to content

fix(web): explicitly resume AudioContext and play audio on first TTS load#35901

Merged
crazywoola merged 1 commit into
langgenius:mainfrom
ki3nd:fix/web-tts-audio-not-playing
May 8, 2026
Merged

fix(web): explicitly resume AudioContext and play audio on first TTS load#35901
crazywoola merged 1 commit into
langgenius:mainfrom
ki3nd:fix/web-tts-audio-not-playing

Conversation

@ki3nd
Copy link
Copy Markdown
Contributor

@ki3nd ki3nd commented May 7, 2026

AudioPlayer.playAudio() on first call went directly to loadAudio() without calling audio.play(), relying solely on autoplay=true. When audio is routed through AudioContext via createMediaElementSource, autoplay is unreliable and the AudioContext may be suspended, producing no sound despite a valid API response.

Mirror the SSE path (playAudioWithAudio) by explicitly resuming the AudioContext and calling audio.play() before streaming begins.

Fixes #35880

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

Screenshots

Before After
... ...

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

…load

AudioPlayer.playAudio() on first call went directly to loadAudio() without
calling audio.play(), relying solely on autoplay=true. When audio is routed
through AudioContext via createMediaElementSource, autoplay is unreliable
and the AudioContext may be suspended, producing no sound despite a valid
API response.

Mirror the SSE path (playAudioWithAudio) by explicitly resuming the
AudioContext and calling audio.play() before streaming begins.

Fixes langgenius#35880
@ki3nd ki3nd requested review from iamjoel and zxhlyh as code owners May 7, 2026 15:42
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. javascript Pull requests that update javascript code labels May 7, 2026
@github-actions github-actions Bot added the web This relates to changes on the web. label May 7, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 8, 2026
@crazywoola crazywoola added this pull request to the merge queue May 8, 2026
Merged via the queue into langgenius:main with commit 7bc19d8 May 8, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update javascript code lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TTS audio fails to play in the browser

2 participants