fix(speech): decode SSE stream to raw audio and handle EPIPE#60
Merged
RyanLee-Dev merged 1 commit intoMiniMax-AI:mainfrom Apr 9, 2026
Merged
Conversation
- Stream mode now parses SSE events, hex-decodes .data.audio, and writes raw binary MP3 to stdout (fixes --stream example piping to mpv) - Add EPIPE handler to main.ts so piping to a downstream process that exits early (e.g. mpv, head) no longer crashes with unhandled error Fixes MiniMax-AI#54 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Two fixes for
mmx speech synthesize --stream:1. SSE stream now outputs decoded binary audio
--streamwas writing raw SSE/JSON/hex text to stdout. It now:parseSSE().data.audio(hex string) from each event's JSONThis makes the documented example actually work:
2. EPIPE no longer crashes the process
Added
stdout.on('error')handler inmain.ts. When a downstream process (e.g.mpv,head) exits early and closes the pipe,EPIPEis now treated as normal pipe-close with exit code 0, instead of an unhandled exception that crashes the CLI.Before:
Error: write EPIPE— unhandled, process exits with non-zero codeAfter: exit code 0
Fixes #54
Test plan
mmx speech synthesize --text "Test" --stream | head -c 4— first bytes should beID3(valid MP3)mmx speech synthesize --text "Test" --stream | head -c 1; echo $?— should print0mmx speech synthesize --text "Test" --out /tmp/out.mp3— non-stream path unchanged🤖 Generated with Claude Code