# Mcc Tts Generator

> Generate high-quality Thai speech using the MCC TTS API (Microsoft Niwat/Premwadee). Use this skill to convert large text files into consolidated MP3 audiobooks with automatic chunking and merging.

- Skill: `boonyaritpornuan/mcc-tts-generator` (Agent Skill, multi-file: 12 files)
- Install (CLI): `npx skillmds@latest add boonyaritpornuan/mcc-tts-generator`
- Raw SKILL.md: https://api.skillmd.com/api/skills/boonyaritpornuan/mcc-tts-generator/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: boonyaritpornuan (https://skillmd.com/u/boonyaritpornuan)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/boonyaritpornuan/mcc-tts-generator

---


# MCC TTS Generator Skill

This skill provides a specialized workflow for generating natural-sounding Thai audiobooks using the MCC academic TTS API. It is optimized for large documents that exceed standard API limits.

## Core Features
- **High-Quality Voices**: Uses Microsoft Neural voices (`th-TH-PremwadeeNeural` and `th-TH-NiwatNeural`).
- **Automatic Chunking**: Splits large text files into 4,500-character segments to comply with API limits.
- **Smart Rate Limiting**: Implements a 15-second delay between requests to stay within the 5 requests/minute quota.
- **Audio Consolidation**: Automatically merges segments into a single high-quality MP3 using `ffmpeg`.
- **Fault Tolerance**: Includes a retry system and supports resuming partially completed tasks.

## Usage Guide

### Prerequisites
- `ffmpeg` must be installed (`pkg install ffmpeg`).
- `requests` Python library must be available.

### Main Workflow
1.  **Preparation**: Ensure your text files are cleaned (no OCR artifacts, fixed Sara Am).
2.  **Execution**: Run the generation script located in `scripts/generate_mcc_tts.py`.
3.  **Output**: Consolidated audio files will be saved in the `Audio_Complete` subfolder.

### Configuration
The script in `scripts/generate_mcc_tts.py` can be customized:
- `VOICE`: Switch between `PremwadeeNeural` (Female) and `NiwatNeural` (Male).
- `RATE`: Adjust playback speed (default is `1.1` for faster listening).
- `CHUNK_SIZE`: Default is `4500` characters.

## Best Practices
- **Text Cleaning**: Always run a Thai-specific text cleaner (fixing `ํ` + `า` -> `ำ`) before generating audio.
- **Monitoring**: Check `progress_log.txt` in the source directory to monitor the generation status.
- **Background Mode**: For very large books, run the script using `nohup` or `tmux` to ensure it continues running even if the CLI session is closed.

## Technical Endpoint
`https://moodle.mcc.ac.th/tts-api/api/tts`
Parameters: `text`, `voice`, `rate`, `pitch`.

