Skip to content

tawab2001/activemind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Voice Mental Performance Coach

A voice-first AI-powered mental performance coach for athletes, built with Streamlit, CrewAI, Ollama, and voice technologies. The app allows athletes to create profiles, engage in interactive voice-based consultations, receive personalized coaching recommendations, and get daily audio reminders. It focuses on mental aspects like confidence, stress management, focus, and motivation.

Features

  • Interactive Voice Consultation: Natural conversation with Coach Alex using speech recognition and TTS.
  • Personalized Coaching: Generates tailored mental performance strategies based on athlete profile and responses.
  • Data Collection: Collects athlete details (age, sport, goals) through conversational flow.
  • Assessment Questions: Asks and processes responses to personalized questions.
  • Coaching Analysis: Provides comprehensive analysis with key insights and action plans.
  • Audio Output: Uses ElevenLabs TTS for high-quality voice (fallback to gTTS or pyttsx3).
  • Speech Recognition: Supports voice input using microphone.
  • Database Persistence: Saves athlete profiles and consultation logs in SQLite.
  • Daily Reminders: Generates and plays audio reminders with coaching tips.
  • Streamlit UI: User-friendly interface for profile setup, assessment, and coaching.
  • Pygame Audio Playback: Handles audio playback for a seamless experience.

Requirements

  • Hardware:
    • Microphone for voice input.
    • Speakers/headphones for audio output.
    • Quiet environment for speech recognition.
  • Software:
    • Python 3.10 or higher (tested on 3.11).
    • Ollama with a model (e.g., llama3.2:latest or phi-2 for lower memory usage).
    • Internet connection for ElevenLabs TTS (optional; fallback to offline TTS).
  • API Keys:
    • ElevenLabs API key (for high-quality TTS; get from ElevenLabs).
  • System Memory:
    • At least 4 GB RAM (for llama3.2:latest) or 2 GB (for phi-2).

Installation

  1. Clone the Repository (if applicable):

    git clone <repository_url>
    cd voice.py
    
  2. Set Up Virtual Environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install Dependencies:

    pip install streamlit crewai langchain-ollama pyttsx3 speechrecognition gtts pygame requests
    
  4. Install Ollama:

    • Download and install Ollama from https://ollama.com/download.
    • Pull and run the model:
      ollama pull llama3.2:latest  # Or phi-2 for lower memory
      ollama serve
      
    • Ensure it's running at http://localhost:11434.
  5. Set ElevenLabs API Key:

    • Add to your environment:
      export ELEVENLABS_API_KEY="your_elevenlabs_api_key_here"
      
    • Or update the script's ELEVENLABS_API_KEY variable.
  6. Set Up Audio Dependencies:

    • On Windows, install Microsoft Visual C++ Build Tools for pyaudio (part of speechrecognition): Download here.

Usage

  1. Run the App:

    streamlit run voice.py
    
    • Open your browser to http://localhost:8501.
  2. Interact with the App:

    • Profile Setup: Enter your name, age, weight, height, sport type, experience level, training frequency, and goals.
    • Welcome Phase: Listen to Coach Alex's welcome audio and respond.
    • Assessment Phase: Answer 6 personalized questions via voice or text.
    • Coaching Phase: Receive personalized coaching analysis, recommendations with confidence scores (e.g., "90%", "85%"), and action plans.
    • Audio and JSON: Play/download audio, view JSON output with recommendations and confidence scores.
    • Daily Reminders: Generate and download daily audio reminders.
    • Save Session: Save your profile and session data to SQLite.
  3. Example JSON Output (includes confidence scores):

    {
      "session_id": "<uuid>",
      "athlete_name": "<name>",
      "sport_type": "<sport>",
      "athlete_level": "<level>",
      "training_frequency": <number>,
      "goals": ["<goal1>", "<goal2>"],
      "responses": {
        "question_1": "<response>",
        ...
      },
      "recommendations": [
        {
          "recommendation": "<recommendation>",
          "justification": "<justification>",
          "confidence_score": "90%"
        },
        ...
      ]
    }
  4. Audio Playback:

    • Uses pygame for automatic playback.
    • Audio includes recommendations with confidence scores (e.g., "Practice deep breathing... with 90% confidence").

Configuration

  • Ollama Model: Change Config.MODEL_NAME to a different model (e.g., llama3.2:latest for higher accuracy, but requires more RAM).
  • API Base: Update Config.API_BASE if Ollama runs on a different port.
  • ElevenLabs Voice ID: Change ELEVENLABS_VOICE_ID for a different voice (e.g., "pNInz6obpgDQGcFmaJgB" for Adam).
  • Database Path: Change DATABASE_PATH if you want a different SQLite file location.
  • Max Response Length: Adjust MAX_RESPONSE_LENGTH for TTS response length.

Troubleshooting

  • **StreamlitAPIException (Duplicate Forms

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors