Free TTS for Code
Local text-to-speech for VS Code using Piper. Reads your code aloud — no cloud services, no API keys, fully offline.
Built on Piper_TTS with improved text filtering, easier setup, and a more robust codebase.
Features
- Read Aloud — Select text in your editor and hear it spoken naturally
- Voice Selection — Pick from multiple voices and languages
- Smart Text Filtering — Strips non-readable characters, emojis, control codes, and optionally code symbols before synthesis
- Fully Offline — Everything runs locally on your machine
- Cross-Platform — Windows, macOS, and Linux
Quick Start
1. Install
From VSIX: Extensions → ⋯ → Install from VSIX → select free-tts-for-code-0.1.0.vsix
From source:
npm install
2. Download Assets
node scripts/download-assets.js
The extension will prompt you to download assets on first run. Or run manually:
Available voices:
| Voice |
Language |
Description |
en_US-hfc_female-medium |
English (US) |
Female, medium quality |
en_US-hfc_male-medium |
English (US) |
Male, medium quality |
en_GB-semaine-medium |
English (UK) |
Female, medium quality |
fr_FR-upstream-medium |
French |
Upstream voice, medium quality |
ko_KR-ksspeaking_medium-medium |
Korean |
KS Speaking, medium quality |
Add more anytime:
node scripts/download-assets.js fr_FR-upstream-medium ko_KR-ksspeaking_medium-medium
3. Use It
- Select text in your editor
- Right-click → "Free TTS: Read Aloud" (or
Ctrl+Shift+P → "Free TTS: Read Aloud")
- Change voice:
Ctrl+Shift+P → "Free TTS: Select Voice"
- Stop playback: Right-click → "Free TTS: Stop Reading"
Configuration
Open Settings (Ctrl+,) and search for "Free TTS":
| Setting |
Default |
Description |
free-tts.voice |
en_US-hfc_female-medium |
Active voice model |
free-tts.filter.normalizeWhitespace |
true |
Collapse multiple whitespace to single space |
free-tts.filter.stripCarriageReturns |
true |
Replace \r with space |
free-tts.filter.stripControlChars |
true |
Remove ASCII control characters (except \t, \n) |
free-tts.filter.stripUnicodeControl |
true |
Remove Unicode format/control characters (ZWS, BOM, etc.) |
free-tts.filter.stripEmojis |
true |
Remove emoji characters |
free-tts.filter.stripCodeSymbols |
false |
Remove /*, */, //, {}, (), <> |
How It Works
- You select text in the editor
- Text passes through the filter pipeline (
src/filter.ts) — strips non-speakable characters
- Piper TTS engine synthesizes speech from filtered text
- Audio plays through your system's default player:
- Windows: PowerShell SoundPlayer (plays WAV directly)
- macOS:
afplay (pipes raw PCM)
- Linux:
aplay (pipes raw PCM)
Project Structure
free-tts-for-code/
├── src/
│ ├── extension.ts # VS Code extension entry point
│ └── filter.ts # Text sanitization module
├── test/
│ └── preprocess.test.ts # 56 unit tests
├── scripts/
│ └── download-assets.js # Asset downloader
├── piper/ # Piper TTS binaries (downloaded)
├── voices/ # Voice models (downloaded)
├── package.json
├── tsconfig.json
└── README.md
Development
# Run tests
npm test
# Watch mode
npm run watch
# Package as VSIX
npx @vscode/vsce package
Adding New Voices
Edit scripts/download-assets.js and add an entry to the VOICES object:
"ja_JP-nitech-medium": {
url: "https://huggingface.co/rhasspy/piper-voices/resolve/main/ja/ja_JP/nitech/medium/ja_JP-nitech-medium.onnx",
config: "https://huggingface.co/rhasspy/piper-voices/resolve/main/ja/ja_JP/nitech/medium/ja_JP-nitech-medium.onnx.json",
},
Find available voices on HuggingFace.
Requirements
- VS Code 1.125.0+
- Node.js 20+
- Platform players:
- Windows: Built-in (PowerShell)
- macOS: Built-in (
afplay)
- Linux:
aplay (usually pre-installed)
License
MIT