GymBuddy Is Your Personal Fitness Companion

We’re thrilled to spotlight a project by community member Yianni Zouras! In the dynamic world of health and fitness, personalization and convenience are king. Introducing GymBuddy, a revolutionary application built on...

Author: Lydia You

We’re thrilled to spotlight a project by community member Yianni Zouras!

In the dynamic world of health and fitness, personalization and convenience are king. Introducing GymBuddy, a revolutionary application built on the powerful OpenHome voice AI platform, designed to redefine your workout experience. GymBuddy is not just another fitness app; it’s your personalized fitness companion, offering tailored workouts and seamless interaction through its innovative voice interface.

Demo

About the Project

What sets GymBuddy apart is its commitment to flexibility and customization. Unlike traditional fitness apps that offer a one-size-fits-all approach, GymBuddy understands that every individual is unique. You can specify your workout duration, preferred types of exercises, intensity levels, and even incorporate equipment you have at hand. GymBuddy’s intelligent algorithm crafts the perfect routine, just for you, every time.

Features:

  • Customizable workouts targeting specific muscle groups

  • Application that learns your preferences and needs over time

  • Timer for exercises

About the Developer

This project was developed by Yianni Zouras. He studied Computer Science at the University of Southern California and loves to make practical applications using the OpenHome SDK.

Methodology

Included below is a code snippet for starting a guided workout with a background music loop and timed exercises.

Python

class GuidedWorkout(Capability):
    @classmethod
    def register_capability(cls):
        return cls(unique_name="Guided workout", hotwords=["start workout", "begin workout", "guided workout"]) 

    def background_music_loop(self, volume=-5):  # Example: reduce volume by 20dB
        global music_playing
        music = AudioSegment.from_wav(song_fname)
        music_with_adjusted_volume = music.apply_gain(volume)  # Adjust volume
        while music_playing:
            play(music_with_adjusted_volume)
            time.sleep(0.1)  # Short sleep to allow interrupt

    def timed_workout(self, agent, workout):
        # start background looping audio
        global music_playing
        music_playing = True
        music_thread = threading.Thread(target = self.background_music_loop, args=())
        music_thread.start()

        exercises = workout['exercises']
        exercise_prompt = 'In 1 or 2 sentences, introduce the following workout by directly addressing the user will do during a guided workout named: {}. Inform users they should do this workout for {} seconds, that they will perform {} sets, and that they will have {} second long breaks in between.'

        pygame.init()
        pygame.mixer.music.load(song_fname)
        pygame.mixer.music.play(-1)

        for exercise in exercises:
            name = exercise['name']
            duration = exercise['duration']
@@ -61,19 +40,18 @@ def timed_workout(self, agent, workout):
            for i in range(repetitions):
                if i != 0:
                    # rest before every repetition before the first
                    prompt = f"Inform the user that it is time to rest for {rest} seconds."
                    prompt = f"Inform the user that it is time to rest for {rest} seconds. Make sure you respond extremely briefly, with a max of 1 sentence."
                    message = text_to_text(prompt)
                    agent.speak(response=message)
                    time.sleep(rest)
                    logging.info(f"Resting for {rest} seconds")
                prompt = f"Inform users that it is time to perform as many of the following exercise: {exercise} for {duration} seconds."
                    time.sleep(rest)
                prompt = f"Inform users that it is time to perform as many of the following {exercise} that they can in the next {duration} seconds. Make sure you respond extremely briefly, with a max of 1 sentence."
                message = text_to_text(prompt)
                agent.speak(response=message)
                time.sleep(duration)
                logging.info(f"Exercise for {duration} seconds")
                time.sleep(duration)
        # workout completed
        music_playing = False
        music_thread.join()
        pygame.mixer.music.stop()
        prompt = "Congralute the user for completing the guided workout briefly, in 1 or 2 sentences."
        message = text_to_text(prompt)
        agent.speak(response=message)