Skip to content

feat(tts): add Xiaomi MiMo-V2-TTS as speech provider#55614

Closed
zoujiejun wants to merge 6 commits into
openclaw:mainfrom
zoujiejun:feat/mimo-tts-provider
Closed

feat(tts): add Xiaomi MiMo-V2-TTS as speech provider#55614
zoujiejun wants to merge 6 commits into
openclaw:mainfrom
zoujiejun:feat/mimo-tts-provider

Conversation

@zoujiejun

@zoujiejun zoujiejun commented Mar 27, 2026

Copy link
Copy Markdown

Summary

Add Xiaomi MiMo-V2-TTS as a new speech synthesis provider in the existing Xiaomi extension.

Closes #52376

Motivation

MiMo-V2-TTS provides high-quality Chinese TTS with unique capabilities:

  • Natural language style control — describe voice style in plain text
  • Dialect support — Northeastern, Sichuan, Cantonese, Taiwanese
  • Character voices — Sun Wukong, Lin Daiyu, etc.
  • Singing synthesis — same model, no mode switch
  • Free — currently the only free API on the MiMo platform

Implementation

Uses the existing Xiaomi extension. MiMo TTS uses a non-standard API:

  • Endpoint: POST /v1/chat/completions (not /v1/audio/speech)
  • Auth: api-key header (not Authorization: Bearer)
  • Audio: message.audio.data base64, 24kHz 16bit mono MP3

Configuration

{
  messages: {
    tts: {
      provider: "mimo",
      providers: {
        mimo: {
          apiKey: "sk-xxx",  // or MIMO_API_KEY env var
          voice: "mimo_default",
          style: "Happy"
        }
      }
    }
  }
}

Files Changed

File Change
extensions/xiaomi/speech-provider.ts New — 150 lines
extensions/xiaomi/index.ts +2 lines
extensions/xiaomi/openclaw.plugin.json +1 line

Testing

  • pnpm build passes
  • ✅ TTS tests 26/26 pass
  • ✅ Real API: Chinese, English, style control, error handling, long text

AI-assisted (OpenClaw + GitHub Copilot). Fully tested.

@greptile-apps

greptile-apps Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds Xiaomi MiMo-V2-TTS as a new speech synthesis provider within the existing Xiaomi extension. The implementation correctly follows the established SpeechProviderPlugin contract — auth fallback (config.apiKey || process.env.MIMO_API_KEY), fileExtension: \".wav\" (dot-prefixed as required by the TTS file-path template), and a static voice list are all consistent with the rest of the codebase.\n\nKey items:\n- The core speech-provider.ts implementation is clean and well-structured; no logic issues found.\n- extensions/xiaomi/index.ts correctly wires up the register hook.\n- bundled-plugin-metadata.generated.ts was not regenerated. openclaw.plugin.json now declares contracts.speechProviders: [\"mimo\"], but the auto-generated snapshot file still carries the old xiaomi entry without a contracts block. This causes pnpm check:bundled-plugin-metadata to fail and means BUNDLED_SPEECH_PLUGIN_IDS won't include \"xiaomi\" at runtime. Running node scripts/generate-bundled-plugin-metadata.mjs and committing the result will resolve both.

Confidence Score: 4/5

Safe to merge after regenerating and committing the bundled plugin metadata snapshot.

The speech provider implementation itself is correct and follows existing patterns. The single remaining blocker is the stale generated file — a one-command fix with no architectural change required.

src/plugins/bundled-plugin-metadata.generated.ts — needs to be regenerated to reflect the new contracts.speechProviders: ["mimo"] entry for the xiaomi plugin.

Important Files Changed

Filename Overview
extensions/xiaomi/speech-provider.ts New MiMo TTS speech provider implementing the non-standard chat-completions API. Structure, error handling, and auth fallback pattern all follow existing codebase conventions correctly.
extensions/xiaomi/index.ts Minimal addition of the register hook that calls api.registerSpeechProvider(buildMimoSpeechProvider()). Correctly follows the same pattern used by other speech-provider plugins.
extensions/xiaomi/openclaw.plugin.json Added contracts.speechProviders: ["mimo"] — correct intent, but the downstream generated file (bundled-plugin-metadata.generated.ts) was not regenerated, leaving the system's capability metadata stale and the CI check failing.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/xiaomi/openclaw.plugin.json
Line: 3-5

Comment:
**Generated metadata file not regenerated**

`openclaw.plugin.json` was updated to add `contracts.speechProviders: ["mimo"]`, but the auto-generated file `src/plugins/bundled-plugin-metadata.generated.ts` was not regenerated. The xiaomi entry in that file still has no `contracts` key.

This has two concrete consequences:

1. `BUNDLED_SPEECH_PLUGIN_IDS` (computed from the generated file in `src/plugins/bundled-capability-metadata.ts:61`) will not include `"xiaomi"`, so the system has no record that the xiaomi plugin contributes a speech provider.
2. The `pnpm check:bundled-plugin-metadata` CI step (which runs `node scripts/generate-bundled-plugin-metadata.mjs --check`) will fail because the generated file no longer matches the actual plugin JSON on disk.

Run `node scripts/generate-bundled-plugin-metadata.mjs` from the repo root to regenerate the file and commit the result.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (2): Last reviewed commit: "fix: correct plugin manifest contracts a..." | Re-trigger Greptile

Comment thread extensions/xiaomi/speech-provider.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 360f47083c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/xiaomi/openclaw.plugin.json Outdated
Comment thread extensions/xiaomi/speech-provider.ts Outdated
@zoujiejun
zoujiejun marked this pull request as ready for review March 27, 2026 07:34
Comment thread extensions/xiaomi/openclaw.plugin.json

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e2982773f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/xiaomi/speech-provider.ts Outdated
zoujiejun and others added 6 commits March 30, 2026 19:22
Add MiMo-V2-TTS support as a new speech synthesis provider in the
existing Xiaomi extension. MiMo TTS uses a non-standard endpoint
(/v1/chat/completions with audio field) and authenticates via api-key
header instead of Bearer token.

Features:
- Natural language style control via <style> tags
- Three voices: mimo_default, default_zh, default_en
- Support for dialects, role-playing, and singing synthesis
- Currently free (no API cost)

Configuration:
  messages.tts.provider: "mimo"
  messages.tts.providers.mimo.apiKey: "sk-xxx"
  Or set MIMO_API_KEY environment variable.

Closes openclaw#52376
- voiceCompatible: false for WAV output (not in allowed voice-note formats)
- regenerate bundled-plugin-metadata with speechProviders contract
MiMo TTS supports wav, mp3, pcm, pcm16 formats.
Switch from wav to mp3:
- MP3 is compatible with OpenClaw voice-note channels (Feishu, Telegram)
- WAV caused voiceCompatible issues per src/media/audio.ts
- MP3 is ~8x smaller (19KB vs 150KB for similar text)
MiMo TTS and text models share the same API platform.
TTS provider now falls back to XIAOMI_API_KEY so users
only need one key for both text inference and speech synthesis.
@zoujiejun
zoujiejun force-pushed the feat/mimo-tts-provider branch from bd74745 to 15437c2 Compare March 30, 2026 11:39

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15437c22ec

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +117 to +121
aliases: ["xiaomi", "mimo"],
models: MIMO_TTS_MODELS,

isConfigured: ({ providerConfig }) =>
Boolean(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Normalize Xiaomi alias-backed TTS config lookup

This provider advertises xiaomi as an alias, but it does not normalize alias config keys to the canonical mimo id. In extensions/speech-core/src/tts.ts (resolveRawProviderConfig), TTS settings are resolved by canonical provider id, so messages.tts.providers.xiaomi.* is ignored and only messages.tts.providers.mimo.* is read; users who select provider: "xiaomi" and configure providers.xiaomi.apiKey will still hit not configured / MiMo API key missing unless an env var is present. Please add alias-aware resolveConfig handling (or remove the alias) so alias selection and config paths stay consistent.

Useful? React with 👍 / 👎.

@steipete

Copy link
Copy Markdown
Contributor

Deep review against current main (5163a2f): feature is valid, but this PR needs work before land.

Positive evidence:

  • Current main has Xiaomi as a model provider only; no Xiaomi/MiMo speech provider is registered.
  • I live-tested with XIAOMI_API_KEY from .profile: POST https://api.xiaomimimo.com/v1/chat/completions with api-key auth, model: "mimo-v2-tts", and MP3 audio settings returned HTTP 200 with base64 audio.
  • The PR's single-assistant-message payload returned audio in the live probe. The issue's modalities: ["text", "audio"] + user/empty-assistant shape also returned audio.

Blockers:

  1. CI is red on this head (checks-fast-extensions, multiple node test shards, Windows shards). Relevant enough that this needs a rebase/current green run before merge.
  2. Generated bundled plugin metadata is stale after adding contracts.speechProviders: ["mimo"]; this breaks the capability metadata path and the generated metadata check.
  3. No docs/changelog. Adding a public TTS provider needs docs/tools/tts.md, docs/providers/xiaomi.md, and a changelog entry.
  4. No focused provider tests are in the diff. Please add tests for request shape, auth fallback (messages.tts.providers.mimo.apiKey -> MIMO_API_KEY/XIAOMI_API_KEY), error handling, base64 decode, outputFormat/fileExtension, and voice listing.
  5. Consider accepting/documenting the explicit modalities: ["text", "audio"] request shape even though the current API accepted the shorter payload in my live probe. It is clearer and matches the confirmed working example in Feature Request: Add Xiaomi MiMo-V2-TTS as a native TTS provider #52376.

So: correct feature, API verified live, not solved on main yet.

@steipete

Copy link
Copy Markdown
Contributor

Superseded by the implementation landed on main in ec8dbc4 (feat(tts): add xiaomi mimo speech provider).

I kept the feature from this PR, but rebuilt it with the missing maintainer pieces:

  • Provider id is xiaomi with mimo as an alias, matching the existing bundled Xiaomi plugin/provider naming.
  • The provider is Xiaomi-owned and declared in contracts.speechProviders.
  • Request shape follows Xiaomi's documented TTS contract: target text in an assistant message, optional style as a user message, api-key auth, and audio: { format, voice }.
  • Normal output is MP3/WAV; voice-note targets transcode to 48 kHz Opus with ffmpeg.
  • Added focused unit tests, live .profile tests, docs, and changelog.

Verification on the landed code:

  • pnpm check:changed
  • pnpm build
  • Xiaomi/MiniMax live TTS: 2 files / 5 tests passed with .profile keys.
  • Broader speech live sweep: OpenAI, ElevenLabs, Deepgram, Google, Gradium, and xAI live files: 6 files / 15 tests passed.

Closing this PR as superseded by the landed mainline fix. Thanks for pushing the Xiaomi TTS gap forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add Xiaomi MiMo-V2-TTS as a native TTS provider

2 participants