3.4 KiB
3.4 KiB
NPC Voice Skill
Text-to-Speech for bringing NPCs and narration to life using ElevenLabs AI voices.
Quick Start
# Test it out
node .claude/skills/npc-voice/speak-npc.js \
--text "Hello, adventurer!" \
--voice merchant \
--npc "Shopkeeper"
Installation
-
Get API Key: Sign up at ElevenLabs and get your API key from settings
-
Configure: Copy
.env.exampleto.envand add your API key:cp .env.example .env # Edit .env and add: ELEVENLABS_API_KEY=your_key_here -
Install Dependencies:
cd .claude/skills/npc-voice && npm install
Usage
Basic Command
node .claude/skills/npc-voice/speak-npc.js \
--text "Your dialogue here" \
--voice <preset> \
--npc "Character Name"
Voice Presets
Run --list to see all available voices:
node .claude/skills/npc-voice/speak-npc.js --list
Popular Presets:
narrator- Storytelling, scene descriptionsmerchant- Friendly shopkeepervillain- Menacing antagonistwizard- Wise spellcasterwarrior- Gruff fightergoblin- Sneaky creaturedwarf- Deep, gruffelf- Elegant
Examples
D&D Session:
# DM narration
node .claude/skills/npc-voice/speak-npc.js \
--text "You enter a dimly lit tavern. The smell of ale and pipe smoke fills the air." \
--voice narrator
# NPC dialogue
node .claude/skills/npc-voice/speak-npc.js \
--text "Welcome to my shop! Looking for potions?" \
--voice merchant \
--npc "Albus the Alchemist"
# Villain monologue
node .claude/skills/npc-voice/speak-npc.js \
--text "You fools! You cannot stop me now!" \
--voice villain \
--npc "Dark Wizard Malakar"
How It Works
- Text Input: You provide dialogue/narration text
- Voice Selection: Choose from preset character voices
- AI Generation: ElevenLabs generates natural-sounding speech
- Auto-Play: Audio plays automatically through your system
- Cleanup: Temporary files are removed
Technical Details
- Model: ElevenLabs eleven_flash_v2_5
- Audio Format: MP3, 44.1kHz, 128kbps
- Audio Player:
- macOS:
afplay - Linux:
mpg123
- macOS:
- Dependencies:
@elevenlabs/elevenlabs-jsdotenv
Use Cases
- D&D/TTRPG: Voice NPCs and narrate scenes
- Storytelling: Read passages from books with character voices
- Content Creation: Generate voiceovers for videos/podcasts
- Accessibility: Convert text to speech for easier consumption
- Game Development: Prototype character voices
Files
speak-npc.js- Main TTS scriptskill.md- Skill documentation for Claudepackage.json- Node.js dependencies.env.example- Environment variable template.env- Your API key (git-ignored)
Troubleshooting
"API key not configured"
- Make sure
.envfile exists with validELEVENLABS_API_KEY
"Audio player exited with code 1"
- macOS:
afplayshould work by default - Linux: Install
mpg123withsudo apt install mpg123
"401 Unauthorized"
- Check your API key is correct and active
- Verify you have credits remaining in your ElevenLabs account
Cost
ElevenLabs pricing (as of 2024):
- Free tier: 10,000 characters/month
- Paid tiers: Starting at $5/month for 30,000 characters
Short NPC dialogues typically use 50-200 characters each.
Created by: Sahar Carmel License: MIT ElevenLabs: https://elevenlabs.io