| # Phase 2 Implementation Workflow |
|
|
| ## π Visual Step-by-Step Guide |
|
|
| This document provides a visual workflow for implementing Phase 2 using the 6 prompts. |
|
|
| --- |
|
|
| ## π― Overview |
|
|
| ``` |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β PHASE 2 IMPLEMENTATION β |
| β (17-21 hours) β |
| β β |
| β 6 Prompts β 6 Components β 1 Complete Voice System β |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| ``` |
|
|
| --- |
|
|
| ## π Complete Workflow |
|
|
| ``` |
| START |
| β |
| ββ Read PHASE_2_IMPLEMENTATION_PROMPTS.md |
| ββ Backup code: git commit -m "Before Phase 2" |
| ββ Install: pip install -r requirements-phase2.txt |
| β |
| βΌ |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β PROMPT 1: ASR Module (2 hours) β |
| β β |
| β Input: PROMPT 1 β AI Assistant β |
| β Output: app/voice/asr.py β |
| β β |
| β Actions: β |
| β 1. Copy PROMPT 1 to AI assistant β |
| β 2. Review generated code β |
| β 3. Save to app/voice/asr.py β |
| β 4. Test: python -c "from app.voice.asr import ..." β |
| β 5. Commit: git commit -m "Add ASR module" β |
| β β |
| β Success Criteria: β |
| β β File created β |
| β β Import works β |
| β β No errors β |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β |
| βΌ |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β PROMPT 2: TTS Module (2 hours) β |
| β β |
| β Input: PROMPT 2 β AI Assistant β |
| β Output: app/voice/tts.py β |
| β β |
| β Actions: β |
| β 1. Copy PROMPT 2 to AI assistant β |
| β 2. Review generated code β |
| β 3. Save to app/voice/tts.py β |
| β 4. Test: python -c "from app.voice.tts import ..." β |
| β 5. Commit: git commit -m "Add TTS module" β |
| β β |
| β Success Criteria: β |
| β β File created β |
| β β Import works β |
| β β No errors β |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β |
| βΌ |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β PROMPT 3: Voice API (3 hours) β |
| β β |
| β Input: PROMPT 3 β AI Assistant β |
| β Output: app/api/voice_endpoints.py β |
| β app/api/voice_schemas.py β |
| β β |
| β Actions: β |
| β 1. Copy PROMPT 3 to AI assistant β |
| β 2. Review generated code (2 files) β |
| β 3. Save both files β |
| β 4. Test: python -c "from app.api.voice_endpoints ..." β |
| β 5. Commit: git commit -m "Add voice API endpoints" β |
| β β |
| β Success Criteria: β |
| β β Both files created β |
| β β Imports work β |
| β β No errors β |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β |
| βΌ |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β PROMPT 4: Voice UI (4 hours) β |
| β β |
| β Input: PROMPT 4 β AI Assistant β |
| β Output: ui/voice.html β |
| β ui/voice.js β |
| β ui/voice.css β |
| β β |
| β Actions: β |
| β 1. Copy PROMPT 4 to AI assistant β |
| β 2. Review generated code (3 files) β |
| β 3. Save all three files β |
| β 4. Test: Open voice.html in browser β |
| β 5. Commit: git commit -m "Add voice UI" β |
| β β |
| β Success Criteria: β |
| β β All 3 files created β |
| β β UI renders in browser β |
| β β No console errors β |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β |
| βΌ |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β PROMPT 5: Integration (3 hours) β |
| β β |
| β Input: PROMPT 5 β AI Assistant β |
| β Output: Updated app/config.py β |
| β Updated app/main.py β |
| β Updated .env.example β |
| β β |
| β Actions: β |
| β 1. Copy PROMPT 5 to AI assistant β |
| β 2. Review changes to 3 files β |
| β 3. Apply changes carefully β |
| β 4. Add to .env: PHASE_2_ENABLED=true β |
| β 5. Test: python -m uvicorn app.main:app --reload β |
| β 6. Check logs for "Phase 2 voice endpoints enabled" β |
| β 7. Test Phase 1: curl http://localhost:8000/api/v1/health β |
| β 8. Commit: git commit -m "Integrate Phase 2" β |
| β β |
| β Success Criteria: β |
| β β Server starts β |
| β β Phase 2 endpoints available β |
| β β Phase 1 still works β |
| β β No errors in logs β |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β |
| βΌ |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β PROMPT 6: Testing (3 hours) β |
| β β |
| β Input: PROMPT 6 β AI Assistant β |
| β Output: tests/unit/test_voice_asr.py β |
| β tests/unit/test_voice_tts.py β |
| β tests/integration/test_voice_api.py β |
| β β |
| β Actions: β |
| β 1. Copy PROMPT 6 to AI assistant β |
| β 2. Review generated tests (3 files) β |
| β 3. Save all test files β |
| β 4. Run: pytest tests/unit/test_voice_*.py -v β |
| β 5. Run: pytest tests/integration/test_voice_api.py -v β |
| β 6. Run: pytest tests/ -v (ALL tests) β |
| β 7. Fix any failures β |
| β 8. Commit: git commit -m "Add Phase 2 tests" β |
| β β |
| β Success Criteria: β |
| β β All test files created β |
| β β All Phase 2 tests pass β |
| β β All Phase 1 tests pass β |
| β β No breaking changes β |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β |
| βΌ |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β FINAL VALIDATION β |
| β β |
| β Manual Testing: β |
| β 1. Open http://localhost:8000/ui/voice.html β |
| β 2. Click "Start Recording" β |
| β 3. Speak: "Your account is blocked. Send OTP now!" β |
| β 4. Click "Stop Recording" β |
| β 5. Wait for processing β |
| β 6. Verify: β |
| β β Transcription appears β |
| β β AI reply text appears β |
| β β Audio player appears β |
| β β AI voice plays β |
| β β Metadata displays β |
| β β Intelligence extracted (if any) β |
| β β |
| β 7. Test Phase 1: β |
| β Open http://localhost:8000/ui/index.html β |
| β β Text chat still works β |
| β β |
| β 8. Final commit: git commit -m "Phase 2 complete" β |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β |
| βΌ |
| β
PHASE 2 COMPLETE! |
| ``` |
|
|
| --- |
|
|
| ## π Detailed Prompt Flow |
|
|
| ### PROMPT 1: ASR Module |
|
|
| ``` |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β YOU β |
| β β β |
| β β Copy PROMPT 1 β |
| β β "Create ASR module with Whisper..." β |
| β βΌ β |
| β AI ASSISTANT β |
| β β β |
| β β Generates app/voice/asr.py β |
| β β - ASREngine class β |
| β β - transcribe() method β |
| β β - Whisper integration β |
| β β - Error handling β |
| β βΌ β |
| β YOU β |
| β β β |
| β β Review code β |
| β β Save to app/voice/asr.py β |
| β β Test: python -c "from app.voice.asr import ..." β |
| β β Commit: git commit -m "Add ASR module" β |
| β βΌ β |
| β β
CHECKPOINT: ASR module works β |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| ``` |
|
|
| ### PROMPT 2: TTS Module |
|
|
| ``` |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β YOU β |
| β β β |
| β β Copy PROMPT 2 β |
| β β "Create TTS module with gTTS..." β |
| β βΌ β |
| β AI ASSISTANT β |
| β β β |
| β β Generates app/voice/tts.py β |
| β β - TTSEngine class β |
| β β - synthesize() method β |
| β β - gTTS integration β |
| β β - Language mapping β |
| β βΌ β |
| β YOU β |
| β β β |
| β β Review code β |
| β β Save to app/voice/tts.py β |
| β β Test: python -c "from app.voice.tts import ..." β |
| β β Commit: git commit -m "Add TTS module" β |
| β βΌ β |
| β β
CHECKPOINT: TTS module works β |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| ``` |
|
|
| ### PROMPT 3: Voice API |
|
|
| ``` |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β YOU β |
| β β β |
| β β Copy PROMPT 3 β |
| β β "Create voice API endpoints..." β |
| β βΌ β |
| β AI ASSISTANT β |
| β β β |
| β β Generates: β |
| β β 1. app/api/voice_schemas.py β |
| β β - VoiceEngageResponse β |
| β β - TranscriptionMetadata β |
| β β - VoiceFraudMetadata β |
| β β β |
| β β 2. app/api/voice_endpoints.py β |
| β β - POST /api/v1/voice/engage β |
| β β - GET /api/v1/voice/audio/{filename} β |
| β β - GET /api/v1/voice/health β |
| β βΌ β |
| β YOU β |
| β β β |
| β β Review both files β |
| β β Save both files β |
| β β Test imports β |
| β β Commit: git commit -m "Add voice API" β |
| β βΌ β |
| β β
CHECKPOINT: API code ready β |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| ``` |
|
|
| ### PROMPT 4: Voice UI |
|
|
| ``` |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β YOU β |
| β β β |
| β β Copy PROMPT 4 β |
| β β "Create voice UI with recording..." β |
| β βΌ β |
| β AI ASSISTANT β |
| β β β |
| β β Generates: β |
| β β 1. ui/voice.html β |
| β β - Recording controls β |
| β β - Conversation display β |
| β β - Metadata section β |
| β β β |
| β β 2. ui/voice.js β |
| β β - MediaRecorder API β |
| β β - API integration β |
| β β - UI updates β |
| β β β |
| β β 3. ui/voice.css β |
| β β - Dark theme β |
| β β - Recording status β |
| β β - Message bubbles β |
| β βΌ β |
| β YOU β |
| β β β |
| β β Review all 3 files β |
| β β Save all files β |
| β β Open voice.html in browser β |
| β β Commit: git commit -m "Add voice UI" β |
| β βΌ β |
| β β
CHECKPOINT: UI renders β |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| ``` |
|
|
| ### PROMPT 5: Integration |
|
|
| ``` |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β YOU β |
| β β β |
| β β Copy PROMPT 5 β |
| β β "Integrate Phase 2 into main app..." β |
| β βΌ β |
| β AI ASSISTANT β |
| β β β |
| β β Provides updates for: β |
| β β 1. app/config.py β |
| β β + PHASE_2_ENABLED β |
| β β + WHISPER_MODEL β |
| β β + TTS_ENGINE β |
| β β + Other Phase 2 settings β |
| β β β |
| β β 2. app/main.py β |
| β β + Conditional voice router inclusion β |
| β β β |
| β β 3. .env.example β |
| β β + Phase 2 config section β |
| β βΌ β |
| β YOU β |
| β β β |
| β β Review changes carefully β |
| β β Apply updates to all 3 files β |
| β β Add PHASE_2_ENABLED=true to .env β |
| β β Start server: uvicorn app.main:app --reload β |
| β β Check logs β |
| β β Test Phase 1 still works β |
| β β Commit: git commit -m "Integrate Phase 2" β |
| β βΌ β |
| β β
CHECKPOINT: Phase 2 integrated β |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| ``` |
|
|
| ### PROMPT 6: Testing |
|
|
| ``` |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β YOU β |
| β β β |
| β β Copy PROMPT 6 β |
| β β "Create tests for Phase 2..." β |
| β βΌ β |
| β AI ASSISTANT β |
| β β β |
| β β Generates: β |
| β β 1. tests/unit/test_voice_asr.py β |
| β β - Test ASREngine β |
| β β - Test transcription β |
| β β - Test error handling β |
| β β β |
| β β 2. tests/unit/test_voice_tts.py β |
| β β - Test TTSEngine β |
| β β - Test synthesis β |
| β β - Test language mapping β |
| β β β |
| β β 3. tests/integration/test_voice_api.py β |
| β β - Test voice endpoints β |
| β β - Test full flow β |
| β β - Test Phase 1 unaffected β |
| β βΌ β |
| β YOU β |
| β β β |
| β β Review all test files β |
| β β Save all files β |
| β β Run: pytest tests/unit/test_voice_*.py β |
| β β Run: pytest tests/integration/test_voice_api.py β |
| β β Run: pytest tests/ (all tests) β |
| β β Fix any failures β |
| β β Commit: git commit -m "Add Phase 2 tests" β |
| β βΌ β |
| β β
CHECKPOINT: All tests pass β |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| ``` |
|
|
| --- |
|
|
| ## π― Progress Tracking |
|
|
| ### Visual Progress Bar |
|
|
| ``` |
| PROMPT 1: [ββββββββββββββββββββ] 100% β
|
| PROMPT 2: [ββββββββββββββββββββ] 100% β
|
| PROMPT 3: [ββββββββββββββββββββ] 100% β
|
| PROMPT 4: [ββββββββββββββββββββ] 100% β
|
| PROMPT 5: [ββββββββββββββββββββ] 100% β
|
| PROMPT 6: [ββββββββββββββββββββ] 100% β
|
| |
| Overall: [ββββββββββββββββββββ] 100% β
COMPLETE! |
| ``` |
|
|
| ### Time Tracking |
|
|
| ``` |
| Start Time: ___________ |
| |
| PROMPT 1: Start _______ End _______ Duration _______ |
| PROMPT 2: Start _______ End _______ Duration _______ |
| PROMPT 3: Start _______ End _______ Duration _______ |
| PROMPT 4: Start _______ End _______ Duration _______ |
| PROMPT 5: Start _______ End _______ Duration _______ |
| PROMPT 6: Start _______ End _______ Duration _______ |
| |
| Total Duration: _______ |
| ``` |
|
|
| --- |
|
|
| ## π¦ Decision Points |
|
|
| ### After Each Prompt |
|
|
| ``` |
| βββββββββββββββββββββββββββββββββββββββββββ |
| β Did the code generate successfully? β |
| βββββββββββββββ¬ββββββββββββββββββββββββββββ |
| β |
| ββββββ΄βββββ |
| β YES β NO |
| β β β |
| βΌ β βΌ |
| Continue β ββββββββββββββββββββββββ |
| to next β β Debug: β |
| prompt β β - Check error msg β |
| β β - Review prompt β |
| β β - Ask AI for help β |
| β β - Try again β |
| β ββββββββββββββββββββββββ |
| β |
| βΌ |
| βββββββββββββββββββββββ |
| β Did tests pass? β |
| βββββββββββ¬βββββββββββββ |
| β |
| ββββββ΄βββββ |
| β YES β NO |
| β β β |
| βΌ β βΌ |
| Continue β ββββββββββββββββββββββββ |
| to next β β Debug: β |
| prompt β β - Read error output β |
| β β - Fix code β |
| β β - Run tests again β |
| β ββββββββββββββββββββββββ |
| β |
| βΌ |
| βββββββββββββββββββββββ |
| β Commit and continue β |
| βββββββββββββββββββββββ |
| ``` |
|
|
| --- |
|
|
| ## π Checklist Format |
|
|
| Print this and check off as you go: |
|
|
| ``` |
| β‘ SETUP |
| β‘ Read PHASE_2_IMPLEMENTATION_PROMPTS.md |
| β‘ Backup: git commit -m "Before Phase 2" |
| β‘ Install: pip install -r requirements-phase2.txt |
| |
| β‘ PROMPT 1: ASR Module (_____ hours) |
| β‘ Copy prompt to AI |
| β‘ Review generated code |
| β‘ Save app/voice/asr.py |
| β‘ Test import |
| β‘ Commit changes |
| |
| β‘ PROMPT 2: TTS Module (_____ hours) |
| β‘ Copy prompt to AI |
| β‘ Review generated code |
| β‘ Save app/voice/tts.py |
| β‘ Test import |
| β‘ Commit changes |
| |
| β‘ PROMPT 3: Voice API (_____ hours) |
| β‘ Copy prompt to AI |
| β‘ Review generated code (2 files) |
| β‘ Save voice_schemas.py |
| β‘ Save voice_endpoints.py |
| β‘ Test imports |
| β‘ Commit changes |
| |
| β‘ PROMPT 4: Voice UI (_____ hours) |
| β‘ Copy prompt to AI |
| β‘ Review generated code (3 files) |
| β‘ Save voice.html |
| β‘ Save voice.js |
| β‘ Save voice.css |
| β‘ Test UI renders |
| β‘ Commit changes |
| |
| β‘ PROMPT 5: Integration (_____ hours) |
| β‘ Copy prompt to AI |
| β‘ Review changes (3 files) |
| β‘ Update app/config.py |
| β‘ Update app/main.py |
| β‘ Update .env.example |
| β‘ Set PHASE_2_ENABLED=true |
| β‘ Start server |
| β‘ Check logs |
| β‘ Test Phase 1 |
| β‘ Commit changes |
| |
| β‘ PROMPT 6: Testing (_____ hours) |
| β‘ Copy prompt to AI |
| β‘ Review tests (3 files) |
| β‘ Save test_voice_asr.py |
| β‘ Save test_voice_tts.py |
| β‘ Save test_voice_api.py |
| β‘ Run Phase 2 tests |
| β‘ Run all tests |
| β‘ Fix failures |
| β‘ Commit changes |
| |
| β‘ FINAL VALIDATION |
| β‘ Manual voice test |
| β‘ Phase 1 still works |
| β‘ All tests pass |
| β‘ Documentation updated |
| β‘ Final commit |
| |
| β
DONE! |
| ``` |
|
|
| --- |
|
|
| ## π Completion |
|
|
| When you reach this point: |
|
|
| ``` |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β β |
| β π PHASE 2 COMPLETE! π β |
| β β |
| β β ASR Module working β |
| β β TTS Module working β |
| β β Voice API working β |
| β β Voice UI working β |
| β β Integration complete β |
| β β All tests passing β |
| β β Phase 1 still working β |
| β β |
| β You can now: β |
| β - Record voice messages β |
| β - Get AI voice replies β |
| β - See transcriptions β |
| β - Extract intelligence from voice β |
| β β |
| β Next: Deploy and demo! π β |
| β β |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| ``` |
|
|
| --- |
|
|
| *Visual workflow for: PHASE_2_IMPLEMENTATION_PROMPTS.md* |
|
|
| *Start with: PROMPT 1 (ASR Module)* |
|
|
| *Track progress with this document!* |
|
|