Mimo TTS Markdown Reader
Read aloud editor documents using the MiMo LLM Text-to-Speech API (v2.5). Supports Markdown and plain text with Director Mode for fine-grained voice control.
Features
- 📖 One-click reading: Command palette
MiMo: Read Current Document or right-click in editor
- ✂️ Selection reading: Read only the selected text, or the entire document if nothing is selected
- ⏯️ Full playback control: Start / Pause / Resume / Stop at any time
- 🎬 Director Mode: Auto-inject style tags with semantic enhancement for Markdown structures
- 📊 Status bar indicator: Real-time display of playing (with progress) / paused / stopped
- 📑 Long document splitting: Automatically split by sentence boundaries, synthesize and play in order
- 🔌 Extensible architecture: TTS service abstracted as an interface for easy integration with other providers
Getting Started
Open VS Code Settings, search for mimoTts, and fill in:
| Setting |
Description |
Default |
mimoTts.apiKey |
Required MiMo API Key/Token |
"" |
mimoTts.apiUrl |
API endpoint URL |
Official URL |
mimoTts.defaultStyle |
Default speaking style |
"narration" |
mimoTts.directorMode |
Enable Director Mode |
true |
mimoTts.bracketStyle |
Tag bracket style (half/full/square) |
"half" |
mimoTts.maxSegmentChars |
Max characters per segment |
200 |
mimoTts.requestTimeoutMs |
Request timeout (ms) |
30000 |
mimoTts.headingStyle |
Heading additional style |
"emphasis" |
mimoTts.quoteStyle |
Blockquote additional style |
"calm quote" |
mimoTts.listPauseStyle |
List pause style |
"pause" |
mimoTts.retryOnError |
Retry on failure |
true |
mimoTts.audioFormat |
Audio format |
"mp3" |
mimoTts.customPlayerPath |
Custom player path |
"" |
2. Commands
| Command |
Shortcut (Win/Mac) |
Description |
MiMo: Read Current Document |
Ctrl+Alt+R / Cmd+Alt+R |
Read current document |
MiMo: Pause Reading |
Ctrl+Alt+P / Cmd+Alt+P |
Pause |
MiMo: Resume Reading |
Ctrl+Alt+E / Cmd+Alt+E |
Resume |
MiMo: Stop Reading |
Ctrl+Alt+S / Cmd+Alt+S |
Stop |
You can also right-click in the editor and select "Read This Document".
Architecture
src/
├── extension.ts # Entry point: activate/deactivate, command registration, config listener
├── types.ts # Type definitions: ITtsService interface, PlaybackState, TtsConfig
├── configManager.ts # Configuration reader (supports hot-reload)
├── preprocessor.ts # Director Mode text preprocessing: Markdown semantic recognition + style tag injection + segmentation
├── ttsClient.ts # MiMo TTS v2.5 API client (ITtsService implementation)
├── audioPlayer.ts # Audio player: temp files + system player
├── playbackController.ts # Playback controller: state machine + segment queue + cursor management
├── statusBar.ts # Status bar indicator
└── test/ # Unit tests
├── preprocessor.test.ts
├── ttsClient.test.ts
└── runTest.ts
Module Dependencies
extension.ts (entry/commands)
│
▼
PlaybackController (state machine + queue + status bar)
│ │
▼ ▼
preprocessor MiMoTtsClient (ITtsService)
(text→tags) (HTTP requests)
│
▼
AudioPlayer (temp files + system player)
Design Highlights
- TTS Service Abstraction: The
ITtsService interface isolates vendor differences. The controller layer is independent of any specific implementation. Adding other TTS providers only requires a new implementation class.
- State Machine:
idle → playing → paused → playing → stopped. Pause uses "stop current segment + record cursor" semantics.
- Segmentation Strategy: Split by sentence endings/newlines, 1–4 sentences per segment, aligned with MiMo Director Mode guidelines.
Director Mode
MiMo TTS v2.5 Director Mode Specification
- Style tags are placed at the beginning of the text in the format:
(style1 style2)content to synthesize
- Style tags are placed in the
messages[role=assistant].content field
- Each segment should contain 1–4 sentences for clear semantics
- Supported delimiters: half-width
(), full-width (), square brackets []
Markdown Structure Recognition
The plugin recognizes Markdown structures line by line and automatically adds style tags:
| Markdown Structure |
Additional Style |
# Heading |
emphasis (configurable via mimoTts.headingStyle) |
> Blockquote |
calm quote (configurable via mimoTts.quoteStyle) |
- * 1. List item |
pause (configurable via mimoTts.listPauseStyle) |
| Plain text |
Default style only |
Usage Example
# MiMo TTS Plugin Guide
This plugin can read aloud document content in the current editor.
> Text-to-speech makes document proofreading more efficient.
- Supports full document reading
- Supports selection reading
- Supports pause and resume
After Director Mode Preprocessing (content in synthesis request)
Assuming config: defaultStyle = "narration", bracketStyle = "half"
Segment 1: (narration emphasis)MiMo TTS Plugin Guide
Segment 2: (narration)This plugin can read aloud document content in the current editor.
Segment 3: (narration calm quote)Text-to-speech makes document proofreading more efficient.
Segment 4: (narration pause)Supports full document reading
Segment 5: (narration pause)Supports selection reading
Segment 6: (narration pause)Supports pause and resume
Each segment is sent as an independent messages[role=assistant].content for synthesis, and audio is played in sequence.
Development & Build
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Build bundle (esbuild)
npm run package
# Debug (open this project in VS Code, press F5 to launch Extension Development Host)
Potential Improvements
- Secure Key Storage: Currently the API Key is stored in VS Code Settings (plaintext). Can be migrated to
vscode.SecretStorage for encrypted storage.
- Streaming Playback: Currently uses batch requests + sequential playback. Can be changed to stream-and-play for lower first-segment latency.
- Multi-platform Player: macOS (
afplay) / Linux (xdg-open) branches are already prepared. Pause/stop control can be further improved.
- Other TTS Providers: Implement the
ITtsService interface to integrate other providers (e.g., Azure TTS, Alibaba Cloud TTS).
- Progress Jump: Currently can only resume from the current segment after pausing. Can add "go back one segment / go forward one segment" controls.
- Waveform Visualization: Integrate a Webview panel to display audio waveform and reading progress.
- Internationalization: Add i18n support.