# Voice Chat Feature - Phase 1 Testing Guide ## Testing Environment Setup ✅ **Bot rebuilt and restarted** with new dependencies: - PyNaCl>=1.5.0 (Discord voice support) - websockets>=12.0 (TTS WebSocket client) ## Test Checklist ### 🎯 Test 1: Voice Commands Basic Functionality #### 1A. Test `!miku join` Command **Prerequisites:** - Be in a Discord server where Miku is present - Join a voice channel first **Steps:** ``` 1. Join any voice channel in the server 2. Type: !miku join ``` **Expected Results:** - ✅ Miku joins your voice channel - ✅ You receive an embed message with: - Title: "🎤 Joined Voice Chat!" - Teal color (#86CECB) - Instructions on how to talk to Miku - List of 8 blocked features - ✅ Bot logs show all 9 resource locks activating: ``` [INFO] Switching to AMD GPU for voice session [INFO] Vision model blocked [INFO] Image generation disabled [INFO] Text channels paused [INFO] Bipolar interactions paused [INFO] Profile picture switching locked [INFO] Autonomous system paused [INFO] Scheduler paused [INFO] Figurine notifier paused ``` **How to Check Logs:** ```bash docker-compose logs miku-bot --tail 100 | grep -i "voice\|blocked\|paused\|locked" ``` #### 1B. Test `!miku voice-status` Command **Steps:** ``` 1. While voice session is active, type: !miku voice-status ``` **Expected Results:** - ✅ Embed showing: - Voice channel name - Prompt channel name (where you typed the command) - List of all 8 blocked features with ❌ icons #### 1C. Test `!miku leave` Command **Steps:** ``` 1. Type: !miku leave ``` **Expected Results:** - ✅ Miku disconnects from voice channel - ✅ Confirmation message: "👋 Left voice chat and restored all features!" - ✅ Bot logs show all 9 resource locks releasing: ``` [INFO] Switched back to GTX GPU [INFO] Vision model unblocked [INFO] Image generation re-enabled [INFO] Text channels resumed [INFO] Bipolar interactions resumed [INFO] Profile picture switching unlocked [INFO] Autonomous system resumed [INFO] Scheduler resumed [INFO] Figurine notifier resumed ``` --- ### 🚫 Test 2: Resource Blocking - Vision Model **Steps:** ``` 1. Type: !miku join (in a text channel) 2. Upload an image or video to the text channel 3. Wait for Miku's response ``` **Expected Results:** - ✅ Miku responds: "🎤 I can't look at images or videos right now, I'm talking in voice chat! Send it again after I leave the voice channel." - ✅ Image is NOT processed - ✅ No vision model loading attempts in logs --- ### 🚫 Test 3: Resource Blocking - Image Generation **Steps:** ``` 1. Type: !miku join 2. Try to request an image (e.g., "draw a picture of yourself") 3. Wait for response ``` **Expected Results:** - ✅ Miku responds: "🎤 I can't draw right now, I'm talking in voice chat! Ask me again after I leave the voice channel." - ✅ Message gets a 🎤 reaction added - ✅ No ComfyUI requests in logs - ✅ Log shows: "[INFO] 🚫 Image generation blocked - voice session active" --- ### 🚫 Test 4: Resource Blocking - Profile Picture Changes **Steps:** ``` 1. Type: !miku join 2. Try to trigger a mood change that would normally change profile picture (This might happen automatically or through commands) ``` **Expected Results:** - ✅ Profile picture does NOT change - ✅ Logs show: "[INFO] Profile picture switching locked" - ✅ Error log: "Profile picture switching locked during voice session" --- ### 🚫 Test 5: Resource Blocking - Autonomous Engine **Steps:** ``` 1. Type: !miku join 2. Wait 30+ seconds (normal autonomous action interval) 3. Check if autonomous messages appear ``` **Expected Results:** - ✅ NO autonomous messages appear - ✅ Logs show: "[DEBUG] Autonomous system paused, skipping tick" --- ### 🚫 Test 6: Resource Blocking - Bipolar Mode **Prerequisites:** - Bipolar mode must be enabled on the server **Steps:** ``` 1. Type: !miku join 2. Try to trigger a bipolar argument (this has a 15% random chance) 3. Or check if any arguments start naturally ``` **Expected Results:** - ✅ NO bipolar arguments start - ✅ Logs show: "[DEBUG] Bipolar interactions paused, skipping argument trigger" --- ### 🚫 Test 7: Resource Blocking - Scheduled Events **This test requires waiting for a scheduled event time** **Expected Behavior:** - ✅ During voice session, scheduled events (bedtime, mood rotations) should NOT fire - ✅ Check logs for: "Scheduler paused" / "Scheduler resumed" --- ### 🚫 Test 8: Resource Blocking - Figurine Notifier **This test requires waiting for figurine notification time** **Expected Behavior:** - ✅ During voice session, figurine notifications should NOT send - ✅ Check logs for: "Figurine notifier paused" / "Figurine notifier resumed" --- ### 🔄 Test 9: Session Persistence **Steps:** ``` 1. Type: !miku join 2. Leave the server text channel 3. Go to a different text channel 4. Type: !miku voice-status ``` **Expected Results:** - ✅ Status correctly shows the original voice channel and prompt channel - ✅ Session persists across channel changes --- ### ⚠️ Test 10: Error Handling #### 10A. Join Without Being in Voice **Steps:** ``` 1. Don't join any voice channel 2. Type: !miku join ``` **Expected Results:** - ✅ Error message: "You need to be in a voice channel first!" #### 10B. Leave When Not in Session **Steps:** ``` 1. Make sure no voice session is active 2. Type: !miku leave ``` **Expected Results:** - ✅ Message: "I'm not in a voice chat right now!" #### 10C. Join While Already in Session **Steps:** ``` 1. Type: !miku join 2. Try: !miku join again ``` **Expected Results:** - ✅ Error message preventing duplicate session start --- ### 🔍 Test 11: GPU Switching **This requires checking the gpu_state.json file** **Steps:** ``` 1. Check current GPU state: cat /home/koko210Serve/docker/miku-discord/gpu_state.json 2. Type: !miku join 3. Check GPU state again: cat /home/koko210Serve/docker/miku-discord/gpu_state.json 4. Type: !miku leave 5. Check GPU state one more time ``` **Expected Results:** - ✅ Before join: `{"current": "gtx"}` - ✅ After join: `{"current": "amd"}` - ✅ After leave: `{"current": "gtx"}` **Command:** ```bash watch -n 2 'cat /home/koko210Serve/docker/miku-discord/gpu_state.json' ``` --- ### 📋 Test 12: Text Channel Pausing **Steps:** ``` 1. Type: !miku join in a text channel 2. Try sending normal messages to Miku in that channel ``` **Expected Results:** - ✅ Miku does NOT respond to normal text messages - ✅ Messages get queued in TEXT_MESSAGE_QUEUE (visible in logs) - ✅ Only voice commands (!miku join/leave/voice-status) work --- ## Quick Testing Script Run all tests at once by copying this into Discord: ``` # Test 1: Join !miku join # Test 2: Check status !miku voice-status # Test 3: Try to block image processing [Upload an image here] # Test 4: Try to block image generation can you draw a picture of a cat? # Test 5: Leave !miku leave # Test 6: Verify features restored [Upload an image here - should work now] ``` --- ## Monitoring Commands ### Watch Bot Logs in Real-Time ```bash docker-compose logs -f miku-bot | grep -i "voice\|block\|pause\|lock" ``` ### Check GPU State ```bash cat /home/koko210Serve/docker/miku-discord/gpu_state.json ``` ### Check for Errors ```bash docker-compose logs miku-bot --tail 200 | grep -i "error\|exception" ``` ### Full Voice-Related Logs ```bash docker-compose logs miku-bot --tail 500 | grep -E "(voice|Voice|VOICE)" ``` --- ## Success Criteria Phase 1 is considered **PASSING** if: ✅ **Core Functionality:** - [x] Bot successfully joins voice channel - [x] Bot successfully leaves voice channel - [x] Status command shows accurate information ✅ **Resource Blocking (5 critical checks):** - [x] Vision model blocked during session - [x] Image generation blocked during session - [x] Profile pictures locked during session - [x] Autonomous engine paused during session - [x] Bipolar mode paused during session ✅ **System Integrity:** - [x] All locks properly released after leaving - [x] GPU switches to AMD during session - [x] No crashes or exceptions during session lifecycle - [x] Text channel responses properly paused ✅ **Logging:** - [x] All lock/unlock actions logged - [x] Clear user-facing error messages - [x] Debug information available for troubleshooting --- ## Known Limitations (Phase 1) ⚠️ **Expected Behaviors (Not Bugs):** - ❌ No actual audio playback yet (Phase 2) - ❌ No LLM streaming to TTS yet (Phase 3) - ❌ Miku doesn't actually respond in voice (Phase 3) - ⚠️ Text input still from text channel (temporary - STT in Phase 4) These are **intentional** Phase 1 limitations and will be addressed in future phases. --- ## Troubleshooting ### Issue: Bot doesn't join voice channel **Check:** ```bash # Verify PyNaCl is installed docker-compose exec miku-bot python -c "import nacl; print('PyNaCl OK')" # Check permissions # Bot needs "Connect" and "Speak" permissions in Discord ``` ### Issue: Resource blocks not working **Check:** ```bash # Verify imports succeeded docker-compose logs miku-bot | grep -i "import\|module" # Check if voice_manager loaded docker-compose logs miku-bot | grep "voice_manager" ``` ### Issue: Commands not recognized **Check:** ```bash # Verify command_router.py imports voice commands docker-compose logs miku-bot | grep "voice command" ``` --- ## Next Steps After Phase 1 Testing Once all tests pass, proceed to: 📋 **Phase 2: Audio Streaming Implementation** - Implement MikuVoiceSource class (discord.AudioSource) - Create WebSocket → Discord audio bridge - Handle audio format conversion - Test actual voice playback See: `VOICE_CHAT_IMPLEMENTATION_PLAN.md` for Phase 2 details