🏒 About the Project
NHL LiveStream Commentary Agent is a real-time AI-powered hockey commentary system that transforms live NHL game data into engaging, professional audio commentary. Built using Google's Agent Development Kit (ADK), this project demonstrates the power of multi-agent AI systems in creating dynamic, contextual sports broadcasting.
💡 What Inspired Us
The inspiration came from watching live sports broadcasts and noticing how commentary can make or break the viewing experience. We wondered: "What if AI could generate professional-quality, real-time commentary that rivals human broadcasters?"
Key inspirations:
- Real-time Sports Broadcasting: The challenge of creating instant, contextual commentary
- Multi-Agent AI Systems: Exploring how different AI agents can collaborate seamlessly
- Google ADK Capabilities: Pushing the boundaries of what's possible with Google's Agent Development Kit
- Hockey's Fast-Paced Nature: The sport's rapid tempo provides an excellent testbed for real-time AI processing
🎯 What We Learned
Technical Learnings
- Agent Orchestration: How to coordinate multiple AI agents (Data, Commentary, Audio) in real-time
- Session Management: Maintaining context continuity across agent interactions to prevent repetitive commentary
- Data Integrity: Preventing "data leakage" where future game information contaminates early timestamps
- Progressive Statistics: Building realistic game progression from 0-0 to final scores
- WebSocket Streaming: Real-time audio delivery for live broadcasting applications
ADK-Specific Insights
- Sequential Agents: Learned to chain agents effectively using ADK's Sequential Agent pattern
- Custom Agent Implementation: Built complex orchestration logic using ADK's BaseAgent class
- Tool Integration: Created sophisticated tools for momentum analysis, player information, and audio processing
- Session Persistence: Implemented proper session management for production deployments
Sports Data Challenges
- NHL API Complexity: Understanding the intricacies of real-time sports data
- Temporal Consistency: Ensuring commentary flows naturally without timeline conflicts
- Player Name Resolution: Mapping player IDs to human-readable names across different data sources
🔧 How We Built It
Architecture Overview
NHL API → Live Data Collector → Data Agent → Commentary Agent → Audio Agent (Progressive stats) (ADK Analysis) (Two-person) (TTS Stream)
Development Phases
Phase 1: Foundation (Data Agent)
- Built ADK-powered data analysis agent using google.adk.Agent
- Implemented tools for momentum analysis and game context extraction
- Created progressive statistics system to prevent data leakage
Phase 2: Commentary Generation (Commentary Agent)
- Developed dual-commentator system (Play-by-play + Analyst)
- Implemented session-aware processing for natural conversation flow
- Created Alex Chen & Mike Rodriguez personas for authentic broadcasting
Phase 3: Audio Integration (Audio Agent)
- Built custom ADK agent using BaseAgent class for complex orchestration
- Integrated Google Cloud Text-to-Speech with dynamic voice styling
- Implemented WebSocket streaming for real-time audio delivery
Phase 4: Sequential Agent Innovation
- V2: Clean Sequential Agent wrapper for Data + Commentary
- V3: Complete pipeline with integrated audio processing
- Solved agent coordination challenges through custom processing logic
Phase 5: Production Deployment
- Containerized application with Docker
- Deployed to Google Cloud Run with auto-scaling
- Built web demo interface with real-time audio streaming
Key Technologies
- Google ADK: Agent Development Kit for multi-agent coordination
- Google Gemini: Large language model for commentary generation
- Google Cloud TTS: Text-to-speech for audio generation
- NHL API: Real-time game data source
- WebSockets: Live audio streaming
- Python AsyncIO: Concurrent processing
- Docker & Cloud Run: Containerized deployment
🚧 Challenges We Faced
- Agent Coordination Complexity
Challenge: Coordinating three different agents with different response patterns and timing requirements.
Solution: Developed Sequential Agent V3 with custom processing logic that manually orchestrates agent calls rather than relying solely on ADK's built-in Sequential Agent.
# Custom agent orchestration data_response = await self._call_agent_with_message(self.data_agent, message) commentary_input = self._prepare_commentary_input(message, data_response) commentary_response = await self._call_agent_with_message(self.commentary_agent, commentary_input) audio_result = await self.process_commentary_to_audio(commentary_data)
- Data Leakage Prevention
Challenge: Early game timestamps were contaminated with final game statistics, making commentary unrealistic.
Solution: Implemented progressive statistics calculation that only uses events up to the current timestamp:
# Filter events by timestamp to prevent future data leakage filtered_events = [event for event in all_events if event.timestamp <= current_time] progressive_stats = calculate_stats_from_events(filtered_events)
- Session Management & Memory
Challenge: ADK sessions accumulated too much context, leading to repetitive commentary and memory issues.
Solution: Implemented smart session refresh strategy:
- Refresh sessions every 8-10 files
- Maintain recent dialogue history for context
- Compact narrative state between sessions
- Real-time Audio Processing
Challenge: Generating and streaming audio in real-time while maintaining chronological order.
Solution: Built sequential processing pipeline:
- Process files in strict chronological order
- Generate audio immediately after commentary
- Use WebSocket for live streaming delivery
- NHL API Data Complexity
Challenge: NHL API returns complex nested data structures with inconsistent player naming.
Solution: Created comprehensive data enhancement system:
- Player name resolution with fallback strategies
- Spatial coordinate conversion for context
- Robust error handling for missing data
- Production Deployment
Challenge: Deploying multi-agent system with real-time requirements to cloud infrastructure.
Solution:
- Containerized with optimized Docker images
- Used Cloud Run for auto-scaling
- Implemented proper environment variable management
- Created comprehensive logging and monitoring
🎉 Results & Impact
Technical Achievements
- Sub-5 Second Latency: From NHL API to audio output
- Natural Commentary Flow: Eliminated repetitive AI commentary through session management
- Production Ready: Deployed and running on Google Cloud Run
- Scalable Architecture: Handles multiple concurrent games
Innovation Highlights
- Sequential Agent V3: Novel approach to multi-agent coordination
- Progressive Statistics: Solved data leakage in sports AI applications
- Live Game Board: Pure state tracking with anti-hallucination features
- Real-time Audio Streaming: WebSocket-based live commentary delivery
Demo Capabilities
- Process any NHL game by ID
- Generate realistic two-person commentary
- Stream live audio to web clients
- Support multiple concurrent games
- Maintain commentary quality across extended periods
🚀 Future Enhancements
- Multi-language Support: Expand beyond English commentary
- Visual Integration: Add player tracking and visual analysis
- Advanced Analytics: Deeper statistical analysis and predictions
- Broadcast Integration: Direct integration with streaming platforms
- Fan Interaction: Real-time fan questions and commentary requests
This project showcases the incredible potential of Google's ADK in creating sophisticated, real-world AI applications that can compete with traditional human-driven processes. The combination of intelligent agents, real-time processing, and cloud deployment creates a foundation for the future of AI-powered sports broadcasting.
Built With
- gemini
- google-adk
- google-cloud
- python
Log in or sign up for Devpost to join the conversation.