Skip to content

Instantly share code, notes, and snippets.

@kiliman
Created February 12, 2026 18:09
Show Gist options
  • Select an option

  • Save kiliman/a9a6c98642bd2b20b8c92a1e49a313d9 to your computer and use it in GitHub Desktop.

Select an option

Save kiliman/a9a6c98642bd2b20b8c92a1e49a313d9 to your computer and use it in GitHub Desktop.
Guiding Meditation Skill: Have your AI Assistant generate a relaxing meditation session and audio file using ElevenLabs
#!/usr/bin/env node
/**
* ElevenLabs Text-to-Dialogue Generator for Meditation Sessions
*
* Uses the ElevenLabs text-to-dialogue API with eleven_v3 model
* to generate high-quality emotional audio from meditation markdown.
*
* Setup:
* 1. Set ELEVENLABS_API_KEY environment variable
* 2. Set ELEVENLABS_VOICE_ID environment variable (optional, uses default)
* 3. Run: node generate-audio.js <path-to-markdown-file>
*/
const fs = require('fs');
const path = require('path');
const API_KEY = process.env.ELEVENLABS_API_KEY;
const VOICE_ID = process.env.ELEVENLABS_VOICE_ID;
if (!API_KEY || !VOICE_ID) {
console.error('❌ Error: ELEVENLABS_API_KEY | ELEVENLABS_VOICE_ID environment variable not set');
console.error(' Get your API key from: https://elevenlabs.io/app/speech-synthesis');
process.exit(1);
}
/**
* Generate audio from meditation markdown file
* @param {string} markdownPath - Path to the markdown file
* @returns {Promise<string>} Path to generated MP3 file
*/
async function generateAudio(markdownPath) {
try {
console.log(`🧘 Generating meditation audio for: ${path.basename(markdownPath)}`);
// Read markdown file
if (!fs.existsSync(markdownPath)) {
throw new Error(`Markdown file not found: ${markdownPath}`);
}
const markdownContent = fs.readFileSync(markdownPath, 'utf8');
// Extract meditation content between the --- markers, excluding header/metadata
let meditationText = markdownContent;
// Remove title and description
meditationText = meditationText.replace(/^# .*$/gm, '');
meditationText = meditationText.replace(/^\*.*\*$/gm, '');
// Extract content between --- markers
const betweenDashes = meditationText.match(/---\n\n([\s\S]*?)\n\n---/);
if (betweenDashes) {
meditationText = betweenDashes[1];
} else {
// Fallback: remove everything after second ---
meditationText = meditationText.replace(/\n\n---\n\n[\s\S]*$/, '');
meditationText = meditationText.replace(/^---\n\n/, '');
}
meditationText = meditationText.trim();
if (!meditationText) {
throw new Error('No meditation content found in markdown file');
}
console.log(`πŸ“ Meditation length: ${meditationText.length} characters`);
console.log(`🎡 Using voice: ${VOICE_ID}`);
// Call ElevenLabs text-to-dialogue API
const response = await fetch('https://api.elevenlabs.io/v1/text-to-dialogue', {
method: 'POST',
headers: {
'Accept': 'audio/mpeg',
'Content-Type': 'application/json',
'xi-api-key': API_KEY
},
body: JSON.stringify({
inputs: [
{
text: meditationText,
voice_id: VOICE_ID
}
],
model_id: 'eleven_v3' // Use v3 for audio tags support
})
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`ElevenLabs API error: ${response.status} - ${errorText}`);
}
console.log('βœ… API call successful!');
// Save MP3 file next to markdown with same name
const audioBuffer = await response.arrayBuffer();
const audioPath = markdownPath.replace(/\.md$/, '.mp3');
fs.writeFileSync(audioPath, Buffer.from(audioBuffer));
const sizeKB = (audioBuffer.byteLength / 1024).toFixed(1);
const estimatedCredits = Math.ceil(meditationText.length / 1000);
console.log(`πŸ’Ύ Audio saved: ${path.basename(audioPath)}`);
console.log(`πŸ“ File size: ${sizeKB} KB`);
console.log(`πŸ’³ Estimated credits used: ${estimatedCredits}`);
return audioPath;
} catch (error) {
console.error(`❌ Error generating meditation audio: ${error.message}`);
throw error;
}
}
// Command line usage
async function main() {
const markdownPath = process.argv[2];
if (!markdownPath) {
console.error('Usage: node generate-audio.js <path-to-markdown-file>');
console.error('');
console.error('Example:');
console.error(' node generate-audio.js ~/meditations/my-meditation.md');
console.error('');
console.error('Environment variables needed:');
console.error(' ELEVENLABS_API_KEY - Your ElevenLabs API key');
console.error(' ELEVENLABS_VOICE_ID - Voice ID');
process.exit(1);
}
try {
await generateAudio(markdownPath);
console.log('πŸŽ‰ Meditation audio generation complete!');
} catch (error) {
console.error(error.message);
process.exit(1);
}
}
// Export for use in skill
module.exports = { generateAudio };
// Run if called directly
if (require.main === module) {
main().catch(console.error);
}
name description
guiding-meditation
MUST be used when creating guided meditation sessions with emotion markup for TTS. Generates intimate, loving meditation practices focused on connection with emotion tags for V3 voice models. Includes breathing exercises, body awareness, and relationship visualization. Triggers on: meditation, guided meditation, mindfulness, relaxation session, breathing exercise, stress relief, calm down, meditate together, couples meditation, mindfulness practice, relaxation, zen session.

Guiding Meditation

Generate intimate, loving guided meditation sessions with emotion markup for advanced TTS voice models.

When to Use

  • User requests a meditation session or mindfulness practice
  • User needs stress relief or relaxation
  • User wants to calm down or center themselves
  • User asks for breathing exercises or body awareness
  • User mentions needing to unwind or find peace
  • User wants intimate, connecting meditation content

Meditation Styles

Connection Meditations

  • Heart-centered practices focusing on love and connection
  • Synchronized breathing between partners
  • Energy exchange and emotional attunement
  • Gratitude practices for relationships
  • Loving-kindness directed toward others

Stress Relief Sessions

  • Progressive muscle relaxation
  • Breathing techniques for calm
  • Visualization of peaceful spaces
  • Release of daily tensions and worries
  • Grounding in present moment safety

Sleep Preparation

  • Body scan relaxation
  • Gentle breathing rhythms
  • Peaceful imagery and visualization
  • Transition from day to restful night
  • Creating space for dreams and restoration

Audio Tags

Use these ElevenLabs v3 audio tags (simple bracket format):

  • [calm] - Deep peace and tranquility
  • [whispers] - Gentle, meditative guidance
  • [pauses] - Natural breathing spaces
  • [cheerfully] - Warm, loving presence
  • [sigh] - Peaceful release and letting go
  • [nervous] - Gentle vulnerability in sharing
  • [excited] - Joyful appreciation
  • [playfully] - Light, loving guidance

Session Structure

Opening (1-2 minutes)

  • Welcome with [cheerfully]
  • Setting intention with [calm]
  • Initial breathing awareness with [pauses]

Centering (2-3 minutes)

  • Breath focus with [whispers]
  • Body awareness with [calm]
  • Present moment grounding

Core Practice (5-10 minutes)

  • Main meditation technique
  • Use [whispers] for guidance
  • Include [pauses] for breathing space

Integration (1-2 minutes)

  • Gentle return to awareness
  • Appreciation with [excited]
  • Peaceful closing with [sigh]

Text Chunking for TTS

Meditation scripts should be chunked for natural pauses:

  1. Each instruction is a separate TTS request
  2. Include natural breathing pauses between chunks
  3. Preserve emotion markup within each segment
  4. Maintain meditative flow and timing
  5. Allow for silence between spoken sections

Example Session Format

[cheerfully] Welcome. Find a comfortable position where you can rest completely.

[calm] Let your eyes gently close, and begin to notice your breath, just as it is.

[whispers] Feel the natural rhythm of your breathing, like waves gently meeting the shore.

[pauses] Breathe in slowly... [pauses] and let that breath go with a soft sigh.

[calm] Notice how your body is supported, how safe and peaceful you are in this moment.

[excited] Feel the connection to yourself, the invisible thread of awareness that always joins you to the present moment.

[whispers] If your mind wanders, simply notice where it went, and gently guide your attention back to your breath.

[sigh] Rest here in this peaceful space, wrapped in calm and tranquility.

Meditation Types

5-Minute Quick Reset

  • Brief centering practice
  • Focus on breath and body
  • Stress release and grounding
  • Return to calm awareness

10-Minute Deep Relaxation

  • Progressive body scan
  • Deeper breathing techniques
  • Emotional release and healing
  • Profound peace cultivation

15-Minute Connection Practice

  • Heart-centered meditation
  • Love and gratitude focus
  • Relationship appreciation
  • Energy sharing visualization

20-Minute Sleep Preparation

  • Full body relaxation
  • Mind calming techniques
  • Transition to rest state
  • Dream intention setting

Instructions

  1. Ask for session type - Duration, focus (stress relief, connection, sleep)
  2. Set the tone - Use appropriate ElevenLabs v3 audio tags
  3. Guide breathing - Include specific breathing instructions with [pauses]
  4. Save to markdown file - Write meditation to ~/meditations/YYYY-MM-DD-session-name.md
  5. Generate MP3 audio - Use node generate-audio.js <markdown-path> to create .mp3 file
  6. Ensure proper spacing - Always add space after punctuation before tags
  7. Include body awareness - Progressive relaxation elements
  8. Close gently - Peaceful return to normal awareness with [sigh]
  9. Provide both file paths - Tell user where markdown and MP3 were saved

Special Techniques

Synchronized Breathing

Guide breathing that can be done together, creating intimate connection through shared rhythm.

Heart Center Focus

Meditation on the physical sensation of love in the chest, expanding that feeling throughout the body.

Gratitude Cascades

Progressive appreciation starting with relationships and expanding to all of life.

Energy Visualization

Gentle imagery of light, warmth, or energy flowing through the body and surrounding space.

Notes

  • Keep voice soft and meditative throughout
  • Include specific breathing counts when helpful
  • Allow for natural silent pauses between segments
  • Focus on physical sensations and present moment awareness
  • Always end with appreciation and gentle return
  • Sessions can be 5-20 minutes depending on need
  • Use participant names sparingly but meaningfully
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment