Skip to content

fix: decode SSE audio stream for music and speech#130

Merged
RyanLee-Dev merged 1 commit into
mainfrom
fix/stream-audio-decode
May 11, 2026
Merged

fix: decode SSE audio stream for music and speech#130
RyanLee-Dev merged 1 commit into
mainfrom
fix/stream-audio-decode

Conversation

@RyanLee-Dev
Copy link
Copy Markdown
Collaborator

Summary

  • Music streaming output 0 bytes — extra_info filter (!== undefined) skipped all events because music API sends extra_info: null on every chunk. Changed to status === 2 to correctly skip only the terminal summary event.
  • AbortSignal.timeout killed long-running streaming responses (music generation takes 90+ seconds). Disabled timeout for streaming requests.
  • Extracted shared pipeAudioStream() util, replacing duplicated raw-reader code in music/cover, music/generate, and speech/synthesize.

Closes #55

Test plan

  • speech synthesize --stream → valid MP3 (49KB, ID3 header)
  • music generate --stream → valid MP3 (4.8MB, ID3 header)
  • bun test — 196 pass
  • bun run lint — clean

Music streaming was writing raw SSE text instead of decoded audio bytes.
Two root causes:
- extra_info filter skipped all music events (null !== undefined is true)
- AbortSignal.timeout aborted long-running streaming responses

Extracted pipeAudioStream() to shared util; uses status===2 to skip
the terminal summary event. Disabled fetch timeout for streaming.
@RyanLee-Dev RyanLee-Dev merged commit 09f4728 into main May 11, 2026
2 checks passed
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