Skip to content
Kushagra2024-codePublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง ๐Ÿ“ฑ AI Medical Voice Agent App

A comprehensive Flutter application that implements an AI-powered medical voice assistant with real-time speech-to-text, AI responses from Google Gemini, multiple doctor specializations, medical report generation, and comprehensive safety features.

โš ๏ธ IMPORTANT MEDICAL DISCLAIMER

THIS APPLICATION IS FOR EDUCATIONAL PURPOSES ONLY

  • This app does NOT provide medical advice, diagnosis, or treatment
  • It is NOT a substitute for professional medical consultation
  • Always consult with qualified healthcare providers for medical concerns
  • In case of emergency, call 911 or your local emergency services immediately
  • The AI responses are informational and should not be relied upon for medical decisions

โœจ Features

๐ŸŽฏ Core Functionality

  • Voice-Based Consultations: Real-time speech-to-text using Google Speech Recognition
  • AI Doctor Responses: Powered by Google Gemini API (free tier)
  • Multiple Doctor Specializations:
    • ๐Ÿ‘จโ€โš•๏ธ General Physician (FREE)
    • โค๏ธ Cardiologist (Premium - Locked)
    • ๐Ÿ‘ถ Pediatrician (Premium - Locked)
    • ๐Ÿง  Mental Health Assistant (Premium - Locked)
  • Text-to-Speech: Natural voice responses using Flutter TTS
  • Medical Reports: AI-generated consultation summaries with symptoms, advice, and warnings
  • Emergency Detection: Automatic detection of emergency keywords with immediate safety responses

๐Ÿ” Authentication & Security

  • Firebase Authentication (FREE tier)
  • Email/Password registration and login
  • Anonymous login fallback
  • Secure user session management

๐Ÿ’พ Data Storage

  • Cloud Firestore (FREE tier) for report storage
  • User-specific report history
  • Persistent conversation data

๐ŸŽจ User Interface

  • Material 3 design
  • Dark mode support
  • Animated microphone button with listening indicator
  • Real-time transcript display
  • Professional report layout

๐Ÿ› ๏ธ Tech Stack

FREE Services Only โœ…

  • Flutter: Latest stable SDK
  • Google Gemini API: Free tier (gemini-pro model)
  • Google Speech-to-Text: Free quota via speech_to_text package
  • Firebase Authentication: FREE tier
  • Cloud Firestore: FREE tier
  • Flutter TTS: Free, open-source

Key Dependencies

dependencies:
  flutter_sdk: latest
  firebase_core: ^3.8.1
  firebase_auth: ^5.3.4
  cloud_firestore: ^5.6.0
  google_generative_ai: ^0.4.6
  speech_to_text: ^7.0.0
  flutter_tts: ^4.2.0
  permission_handler: ^11.3.1
  flutter_dotenv: ^5.2.1
  provider: ^6.1.2
  http: ^1.2.2
  intl: ^0.19.0
  uuid: ^4.5.1

๐Ÿ“ Project Structure

lib/
โ”œโ”€โ”€ main.dart                    # App entry point
โ”œโ”€โ”€ app.dart                     # Main app widget with theming
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ env.dart                # Environment variable loader
โ”‚   โ””โ”€โ”€ gemini_config.dart      # Gemini API configuration
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ doctors.dart            # Doctor definitions with system prompts
โ”œโ”€โ”€ models/
โ”‚   โ”œโ”€โ”€ doctor.dart             # Doctor model
โ”‚   โ””โ”€โ”€ report.dart             # Medical report model
โ”œโ”€โ”€ services/
โ”‚   โ”œโ”€โ”€ auth_service.dart       # Firebase authentication
โ”‚   โ”œโ”€โ”€ speech_service.dart     # Speech-to-text service
โ”‚   โ”œโ”€โ”€ gemini_service.dart     # AI conversation service
โ”‚   โ”œโ”€โ”€ tts_service.dart        # Text-to-speech service
โ”‚   โ””โ”€โ”€ report_service.dart     # Report generation & storage
โ”œโ”€โ”€ widgets/
โ”‚   โ”œโ”€โ”€ doctor_card.dart        # Doctor selection card
โ”‚   โ”œโ”€โ”€ mic_button.dart         # Animated microphone button
โ”‚   โ””โ”€โ”€ transcript_view.dart    # Conversation transcript display
โ””โ”€โ”€ screens/
    โ”œโ”€โ”€ splash_screen.dart      # Initial loading screen
    โ”œโ”€โ”€ login_screen.dart       # Authentication screen
    โ”œโ”€โ”€ doctor_select_screen.dart  # Doctor selection
    โ”œโ”€โ”€ consultation_screen.dart   # Voice consultation
    โ””โ”€โ”€ report_screen.dart      # Medical report display

๐Ÿš€ Setup Instructions

Prerequisites

  1. Flutter SDK: Install from flutter.dev

    flutter --version  # Verify installation
  2. Firebase Project:

    • Go to Firebase Console
    • Create a new project (FREE plan)
    • Enable Authentication (Email/Password and Anonymous)
    • Enable Cloud Firestore
    • Download configuration files (already configured in this project)
  3. Gemini API Key:

Installation Steps

  1. Clone or navigate to the project directory

    cd /home/kushagra/Documents/code/Doctor
  2. Install dependencies

    flutter pub get
  3. Configure environment variables

    Edit the .env file in the root directory:

    # REQUIRED: Get your free API key from https://makersuite.google.com/app/apikey
    GEMINI_API_KEY=your_actual_gemini_api_key_here
    
    # OPTIONAL: AssemblyAI key (not needed, we use Google Speech-to-Text)
    ASSEMBLY_AI_KEY=optional
  4. Verify Firebase configuration

    The project already has Firebase configured. If you want to use your own Firebase project:

    # Install FlutterFire CLI
    dart pub global activate flutterfire_cli
    
    # Configure your Firebase project
    flutterfire configure
  5. Run the app

    # For Android
    flutter run
    
    # For Web
    flutter run -d chrome
    
    # For specific device
    flutter devices
    flutter run -d <device_id>

๐Ÿ“ฑ Platform Support

โœ… Fully Supported

  • Android: Primary target, all features work
  • Web: Compatible, some permissions may require browser setup

โš ๏ธ Requires Additional Setup

  • iOS: Requires Xcode and iOS provisioning
  • Windows/Linux/macOS: May need platform-specific microphone permissions

๐ŸŽฎ How to Use

1. First Launch

  • The app opens to a splash screen
  • If not logged in, you'll see the login screen
  • Create an account with email/password or continue as guest

2. Select a Doctor

  • Choose from available AI doctors
  • Only "General Physician" is free (demo restriction)
  • Premium doctors show as locked

3. Start Consultation

  • Tap the microphone button to start speaking
  • Speak your health concerns clearly
  • The AI doctor will respond with advice
  • Conversation is displayed in real-time

4. Emergency Detection

If you mention emergency keywords like:

  • "chest pain"
  • "can't breathe"
  • "suicidal thoughts"
  • "severe bleeding"

The app immediately displays emergency contact information.

5. End Consultation

  • Tap the "Stop" button in the app bar
  • A medical report is automatically generated
  • View your consultation summary, symptoms, and advice

6. View Reports

  • Reports are saved to your account
  • Access past consultations anytime
  • Share or export reports (feature placeholder)

๐Ÿ”’ Privacy & Security

  • No Payment Data: No credit cards or paid services
  • Firebase Security: User authentication and data isolation
  • Local Processing: Speech recognition happens on-device when possible
  • Encrypted Storage: Firebase handles encryption
  • No Personal Health Data: App is educational only

๐Ÿ› Troubleshooting

Microphone Permission Denied

Solution: Enable microphone permission in system settings
- Android: Settings > Apps > Doctor > Permissions > Microphone
- Web: Browser will prompt for permission

Gemini API Error

Error: "API key not configured" or "Invalid API key"
Solution: 
1. Get a free API key from https://makersuite.google.com/app/apikey
2. Add it to .env file
3. Restart the app

Speech Recognition Not Working

Solution: Check internet connection
- Google Speech-to-Text requires internet
- Ensure stable network connection

Firebase Error

Error: "Firebase initialization failed"
Solution: 
1. Check firebase_options.dart exists
2. Verify Firebase project is active
3. Enable Authentication and Firestore in Firebase Console

Build Errors

# Clean and rebuild
flutter clean
flutter pub get
flutter run

๐Ÿ—๏ธ Architecture

Service Layer

  • AuthService: Handles user authentication
  • SpeechService: Converts speech to text
  • GeminiService: AI conversation and report generation
  • TtsService: Converts text to speech
  • ReportService: Saves and retrieves medical reports

State Management

  • Simple setState for most screens
  • StreamBuilder for authentication state
  • Service-based architecture for clean separation

AI System Prompts

Each doctor has a specialized system prompt that:

  • Defines their medical specialty
  • Sets conversation style
  • Enforces safety rules (no diagnosis, no prescriptions)
  • Includes emergency detection guidelines

๐Ÿ“Š Firebase Firestore Structure

reports/
  โ”œโ”€โ”€ {reportId}/
  โ”‚   โ”œโ”€โ”€ id: string
  โ”‚   โ”œโ”€โ”€ userId: string
  โ”‚   โ”œโ”€โ”€ doctorId: string
  โ”‚   โ”œโ”€โ”€ doctorName: string
  โ”‚   โ”œโ”€โ”€ timestamp: timestamp
  โ”‚   โ”œโ”€โ”€ summary: string
  โ”‚   โ”œโ”€โ”€ symptoms: array<string>
  โ”‚   โ”œโ”€โ”€ possibleCauses: array<string>
  โ”‚   โ”œโ”€โ”€ advice: array<string>
  โ”‚   โ”œโ”€โ”€ emergencyWarning: string
  โ”‚   โ””โ”€โ”€ fullTranscript: string

๐Ÿ”ฎ Future Enhancements (Not Implemented)

These features would require paid services:

  • โŒ Real payment system (would need Stripe/PayPal)
  • โŒ Advanced AI models (would need paid API)
  • โŒ Cloud storage for audio files (would exceed free tier)
  • โŒ Push notifications (requires paid plan)
  • โŒ SMS alerts (requires Twilio/paid service)

๐Ÿค Contributing

This is an educational project demonstrating:

  • Flutter development best practices
  • AI integration with free APIs
  • Voice interaction implementation
  • Firebase authentication and database
  • Medical safety considerations

Feel free to fork and enhance for learning purposes!

๐Ÿ“„ License

This project is for educational purposes. Medical advice features are demonstration only.

๐Ÿ™ Acknowledgments

  • Google Gemini: Free AI API
  • Firebase: Free backend services
  • Flutter: Cross-platform framework
  • Flutter TTS: Open-source text-to-speech
  • Speech-to-Text: Google's free speech recognition

๐Ÿ“ž Support

For technical issues:

  1. Check this README
  2. Review error messages in console
  3. Verify all API keys are configured
  4. Ensure all dependencies are installed

For medical emergencies:

  • Call 911 (US)
  • Call 999 (UK)
  • Call 112 (EU)
  • Or your local emergency number

Remember: This app is a demonstration tool for educational purposes only. Always consult real healthcare professionals for medical advice.

Built with โค๏ธ using Flutter and FREE services only!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages