A Next.js application that brings book characters to life through AI-powered voice conversations using ElevenLabs Conversational AI.
- Story Feed: Vertical scrolling feed of classic literature stories
- Character Selection: Choose from iconic characters across multiple books
- Live Voice Conversations: Have real-time voice conversations with characters
- Smart Voice Matching: Automatically selects appropriate voices based on character age and gender
- Character Personalities: Each character has unique personality traits and speaking styles
- Beautiful UI: Cinematic design with film grain effects and smooth animations
- Harry Potter (teenager, male)
- Hermione Granger (teenager, female)
- Albus Dumbledore (old, male)
- Elizabeth Bennet (young adult, female)
- Mr. Darcy (adult, male)
- Jay Gatsby (adult, male)
- Nick Carraway (young adult, male)
- Daisy Buchanan (young adult, female)
- Frodo Baggins (young adult, male)
- Gandalf the Grey (old, male)
- Aragorn (middle-aged, male)
- Alice (child, female)
- Mad Hatter (adult, male)
- Cheshire Cat (adult, neutral)
- Node.js 18+
- npm or yarn
- ElevenLabs API account
- Clone the repository:
git clone <repository-url>
cd bookly- Install dependencies:
npm install- Install ElevenLabs SDK:
npm install @elevenlabs/client- Set up environment variables:
Create a .env.local file in the root directory:
ELEVENLABS_API_KEY=your_elevenlabs_api_key_hereGet your API key from ElevenLabs Settings
Important: Use ELEVENLABS_API_KEY (server-side only, no NEXT_PUBLIC_ prefix) to keep your API key secure.
- Run the development server:
npm run dev- Open http://localhost:3000 in your browser
Characters are assigned voices based on their age and gender:
- Age categories: child, teenager, young-adult, adult, middle-aged, old
- Gender categories: male, female, neutral
The system automatically combines these to create a voice key (e.g., teenager-male, old-female) and maps it to an ElevenLabs voice ID.
Each character has:
- Age & Gender: Determines which voice to use
- Prompt: Defines the character's personality, background, and speaking style
- Introduction: The first message the character speaks when selected
Example:
{
name: 'Harry Potter',
age: 'teenager',
gender: 'male',
prompt: 'You are Harry Potter, the famous wizard...',
introduction: 'Hello there! I\'m Harry Potter...'
}- Character Selection: User scrolls through stories and taps a character
- Introduction: Character's introduction plays automatically
- Start Conversation: User clicks the character avatar to begin
- Live Chat: Real-time voice conversation using ElevenLabs AI
- End Session: Click avatar again or close button to end
Edit /src/data/stories.ts:
{
id: 'your-character',
name: 'Character Name',
avatar: 'avatar-url',
age: 'adult',
gender: 'female',
prompt: 'Character personality and background...',
introduction: 'First message the character will say...'
}Edit /src/config/voice-mapping.ts to use your own ElevenLabs voices:
'adult-female': {
voiceId: 'your-custom-voice-id',
name: 'Custom Voice Name',
description: 'Voice description'
}Find voices in the ElevenLabs Voice Library
bookly/
βββ src/
β βββ (story-feed)/
β β βββ story-feed.tsx # Main feed component
β β βββ story-card.tsx # Individual story card
β β βββ characters-carousel.tsx # Character selection
β β βββ voice-widget.tsx # Voice conversation UI
β β βββ nav-link.tsx # Navigation component
β βββ app/
β β βββ api/
β β β βββ conversation/
β β β β βββ token/route.ts # Get signed URL
β β β β βββ start/route.ts # Start session
β β β βββ tts/route.ts # Text-to-speech
β β βββ page.tsx # Home page
β β βββ layout.tsx # Root layout
β β βββ globals.css # Global styles
β βββ config/
β β βββ voice-mapping.ts # Voice ID mappings
β βββ data/
β β βββ stories.ts # Story and character data
β βββ hooks/
β β βββ use-mobile.ts # Mobile detection hook
β βββ utils/
β βββ utils.ts # Utility functions
βββ API_ARCHITECTURE.md # Backend API documentation
βββ ELEVENLABS_SETUP.md # Detailed ElevenLabs setup guide
βββ README.md # This file
- Framework: Next.js 16 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- Voice AI: ElevenLabs Conversational AI
- Icons: Lucide React
- State Management: React Hooks
Important: Each character needs an ElevenLabs agent configured before conversations will work.
See AGENT_SETUP_GUIDE.md for detailed instructions on:
- Creating agents in ElevenLabs dashboard
- Configuring voice, personality, and introduction
- Adding agent IDs to your characters
Without agent IDs, you'll see: "No agent ID configured for [Character]"
npm run ts # Type check
npm run lint # Lint codenpm run build
npm startSee ELEVENLABS_SETUP.md for detailed troubleshooting steps.
Common issues:
- No audio: Check microphone permissions in browser
- API errors: Verify API key in
.env.local - Connection fails: Check internet connection and API credits
This project is for educational purposes.
- Stories and characters are from classic literature
- Voice technology powered by ElevenLabs
- Avatar images from DiceBear
- Background images from Unsplash