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.
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
- 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
- Firebase Authentication (FREE tier)
- Email/Password registration and login
- Anonymous login fallback
- Secure user session management
- Cloud Firestore (FREE tier) for report storage
- User-specific report history
- Persistent conversation data
- Material 3 design
- Dark mode support
- Animated microphone button with listening indicator
- Real-time transcript display
- Professional report layout
- 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
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.1lib/
โโโ 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
-
Flutter SDK: Install from flutter.dev
flutter --version # Verify installation -
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)
-
Gemini API Key:
- Visit Google AI Studio
- Create a FREE API key
- No credit card required!
-
Clone or navigate to the project directory
cd /home/kushagra/Documents/code/Doctor -
Install dependencies
flutter pub get
-
Configure environment variables
Edit the
.envfile 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
-
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
-
Run the app
# For Android flutter run # For Web flutter run -d chrome # For specific device flutter devices flutter run -d <device_id>
- Android: Primary target, all features work
- Web: Compatible, some permissions may require browser setup
- iOS: Requires Xcode and iOS provisioning
- Windows/Linux/macOS: May need platform-specific microphone permissions
- 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
- Choose from available AI doctors
- Only "General Physician" is free (demo restriction)
- Premium doctors show as locked
- 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
If you mention emergency keywords like:
- "chest pain"
- "can't breathe"
- "suicidal thoughts"
- "severe bleeding"
The app immediately displays emergency contact information.
- Tap the "Stop" button in the app bar
- A medical report is automatically generated
- View your consultation summary, symptoms, and advice
- Reports are saved to your account
- Access past consultations anytime
- Share or export reports (feature placeholder)
- 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
Solution: Enable microphone permission in system settings
- Android: Settings > Apps > Doctor > Permissions > Microphone
- Web: Browser will prompt for permission
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
Solution: Check internet connection
- Google Speech-to-Text requires internet
- Ensure stable network connection
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
# Clean and rebuild
flutter clean
flutter pub get
flutter run- 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
- Simple setState for most screens
- StreamBuilder for authentication state
- Service-based architecture for clean separation
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
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
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)
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!
This project is for educational purposes. Medical advice features are demonstration only.
- 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
For technical issues:
- Check this README
- Review error messages in console
- Verify all API keys are configured
- 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!