File size: 32,538 Bytes
6a4a552 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 | # 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!*
|