feat: Add Ollama integration for AI-based speaker detection

- Added Requirement 14 for intelligent speaker detection using Ollama/llama3:8B
- Updated design document with OllamaService component and integration details
- Added 4 new correctness properties for Ollama functionality
- Added tasks 15-17 for implementing Ollama integration
- Updated technology stack to include httpx and Ollama
- Added error handling guidelines for Ollama integration
- Configured fallback to pattern-based detection when Ollama unavailable

This enhancement allows users to paste raw dialogue text without manual role markers.
The system will use AI to intelligently detect speakers, making the tool more user-friendly.
This commit is contained in:
2025-12-09 10:31:38 +00:00
parent ff2c8f8404
commit 20e6cd1f9d
3 changed files with 157 additions and 4 deletions

View File

@@ -179,3 +179,16 @@ The Text to Audiobook system is a production-ready React TypeScript single-page
3. THE README SHALL document how to run the frontend with example commands
4. THE README SHALL include steps to test the full workflow from text input to audio generation
5. THE README MAY include screenshots or diagrams illustrating the application flow
### Requirement 14
**User Story:** As a user, I want the system to intelligently detect speakers in unmarked text using AI, so that I can convert any dialogue or narrative without manually adding role markers.
#### Acceptance Criteria
1. WHEN the Backend receives text without explicit role markers THEN the Backend SHALL use Ollama with llama3:8B to analyze the text and identify distinct speakers
2. WHEN Ollama analyzes text THEN the Backend SHALL send a structured prompt requesting speaker identification in JSON format
3. WHEN Ollama returns speaker names THEN the Backend SHALL parse the JSON response and create role objects
4. WHEN Ollama is unavailable or fails THEN the Backend SHALL fall back to pattern-based role detection
5. WHEN both AI detection and pattern detection find roles THEN the Backend SHALL merge and deduplicate the results
6. THE Backend SHALL configure Ollama connection using environment variable OLLAMA_BASE_URL with default http://localhost:11434