Commit Graph

25 Commits

Author SHA1 Message Date
cdd8c0fc08 fix: Improve Piper TTS error handling and user messaging
- Added proper error handling for missing voice models in preview endpoint
- Return 404 with helpful message when Piper models not found
- Added user-friendly alert in frontend when preview fails
- Added prominent warning in UI when Piper is selected about manual setup
- Check for empty audio before returning to prevent decode errors

Users now get clear feedback when Piper voice models are missing
instead of cryptic 'media could not be decoded' errors.
2025-12-09 15:00:32 +00:00
d3e72edd7f fix: Update Piper TTS to support voice preview and improve setup
- Fixed preview endpoint to work with both Kokoro and Piper engines
- Improved voice model download with curl fallback and SSL handling
- Added better error messages when models are missing
- Created PIPER_SETUP.md with manual download instructions
- Added test_piper_direct.py for testing Piper installation
- Updated README with voice model download requirements

Note: Piper voice models require manual download from GitHub releases
due to HuggingFace URL structure. See PIPER_SETUP.md for instructions.
2025-12-09 14:56:48 +00:00
6f7330c491 docs: Add comprehensive Piper TTS integration documentation
- Created PIPER_TTS_INTEGRATION.md with complete integration summary
- Added test_engine_selection.py for testing engine switching
- Documented engine comparison, usage examples, and pitch guidelines
- Listed all modified/created files and git commits
- Included next steps for optional enhancements

Task 26 completed: Piper TTS integration with engine selection UI
2025-12-09 14:51:56 +00:00
bfdcc94b24 feat: Add Piper TTS integration with pitch control support
- Created PiperTTSService with pitch shifting (-12 to +12 semitones)
- Created UnifiedTTSService to manage multiple TTS engines
- Added engine selection endpoints (GET/POST /api/tts/engines)
- Added voices listing endpoint (GET /api/tts/voices)
- Added pitch_adjustments parameter to TTS generation
- Created install_piper.sh for easy Piper installation
- Updated backend README with multi-engine documentation
- Created comprehensive PIPER_TTS_GUIDE.md
- Added TTS_ENGINE environment variable for engine selection
- Updated requirements.txt with piper-tts and pydub

This allows users to choose between Kokoro (high quality) and Piper
(fast with pitch control) TTS engines at runtime.
2025-12-09 14:45:18 +00:00
69eb0b3507 Add voice preview and age category modifiers
Features:
- Voice preview button to test voices before generation
- Age category selection (young, teen, adult, old)
- Age categories adjust voice speed automatically:
  - Young: 1.15x (faster, energetic)
  - Teen: 1.08x (slightly faster)
  - Adult: 1.0x (normal)
  - Old: 0.85x (slower, measured)
- Preview caching to avoid regenerating same voice
- Backend /api/tts/preview endpoint for voice samples
- Frontend previewVoice API function

This allows users to hear how each voice sounds and adjust
character ages to make them sound younger or older.
2025-12-09 14:17:58 +00:00
706ada866c feat: modernize UI with gradient design, glass morphism, and enhanced visual appeal
- Add purple/indigo gradient background throughout app
- Implement glass morphism effects on all cards
- Add gradient buttons with smooth hover animations
- Integrate emoji icons for better visual communication
- Enhance typography with improved font stack
- Add loading spinners and smooth transitions
- Improve color scheme with modern purple/indigo palette
- Add glowing shadows and depth effects
- Maintain responsive design and touch-friendly interactions
2025-12-09 12:29:40 +00:00
63bdf57593 fix: Improve Ollama prompt to always detect Narrator role
Updated the speaker detection prompt to explicitly instruct the AI to:
- Identify narrative text and assign it to 'Narrator'
- Detect character dialogue and list character names
- Include BOTH Narrator and characters when story has mixed content

This ensures stories with narrative descriptions get proper voice
assignments for both the narrator and speaking characters.

Example: Story with 'Once upon a time...' narrative and dialogue from
Lily, Benny, Sammy now correctly detects all 4 roles.
2025-12-09 12:26:15 +00:00
cea97d3cd4 Task 19: Update TTS generation endpoint to accept edited scripts
- Modified TTSRequest to accept optional segments array
- Updated generate_audiobook endpoint to use segments if provided
- Added generate_audiobook_from_segments method to TTSService
- Ensured backward compatibility with text-based generation
- Added comprehensive tests for segment-based generation
- All tests passing (7/7)

Requirements: 15.7
2025-12-09 11:46:10 +00:00
e2196c592a Implement script generation endpoint (Task 18)
- Added ScriptRequest, ScriptResponse, and ScriptSegment Pydantic models
- Created /api/tts/script POST endpoint in main.py
- Integrated with TTSService to generate script segments using AI
- Added generate_script_segments method to TTSService
- Returns segments with unique IDs for frontend tracking
- Handles errors gracefully when AI segmentation fails
- Falls back to pattern-based segmentation when Ollama unavailable
- Added comprehensive tests for the endpoint
- Validates: Requirements 15.1, 15.2
2025-12-09 11:43:04 +00:00
1c495079eb First Push 2025-12-09 11:17:24 +00:00
5c7b339bdf Add all 54 Kokoro TTS voices and 9 language support
- Expanded from 8 to 54 voices across 9 languages
- American English: 21 voices (11 female, 10 male)
- British English: 8 voices (4 female, 4 male)
- Spanish: 3 voices (1 female, 2 male)
- French: 1 voice (1 female)
- Hindi: 4 voices (2 female, 2 male)
- Italian: 2 voices (1 female, 1 male)
- Japanese: 5 voices (4 female, 1 male)
- Portuguese: 3 voices (1 female, 2 male)
- Chinese: 7 voices (4 female, 4 male)
- Updated backend to support all language codes (a,b,e,f,h,i,j,p,z)
- Added comprehensive voice documentation
2025-12-09 11:14:28 +00:00
e3dcb89bb7 Add comprehensive end-to-end test for AI-powered audiobook generation
- Tests complete workflow from unmarked text to segmented audio
- Demonstrates AI role detection on narrative text
- Shows AI text segmentation with intelligent speaker assignment
- Validates dialogue detection and speaker distribution
- Provides quality analysis of segmentation results
2025-12-09 11:02:53 +00:00
4180527821 Update documentation for AI-powered features
- Added comprehensive documentation for AI speaker detection
- Documented AI text segmentation capabilities
- Added Ollama setup instructions
- Explained benefits of AI-powered vs pattern-based detection
- Updated API endpoint documentation with AI feature details
2025-12-09 11:00:57 +00:00
d18fddef57 Add AI-powered text segmentation for intelligent speaker assignment
- Added segment_text() method to OllamaService for AI-based text splitting
- OllamaService now annotates each text segment with the appropriate speaker
- Updated TTSService to use AI segmentation when available
- Falls back to pattern-based segmentation when Ollama unavailable
- AI intelligently assigns dialogue to speakers and narrative to Narrator
- Added comprehensive test suite for AI segmentation
- Verified AI correctly splits unmarked dialogue between multiple speakers

This makes the tool much more powerful - users can now input plain narrative
text without explicit role markers and the AI will intelligently assign voices
to different characters and the narrator.
2025-12-09 10:59:00 +00:00
b48e53ce63 Fix Ollama model name to use llama3:latest instead of llama3:8b
- Changed model from 'llama3:8b' to 'llama3:latest' to match available models
- Verified Ollama integration is working correctly
- AI detection now successfully identifies speakers in unmarked text
2025-12-09 10:54:05 +00:00
f56f8086e5 Integrate Ollama into role detection with fallback to pattern matching
- Updated RoleDetector to use OllamaService for AI-based speaker detection
- Implemented _detect_with_ollama() method with availability check
- Added fallback logic: tries Ollama first, then pattern matching
- Implemented role merging and deduplication across both methods
- Handles Ollama unavailable gracefully with logging
- Logs detection method used (AI vs pattern)
- Updated main.py endpoint to await async detect_roles
- Added comprehensive integration tests

Requirements: 14.1, 14.4, 14.5
2025-12-09 10:49:37 +00:00
73dc5695ca Improve Ollama speaker detection with multi-sample strategy
- Sample up to 4 chunks of 5000 characters from different text positions
- Distribute samples evenly across beginning, middle, and end of text
- Deduplicate speakers across all samples for comprehensive detection
- Log individual sample results for debugging
- Handle short texts efficiently (single sample)
- Updated tests to verify multi-sample behavior

This ensures speakers introduced anywhere in long texts are detected,
not just those appearing in the first 2000 characters.
2025-12-09 10:40:59 +00:00
a8802fd765 Implement Ollama integration service for AI-based speaker detection
- Created OllamaService class with httpx for API communication
- Implemented detect_speakers() method with structured prompts
- Added JSON response parser supporting multiple formats
- Implemented is_available() health check method
- Added 30-second timeout handling
- Configured OLLAMA_BASE_URL environment variable
- Added comprehensive unit tests with 100% coverage
- Updated requirements.txt with httpx dependency

Requirements: 14.1, 14.2, 14.3, 14.6
2025-12-09 10:35:30 +00:00
ff2c8f8404 docs: Create comprehensive README documentation
- Updated main README with detailed setup, Kokoro model configuration, and troubleshooting
- Enhanced backend README with API documentation, Docker setup, and testing instructions
- Improved frontend README with component details, deployment guide, and development tips
- Added workflow testing steps and common error solutions
- Documented all supported languages, voices, and configuration options

Implements task 14 from text-to-audiobook spec
Requirements: 13.1, 13.2, 13.3, 13.4, 13.5
2025-12-09 10:11:15 +00:00
ffd079dbcb feat: Add Docker configuration for backend
- Create Dockerfile with Python 3.10 base image
- Install system dependencies (espeak-ng) for Kokoro TTS
- Install Python dependencies from requirements.txt
- Copy backend code and expose port 8000
- Configure Uvicorn server startup
- Add docker-compose.yml for easy orchestration
- Include health checks and environment variables
- Add .dockerignore to optimize build context

Implements task 6 - Requirements 11.1-11.6
2025-12-09 01:23:00 +00:00
271a127167 Implement audio generation endpoint
- Add POST /api/tts endpoint with full request validation
- Validate text, language code, speed range, and roles list
- Integrate TTSService to generate multi-voice audiobooks
- Fix Kokoro pipeline generator handling to properly collect audio
- Stream audio response with correct Content-Type (audio/wav)
- Add Content-Disposition header with filename (audiobook.wav)
- Handle errors gracefully with appropriate HTTP status codes
- Add comprehensive test suite for endpoint validation

Requirements: 6.1, 6.7, 6.8, 9.5
2025-12-09 01:21:39 +00:00
e6f4e2ea32 Implement TTS service with Kokoro integration
- Created TTSService class with pipeline caching per language
- Implemented text segmentation to identify role markers (colon and bracket patterns)
- Implemented segment synthesis with voice assignment
- Implemented audio concatenation at 24 kHz sample rate
- Added fallback to default voice (af_bella) for unmapped roles
- Supports language codes: a, b, f, j
- Handles long text by chunking on sentence boundaries
- Added comprehensive unit tests (13 tests, all passing)

Requirements: 10.1, 10.3, 10.4, 6.2, 6.3, 6.4, 6.5, 6.6
2025-12-09 01:06:59 +00:00
77437348ed Implement role detection service with pattern matching
- Created RoleDetector class with colon and bracket pattern extraction
- Implemented role deduplication logic
- Added fallback to default 'Narrator' role when no patterns found
- Created /api/tts/roles endpoint using RoleDetector
- Added comprehensive test suite for role detection
- All tests passing (7/7)

Requirements: 2.1, 2.2, 2.3, 2.4, 2.5, 2.6
2025-12-09 01:04:09 +00:00
31da896e56 Implement backend API foundation
- Created FastAPI application with CORS middleware
- Defined Pydantic models (RoleDetectionRequest, RolesResponse, TTSRequest, ErrorResponse)
- Implemented /api/health endpoint
- Set up error handling middleware for validation and general exceptions
- Configured logging with INFO level
- Added test script to verify API functionality
- Validates Requirements: 9.1, 9.2, 9.4
2025-12-09 00:57:46 +00:00
f4bc759007 Task 1: Set up project structure and dependencies
- Created backend directory with FastAPI project structure
- Created frontend directory with React + TypeScript + Vite
- Configured Python virtual environment and installed dependencies (fastapi, uvicorn, kokoro, soundfile, python-multipart)
- Verified espeak-ng system dependency is installed
- Configured Node.js project with TypeScript, React, and Vite
- Set up Tailwind CSS for styling
- Set up environment variable configuration for both projects
- Created comprehensive README documentation

Requirements: 9.6, 10.2, 11.1
2025-12-09 00:47:44 +00:00