feat: centralize audio format validation for TTS and music commands#116
feat: centralize audio format validation for TTS and music commands#116omghante wants to merge 1 commit intoMiniMax-AI:mainfrom
Conversation
raylanlin
left a comment
There was a problem hiding this comment.
Thanks for this PR, @omghante! The code quality and structure are solid — here are some notes from a detailed review:
✅ What's great:
- Centralized
audio-formats.tsutility with type-safeas const— clean pattern - Dynamic help text (
AUDIO_FORMATS_DISPLAY) is much better than hardcoded strings in each command - Early validation before API call — great UX for quick-fail
- Well-written tests covering opus, ogg, and invalid format rejection
The MiniMax TTS API (v1/t2a_v2) does not actually support opus or ogg as output formats. I tested all 6 formats against the live API:
| Format | API response | Supported? |
|---|---|---|
| mp3 | 0 (success) | ✅ |
| wav | 0 (success) | ✅ |
| flac | 0 (success) | ✅ |
| pcm | 0 (success) | ✅ |
| opus | 2013 (invalid params) | ❌ |
| ogg | 2013 (invalid params) | ❌ |
With this PR as-is, if a user passes --format opus, the CLI will accept it (passes validateAudioFormat) but then the API returns 2013 - invalid params: audio_setting format, giving a confusing error message.
Suggested fix:
Remove opus and ogg from AUDIO_FORMATS in src/utils/audio-formats.ts, keeping only the 4 API-supported formats:
export const AUDIO_FORMATS = ['mp3', 'wav', 'flac', 'pcm'] as const;After this change, the rest of this PR (centralized validation, dynamic help text, test infrastructure) is all meaningful and ready to merge.
Happy to follow up if you want to adjust the supported formats — the refactoring work here is definitely worth landing.
|
效率真高啊,厉害! |
|
The Opus format will be supported this week. |
…iniMax-AI#111) - Add central audio-formats.ts utility with type-safe format validation - Add early CLI-side validation for --format flag (quick-fail UX) - Update help text to dynamically list supported formats (mp3, wav, flac, pcm) - Add unit test for invalid format rejection - Supports only API-validated formats; opus/ogg can be added when backend support lands
62258c0 to
7907a08
Compare
|
Thanks for testing against the live API! Dropped opus/ogg and force-pushed easy one-liner to re-add when backend support lands. Let me know if anything else needs. |
Description
This PR centralizes audio format validation across the MiniMax CLI for
speech synthesize,music generate, andmusic covercommands. Previously, invalid--formatvalues were silently passed to the API, resulting in confusing server-side errors. Now the CLI validates early and fails fast with a clear message.Changes Included:
src/utils/audio-formats.tswith type-safe format constants and validation--formatvalidation across speech and music commands (quick-fail UX)mp3, wav, flac, pcm) instead of hardcoded stringsFixes: #111
@stayif Thanks for raising this the CLI-side validation infrastructure is now in place. Once the backend adds opus/ogg support, enabling it here is literally adding two words to an array. Let me know if you have any feedback!
@RyanLee-Dev Updated per your review removed opus/ogg, kept only the 4 API-validated formats. The centralized validation and dynamic help text are ready to go. Thanks for the thorough testing!