This solution leverages the existing kokoro-tts --stream functionality instead of reinventing it.
extract_pages.py → pipe → kokoro-tts --stream
↓ ↓
[Page Text] [Audio Stream]
./stream_sapiens_from_page.sh 50./stream_sapiens_from_page.sh 50 100./stream_sapiens_from_page.sh 50 100 af_sarah./stream_sapiens_from_page.sh 50 100 af_sarah 1.3Just run the script without arguments to see all available voices:
./stream_sapiens_from_page.sh- Extracts text from specific page ranges
- Outputs to stdout for piping
- Simple, focused functionality
- Uses the existing streaming functionality
- All the advanced features (voice blending, error handling, etc.)
- No reinventing the wheel
- Combines extraction + streaming
- Simple parameter handling
- User-friendly interface
✅ Leverages existing kokoro-tts streaming infrastructure
✅ Much simpler codebase (50 lines vs 400+ lines)
✅ Uses proven streaming functionality
✅ All existing kokoro-tts features available
✅ Easy to maintain and extend
extract_pages.py- Simple page extractor (50 lines)stream_sapiens_from_page.sh- Wrapper script (40 lines)- This guide - Usage documentation
- ✅ Real-time streaming
- ✅ 50+ voice options
- ✅ Voice blending support
- ✅ Speed control
- ✅ Error handling
- ✅ Progress indicators
- ✅ Interruption support (Ctrl+C)
# Start reading Sapiens from Chapter 4 (page 50)
./stream_sapiens_from_page.sh 50
# Read just one page with a specific voice
./stream_sapiens_from_page.sh 50 50 af_sarah
# Speed reading with 1.5x speed
./stream_sapiens_from_page.sh 100 150 am_adam 1.5This approach is much cleaner and leverages the existing, well-tested streaming functionality rather than building everything from scratch!