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
This commit is contained in:
@@ -349,15 +349,125 @@
|
||||
- Add troubleshooting section for Ollama issues
|
||||
- _Requirements: 14.6_
|
||||
|
||||
- [ ] 18. Final integration testing and polish
|
||||
- Test complete end-to-end workflow
|
||||
- Test with various text samples (short, long, multiple roles, no roles)
|
||||
- [x] 18. Implement script generation endpoint
|
||||
- Create /api/tts/script POST endpoint in main.py
|
||||
- Define ScriptRequest and ScriptResponse Pydantic models
|
||||
- Define ScriptSegment model with id, speaker, and text fields
|
||||
- Integrate with TTSService to generate script segments using AI
|
||||
- Return segments with unique IDs for frontend tracking
|
||||
- Handle errors gracefully when AI segmentation fails
|
||||
- _Requirements: 15.1, 15.2_
|
||||
|
||||
- [ ]* 18.1 Write property test for script generation
|
||||
- **Property 32: Script generation completeness**
|
||||
- **Validates: Requirements 15.2**
|
||||
|
||||
- [ ]* 18.2 Write property test for script segment structure
|
||||
- **Property 33: Script segment structure**
|
||||
- **Validates: Requirements 15.4**
|
||||
|
||||
- [ ]* 18.3 Write unit tests for script endpoint
|
||||
- Test successful script generation
|
||||
- Test with various text lengths
|
||||
- Test error handling
|
||||
- _Requirements: 15.2_
|
||||
|
||||
- [ ] 19. Update TTS generation endpoint to accept edited scripts
|
||||
- Modify TTSRequest to accept optional segments array
|
||||
- Update generate_audiobook logic to use segments if provided
|
||||
- Fall back to text segmentation if no segments provided
|
||||
- Ensure backward compatibility with existing API calls
|
||||
- _Requirements: 15.7_
|
||||
|
||||
- [ ]* 19.1 Write property test for edited script persistence
|
||||
- **Property 35: Edited script persistence**
|
||||
- **Validates: Requirements 15.7**
|
||||
|
||||
- [ ]* 19.2 Write unit tests for script-based generation
|
||||
- Test generation with edited segments
|
||||
- Test fallback to text-based generation
|
||||
- Test segment speaker assignments are respected
|
||||
- _Requirements: 15.7_
|
||||
|
||||
- [ ] 20. Implement script generation API client function
|
||||
- Add generateScript() function to src/api/tts.ts
|
||||
- Define ScriptSegment, ScriptRequest, and ScriptResponse TypeScript interfaces
|
||||
- Implement error handling for script generation
|
||||
- Update GenerateRequest interface to support segments
|
||||
- _Requirements: 15.1, 15.2_
|
||||
|
||||
- [ ]* 20.1 Write unit tests for script API client
|
||||
- Test generateScript() function
|
||||
- Test error handling
|
||||
- Mock API responses
|
||||
- _Requirements: 15.1_
|
||||
|
||||
- [ ] 21. Implement ScriptReviewSection component
|
||||
- Create ScriptReviewSection component
|
||||
- Display list of script segments with text boxes
|
||||
- Add speaker dropdown for each segment
|
||||
- Implement segment editing handlers
|
||||
- Add "Generate Audiobook" button
|
||||
- Add "Skip Review" button for quick generation
|
||||
- Style for readability and mobile responsiveness
|
||||
- _Requirements: 15.3, 15.4, 15.5, 15.6, 15.8_
|
||||
|
||||
- [ ]* 21.1 Write property test for script segment editability
|
||||
- **Property 34: Script segment editability**
|
||||
- **Validates: Requirements 15.5**
|
||||
|
||||
- [ ]* 21.2 Write unit tests for ScriptReviewSection
|
||||
- Test component renders segments correctly
|
||||
- Test speaker dropdown contains all roles
|
||||
- Test segment editing updates state
|
||||
- Test generate button is enabled
|
||||
- Test skip review button works
|
||||
- _Requirements: 15.3, 15.4, 15.5, 15.8_
|
||||
|
||||
- [ ] 22. Update App component for script review workflow
|
||||
- Add 'review' phase to application state
|
||||
- Add scriptSegments state variable
|
||||
- Add isGeneratingScript loading state
|
||||
- Implement handleGenerateScript() method
|
||||
- Implement handleSkipReview() method
|
||||
- Implement handleSegmentChange() method
|
||||
- Update handleGenerate() to use edited segments
|
||||
- Wire up ScriptReviewSection component
|
||||
- Update phase transitions: input → assignment → review → generated
|
||||
- _Requirements: 15.1, 15.3, 15.6, 15.7, 15.8_
|
||||
|
||||
- [ ]* 22.1 Write unit tests for script workflow
|
||||
- Test phase transitions include review phase
|
||||
- Test script generation is called after voice assignment
|
||||
- Test segment changes are tracked
|
||||
- Test skip review bypasses review phase
|
||||
- _Requirements: 15.1, 15.8_
|
||||
|
||||
- [ ] 23. Update VoiceAssignmentSection to trigger script generation
|
||||
- Change "Generate Audiobook" button to "Next: Review Script"
|
||||
- Add "Skip Review & Generate" button as alternative
|
||||
- Update button handlers to call appropriate methods
|
||||
- _Requirements: 15.1, 15.8_
|
||||
|
||||
- [ ] 24. Add script review documentation
|
||||
- Document script review feature in README
|
||||
- Add screenshots of script review interface
|
||||
- Explain how to edit speaker assignments
|
||||
- Document skip review option
|
||||
- Add troubleshooting for script generation issues
|
||||
- _Requirements: 15.3, 15.4, 15.5, 15.8_
|
||||
|
||||
- [ ] 25. Final integration testing and polish
|
||||
- Test complete end-to-end workflow with script review
|
||||
- Test script generation with various text samples
|
||||
- Test editing speaker assignments in script
|
||||
- Test skip review functionality
|
||||
- Test with unmarked dialogue text (relying on AI detection)
|
||||
- Test with marked text (pattern detection)
|
||||
- Test with Ollama available and unavailable
|
||||
- Test all language options (a, b, f, j)
|
||||
- Test error scenarios (network failures, invalid inputs)
|
||||
- Verify audio quality and playback
|
||||
- Verify audio quality and playback with edited scripts
|
||||
- Test Docker deployment
|
||||
- Fix any bugs discovered during testing
|
||||
- _Requirements: All_
|
||||
Reference in New Issue
Block a user