Skip to content

feat: centralize audio format validation for TTS and music commands#116

Open
omghante wants to merge 1 commit intoMiniMax-AI:mainfrom
omghante:feat/111-add-opus-ogg-audio-format-support
Open

feat: centralize audio format validation for TTS and music commands#116
omghante wants to merge 1 commit intoMiniMax-AI:mainfrom
omghante:feat/111-add-opus-ogg-audio-format-support

Conversation

@omghante
Copy link
Copy Markdown

@omghante omghante commented Apr 25, 2026

Description

This PR centralizes audio format validation across the MiniMax CLI for speech synthesize, music generate, and music cover commands. Previously, invalid --format values 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:

  • Created a centralized src/utils/audio-formats.ts with type-safe format constants and validation
  • Added early CLI-side --format validation across speech and music commands (quick-fail UX)
  • Updated help text to dynamically list supported formats (mp3, wav, flac, pcm) instead of hardcoded strings
  • Added unit test for invalid format rejection

Note: Only API-supported formats (mp3, wav, flac, pcm) are included. When backend opus/ogg support lands, it's a one-line addition to AUDIO_FORMATS.

Fixes: #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!

Copy link
Copy Markdown
Collaborator

@raylanlin raylanlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts utility with type-safe as 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

⚠️ Issue with opus/ogg support:
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.

@stayif
Copy link
Copy Markdown

stayif commented Apr 27, 2026

效率真高啊,厉害!

@RyanLee-Dev
Copy link
Copy Markdown
Collaborator

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
@omghante omghante force-pushed the feat/111-add-opus-ogg-audio-format-support branch from 62258c0 to 7907a08 Compare April 27, 2026 05:04
@omghante
Copy link
Copy Markdown
Author

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.

@omghante omghante changed the title feat: add opus/ogg audio format support for TTS and music feat: centralize audio format validation for TTS and music commands Apr 27, 2026
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.

Feature Request: Add opus/ogg format support for TTS output

4 participants