feat: add MiniMax cloud TTS engine - #971
Conversation
Register a cloud speech engine in the TTS engine registry with the current speech models, global/CN endpoint selection, request controls (voice/audio settings, language boost, output format) and audio formats (mp3/wav/flac/pcm). Adds preset-voice listing/validation and unit tests.
📝 WalkthroughWalkthroughAdds MiniMax as a cloud TTS engine with regional API access, preset voices, request validation, audio decoding, backend factory integration, and unit tests for configuration, synthesis, and error handling. ChangesMiniMax TTS support
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant GenerationRequest
participant MiniMaxTTSBackend
participant MiniMaxT2A
GenerationRequest->>MiniMaxTTSBackend: generate text and voice settings
MiniMaxTTSBackend->>MiniMaxT2A: POST T2A payload with API key
MiniMaxT2A-->>MiniMaxTTSBackend: JSON response with hex audio
MiniMaxTTSBackend->>MiniMaxTTSBackend: decode audio to float32 samples
MiniMaxTTSBackend-->>GenerationRequest: audio samples and sample rate
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/backends/minimax_backend.py`:
- Around line 89-100: Extend LANGUAGE_BOOST_MAP with MiniMax-supported boost
names for the explicitly supported language codes ar, he, da, el, fi, hi, ms,
nl, no, pl, sv, and tr, ensuring GenerationRequest.language values are mapped to
their corresponding language names instead of falling back to "auto".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7275aeea-b206-40b8-84c6-5be22c8774b0
📒 Files selected for processing (6)
backend/backends/__init__.pybackend/backends/minimax_backend.pybackend/models.pybackend/routes/profiles.pybackend/services/profiles.pybackend/tests/test_minimax_backend.py
| LANGUAGE_BOOST_MAP = { | ||
| "en": "English", | ||
| "zh": "Chinese", | ||
| "ja": "Japanese", | ||
| "ko": "Korean", | ||
| "de": "German", | ||
| "fr": "French", | ||
| "ru": "Russian", | ||
| "pt": "Portuguese", | ||
| "es": "Spanish", | ||
| "it": "Italian", | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== locate files =="
fd -a 'minimax_backend\.py|models\.py$' . | sed 's#^\./##'
echo "== inspect minimax backend relevant section =="
if [ -f backend/backends/minimax_backend.py ]; then
wc -l backend/backends/minimax_backend.py
sed -n '1,180p' backend/backends/minimax_backend.py | cat -n
fi
echo "== search request language type/constants =="
rg -n "GenerationRequest|language|LANGUAGE_BOOST_MAP|boost" backend -S || trueRepository: jamiepine/voicebox
Length of output: 24857
🌐 Web query:
MiniMax HTTP Speech T2A supported languages boost API language_code
💡 Result:
MiniMax text-to-audio (T2A) models support 40 widely used global languages [1][2][3]. The language_boost parameter in the API is used to enhance recognition or synthesis accuracy for these languages, allowing you to specify a language name or set it to "Automatic" [4]. For certain languages with specific dialectal needs, such as Cantonese, the parameter may require a combined string like "Chinese,Yue" [5][6]. The 40 supported languages include: Chinese (including Cantonese), English, Spanish, French, Russian, German, Portuguese, Arabic, Italian, Japanese, Korean, Indonesian, Vietnamese, Turkish, Dutch, Ukrainian, Thai, Polish, Romanian, Greek, Czech, Finnish, Hindi, Bulgarian, Danish, Hebrew, Malay, Persian, Slovak, Swedish, Croatian, Filipino, Hungarian, Norwegian, Slovenian, Catalan, Nynorsk, Tamil, and Afrikaans [1][2][3]. Note that certain languages, such as Filipino, Tamil, and Persian, are specifically supported by the newer speech-2.6 series models and later [7][8]. When using the API, ensure you select the appropriate model (e.g., speech-2.8-hd, speech-2.8-turbo, or speech-2.6-*) to access the full range of language capabilities [1][8].
Citations:
- 1: https://platform.minimax.io/docs/api-reference/api-overview
- 2: https://platform.minimax.io/docs/guides/speech-t2a-async
- 3: https://platform.minimax.io/docs/guides/speech-t2a-websocket
- 4: https://replicate.com/minimax/speech-2.6-turbo/readme
- 5: https://platform.minimax.io/docs/api-reference/speech-t2a-http
- 6: https://reference-server.pipecat.ai/en/stable/_modules/pipecat/services/minimax/tts.html
- 7: https://pipecat-docs.readthedocs.io/en/latest/api/pipecat.services.minimax.tts.html
- 8: https://docs.pipecat.ai/api-reference/server/services/tts/minimax
🌐 Web query:
MiniMax T2A language_boost exact value Arabic Danish Greek Finnish Hebrew Hind
💡 Result:
In the MiniMax Text-to-Audio (T2A) API, the language_boost parameter is used to specify a language or dialect to enhance recognition and synthesis accuracy, preventing pronunciation errors [1][2][3]. Arabic, Danish, Greek, Finnish, Hebrew, and Hindi are all supported, valid values for this parameter [1][3][4]. When using this parameter, you must provide the language name exactly as defined in the API's supported list [1][5]. The supported values for the requested languages are: - Arabic [1][4] - Danish [1][4] - Greek [1][4] - Finnish [1][4] - Hebrew [1][4] - Hindi [1][4] Other common valid values include 'auto' (for automatic detection), 'English', 'Chinese', 'French', 'German', and many others [1][3][5]. The parameter defaults to null if not specified [1][6]. Note that while the model supports these languages, the speech-01 and speech-02 series models have specific limitations regarding Persian, Filipino, and Tamil, which are not currently supported for enhancement via this parameter [1].
Citations:
- 1: https://platform.minimax.io/docs/api-reference/speech-t2a-http
- 2: https://platform.minimax.io/docs/faq/about-apis
- 3: https://novita.ai/docs/api-reference/model-apis-minimax-speech-02-turbo
- 4: https://platform.minimax.io/docs/api-reference/api-overview
- 5: https://fal.ai/models/fal-ai/minimax/speech-02-turbo/api
- 6: https://platform.minimax.io/docs/guides/mcp-guide
🌐 Web query:
site:platform.minimax.io/api-reference/speech-t2a-http T2A language_boost Arabic Hebrew Finnish
💡 Result:
Yes — the MiniMax T2A HTTP docs list Arabic, Hebrew, and Finnish as available language_boost options. The docs also note that language_boost can be set to "auto" if the language is unknown. [1]
Map the remaining explicitly supported request languages.
GenerationRequest.language allows ar, he, da, el, fi, hi, ms, nl, no, pl, sv, and tr, but LANGUAGE_BOOST_MAP sends "auto" for all of them. Add MiniMax-supported boost names for these codes so GenerationRequest.language is preserved.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@backend/backends/minimax_backend.py` around lines 89 - 100, Extend
LANGUAGE_BOOST_MAP with MiniMax-supported boost names for the explicitly
supported language codes ar, he, da, el, fi, hi, ms, nl, no, pl, sv, and tr,
ensuring GenerationRequest.language values are mapped to their corresponding
language names instead of falling back to "auto".
Reason: Add MiniMax cloud speech generation to the TTS engine registry with the current speech models, global/CN endpoint selection, request controls, and audio formats.
What this adds
A new cloud TTS engine that plugs into the existing
TTSBackendprotocol, solong-text chunking, trimming and preset-voice profile handling all work
unchanged. Nothing is downloaded — each request is a single HTTP call.
backend/backends/minimax_backend.py— newMiniMaxTTSBackend:MINIMAX_TTS_MODELS):speech-2.8-hd(default),speech-2.8-turbo,speech-2.6-hd,speech-2.6-turbo,speech-02-hd,speech-02-turbo,speech-01-hd,speech-01-turbo. Unknown model idsfall back to the default.
MINIMAX_API_REGION:global_en(
https://api.minimax.io/v1/t2a_v2, default) andcn_zh(
https://api.minimaxi.com/v1/t2a_v2). Unknown/empty values fall back tothe global host.
voice_setting(voice id, speed,vol, pitch),
audio_setting(sample rate, format, channel),language_boost(derived from the request language,autofallback) andoutput_format.MINIMAX_AUDIO_FORMATS):mp3,wav,flac,pcm(default).
pcmis decoded directly to float32; container formats aredecoded through soundfile.
MINIMAX_API_KEYor~/.env.local, and API errors (base_resp.status_code) surface as clearruntime errors.
backend/backends/__init__.py— registersminimaxinTTS_ENGINES, wiresthe factory, and reports a clear API-key error from
ensure_model_cached_or_raiseinstead of a download message.backend/models.py— allowsengine="minimax"onGenerationRequest.backend/services/profiles.py/backend/routes/profiles.py— expose thepreset voice ids for validation and the
/profiles/presets/{engine}listing.backend/tests/test_minimax_backend.py— unit tests for region/endpointselection, payload construction, response parsing and audio decoding (no
network calls).
Checks
python -m ruff checkon the new/changed backend files — clean.python -m pytest backend/tests/test_minimax_backend.py— 19 passed.Configuration is required at runtime: set
MINIMAX_API_KEY(and optionallyMINIMAX_API_REGION).Summary by CodeRabbit
New Features
Bug Fixes