ilia bdbf09a9ac feat: Implement voice I/O services (TICKET-006, TICKET-010, TICKET-014)
 TICKET-006: Wake-word Detection Service
- Implemented wake-word detection using openWakeWord
- HTTP/WebSocket server on port 8002
- Real-time detection with configurable threshold
- Event emission for ASR integration
- Location: home-voice-agent/wake-word/

 TICKET-010: ASR Service
- Implemented ASR using faster-whisper
- HTTP endpoint for file transcription
- WebSocket endpoint for streaming transcription
- Support for multiple audio formats
- Auto language detection
- GPU acceleration support
- Location: home-voice-agent/asr/

 TICKET-014: TTS Service
- Implemented TTS using Piper
- HTTP endpoint for text-to-speech synthesis
- Low-latency processing (< 500ms)
- Multiple voice support
- WAV audio output
- Location: home-voice-agent/tts/

 TICKET-047: Updated Hardware Purchases
- Marked Pi5 kit, SSD, microphone, and speakers as purchased
- Updated progress log with purchase status

📚 Documentation:
- Added VOICE_SERVICES_README.md with complete testing guide
- Each service includes README.md with usage instructions
- All services ready for Pi5 deployment

🧪 Testing:
- Created test files for each service
- All imports validated
- FastAPI apps created successfully
- Code passes syntax validation

🚀 Ready for:
- Pi5 deployment
- End-to-end voice flow testing
- Integration with MCP server

Files Added:
- wake-word/detector.py
- wake-word/server.py
- wake-word/requirements.txt
- wake-word/README.md
- wake-word/test_detector.py
- asr/service.py
- asr/server.py
- asr/requirements.txt
- asr/README.md
- asr/test_service.py
- tts/service.py
- tts/server.py
- tts/requirements.txt
- tts/README.md
- tts/test_service.py
- VOICE_SERVICES_README.md

Files Modified:
- tickets/done/TICKET-047_hardware-purchases.md

Files Moved:
- tickets/backlog/TICKET-006_prototype-wake-word-node.md → tickets/done/
- tickets/backlog/TICKET-010_streaming-asr-service.md → tickets/done/
- tickets/backlog/TICKET-014_tts-service.md → tickets/done/
2026-01-12 22:22:38 -05:00

77 lines
2.9 KiB
Python

#!/usr/bin/env python3
"""
Test script for conversation summarization.
"""
import sys
from pathlib import Path
# Add parent directory to path
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
from conversation.summarization.summarizer import get_summarizer
from conversation.summarization.retention import get_retention_manager, RetentionPolicy
def test_summarization():
"""Test summarization functionality."""
print("=" * 60)
print("Conversation Summarization Test")
print("=" * 60)
summarizer = get_summarizer()
# Test should_summarize
print("\n1. Testing summarization threshold...")
should = summarizer.should_summarize(message_count=25, total_tokens=1000)
print(f" ✅ 25 messages, 1000 tokens: should_summarize = {should} (should be True)")
should = summarizer.should_summarize(message_count=10, total_tokens=3000)
print(f" ✅ 10 messages, 3000 tokens: should_summarize = {should} (should be False)")
should = summarizer.should_summarize(message_count=10, total_tokens=5000)
print(f" ✅ 10 messages, 5000 tokens: should_summarize = {should} (should be True)")
# Test summarization
print("\n2. Testing summarization...")
messages = [
{"role": "user", "content": "What time is it?"},
{"role": "assistant", "content": "It's 3:45 PM EST."},
{"role": "user", "content": "Add 'buy groceries' to my todo list"},
{"role": "assistant", "content": "I've added 'buy groceries' to your todo list."},
{"role": "user", "content": "What's the weather like?"},
{"role": "assistant", "content": "It's sunny and 72°F in your area."},
]
summary = summarizer.summarize(messages, agent_type="family")
print(f" ✅ Summary created:")
print(f" Summary: {summary['summary']}")
print(f" Key points: {len(summary['key_points'])}")
print(f" Message count: {summary['message_count']}")
# Test pruning
print("\n3. Testing message pruning...")
pruned = summarizer.prune_messages(
messages,
keep_recent=3,
summary=summary
)
print(f" ✅ Pruned messages: {len(pruned)} (original: {len(messages)})")
print(f" First message role: {pruned[0]['role']} (should be 'system' with summary)")
print(f" Recent messages kept: {len([m for m in pruned if m['role'] != 'system'])}")
# Test retention
print("\n4. Testing retention manager...")
retention = get_retention_manager()
session_count = retention.get_session_count()
print(f" ✅ Current session count: {session_count}")
old_sessions = retention.list_old_sessions()
print(f" ✅ Old sessions (>{retention.policy.max_age_days} days): {len(old_sessions)}")
print("\n" + "=" * 60)
print("✅ Summarization tests complete!")
print("=" * 60)
if __name__ == "__main__":
test_summarization()