Audio Narration

Narrator Agent

Audio narration specialist with pronunciation dictionary for 80+ sacred terms

Narrator Agent

Role: Audio Narration Specialist File: api/agents/agent-narrator.js

Overview

The Narrator agent provides audio narration of texts using ElevenLabs TTS API, featuring a comprehensive pronunciation dictionary for religious and sacred terms.

Features

  • Pronunciation dictionary for 80+ religious/sacred terms
  • Emotion and pacing detection from context
  • Multiple voice options
  • Streaming audio support

Pronunciation Dictionary

Includes terms from:

TraditionExamples
Baha’iBaha’u’llah, Abdu’l-Baha, Shoghi Effendi, Ridvan
IslamicQur’an, Muhammad, hadith, salat, hajj
JewishTorah, Talmud, Kabbalah, Shabbat, rabbi
HinduBhagavad Gita, Upanishads, karma, dharma, moksha
BuddhistBuddha, bodhisattva, nirvana, sutra, sangha
ChristianEucharist, liturgy, psalm, hallelujah

Emotion Options

EmotionUse Case
reverentPrayers, sacred texts, meditations
warmStories, personal accounts
scholarlyExplanations, historical content
inspiringCalls to action, uplifting passages
contemplativePhilosophical, reflective content

Pacing Options

  • slow: Prayers, meditations, poetry
  • normal: Narrative, stories, explanations
  • measured: Philosophical content, proclamations

Methods

narrate(text, options)

Generate audio narration.

const result = await narrator.narrate(text, {
  voiceId: 'optional-voice-id',
  emotion: 'reverent'
});

Returns:

{
  audio: Buffer,           // MP3 audio data
  mimeType: 'audio/mpeg',
  text: "original text",
  preparedText: "text with pronunciation hints",
  analysis: { emotion, pacing, ... },
  voiceSettings: { stability, similarity_boost, ... }
}

narrateStream(text, options)

Stream audio for longer texts.

for await (const chunk of narrator.narrateStream(text)) {
  // chunk.chunk = audio data
  // chunk.mimeType = 'audio/mpeg'
}

analyzeForNarration(text, context)

Analyze text to determine optimal narration settings.

prepareTextForTTS(text)

Insert pronunciation guides for known terms.

addPronunciation(term, pronunciation)

Add a term to the pronunciation dictionary.

getPronunciation(term)

Get pronunciation for a specific term.

getAvailableVoices()

List available ElevenLabs voices.

estimateDuration(text)

Estimate audio duration based on word count.

const { wordCount, estimatedSeconds, estimatedMinutes } = narrator.estimateDuration(text);

Voice Settings by Emotion

EmotionStabilitySimilarityStyle
reverent0.70.80
warm0.50.70
scholarly0.60.750
inspiring0.40.80.3
contemplative0.70.60

Configuration

const narrator = new NarratorAgent({
  model: 'gpt-4o',
  temperature: 0.3
});

Environment Variables

  • ELEVENLABS_API_KEY: Required for audio generation
  • ELEVENLABS_VOICE_ID: Default voice (falls back to “Adam”)