How amritanshu2005/realtime-voice-video-ai-gym-trainer works
Purpose and runtime
A Python/Streamlit realtime gym trainer: webcam frames are pose-estimated, exercise-specific logic counts reps and detects form issues, and coaching is delivered through UI and voice. Run with streamlit run main.py; the primary entry point is main.py.
Application shell and session lifecycle
main.py owns the Streamlit application flow, likely composing login, exercise selection, live video, metrics, and coaching. Streamlit session state is initialized and maintained through services/state/session_defaults.py; shared exercise abstractions belong in core/base_exercise.py.
Vision and pose-model boundary
The video-processing boundary is services/vision/exercise_video_processor.py: it should receive webcam/video frames, invoke pose estimation, and return annotated frames plus structured exercise observations. The packaged MediaPipe model is ml_models/pose_landmarker_full.task. This isolates camera/OpenCV/MediaPipe concerns from workout rules and UI.
Exercise analysis and repetition state machines
Exercise-specific posture analysis is split by movement: detectors/biceps_curl.py, detectors/squat.py, detectors/pushup.py, detectors/lunges.py, and detectors/shoulder_press.py. These modules are the core domain layer for landmark interpretation, rep transitions, and corrective signals; core/base_exercise.py is the likely common contract for interchangeable detector implementations.
Coaching pipeline
Detected form events, completed repetitions, and session context feed coaching services. services/coaching/voice_pipeline.py coordinates coaching delivery; services/coaching/llm.py is the external/AI language-generation boundary, while services/coaching/tts.py converts coaching text to audio. Internet connectivity is relevant when the LLM or cloud voice capabilities are used.
Metrics, configuration, and persistence
Workout configuration is centralized in services/config/workout_config.py. Live counters and workout summaries are handled by services/tracking/metrics.py. Durable exercise/session history is abstracted behind services/persistence/exercise_repository.py, keeping storage decisions separate from detector and Streamlit code.
Access and presentation boundaries
Authentication gating is isolated in services/auth/login_wall.py. UI styling is loaded via services/ui/style_loader.py and static assets such as static/style.css. The browser-facing layer should consume processed frames, metrics, and coaching outputs rather than directly depend on vision or detector internals.
Main entry points: main.py App shell · base_exercise.py Exercise contract · exercise_video_processor.py Video processor · voice_pipeline.py Voice pipeline
Components 18
Streamlit UI
- App shell · Composes the live workout experience.
main.py - Login gate
services/auth/login_wall.py - Style loader · Loads browser styling assets.
services/ui/style_loader.py
Vision & Analysis
- Exercise contract · Common interface for exercise detectors.
core/base_exercise.py - Video processor · Converts frames into annotations and exercise observations.
services/vision/exercise_video_processor.py - Pose landmarker
ml_models/pose_landmarker_full.task - Biceps curl
detectors/biceps_curl.py - Squat
detectors/squat.py - Push-up
detectors/pushup.py - Lunges
detectors/lunges.py - Shoulder press
detectors/shoulder_press.py
Coaching
- Voice pipeline · Delivers coaching from workout events and context.
services/coaching/voice_pipeline.py - Coaching LLM · Generates coaching language.
services/coaching/llm.py - Text to speech · Converts coaching text to audio.
services/coaching/tts.py
Workout State & Data
- Session defaults · Initializes Streamlit workout state.
services/state/session_defaults.py - Workout config
services/config/workout_config.py - Live metrics · Maintains counters and workout summaries.
services/tracking/metrics.py - Exercise history · Stores durable exercise and session history.
services/persistence/exercise_repository.py
Connections 20
- App shell → Login gate: gates access
- App shell → Style loader: loads styling
- App shell → Session defaults: initializes
- App shell → Workout config: selects workout
- App shell → Video processor: webcam frames
- App shell → Live metrics: renders metrics
- App shell → Voice pipeline: renders coaching
- Video processor → Pose landmarker: estimates pose
- Video processor → Exercise contract: routes observations
- Exercise contract → Biceps curl: implemented by
- Exercise contract → Squat: implemented by
- Exercise contract → Push-up: implemented by
- Exercise contract → Lunges: implemented by
- Exercise contract → Shoulder press: implemented by
- Video processor → Live metrics: reps and form events
- Live metrics → Exercise history: persists summaries
- Live metrics → Voice pipeline: session context
- Voice pipeline → Coaching LLM: coaching prompt
- Coaching LLM → Text to speech: coaching text
- Voice pipeline → App shell: audio and guidance