Stacy is a voice-enabled AI safety companion designed to provide immediate support during moments of distress. This is the Pre-MVP web application that demonstrates the core conversation flow using OpenAI's Realtime API.
- Voice Interaction: Real-time voice conversation with AI using WebRTC
- Distress Detection: Keyword and sentiment analysis to detect emergency situations
- Location Tracking: GPS integration for location sharing
- Emergency Triggers: Quick access to emergency functions
- Safety-Focused AI: Specialized AI responses for safety situations
- SMS integration via Twilio
- Google Maps API for safe navigation
- Emergency contact management
- iOS/Android mobile apps
- Node.js 18+
- OpenAI API key with Realtime API access
- Clone and install dependencies:
git clone <repository-url>
cd djiosmopocket3
npm install- Configure environment variables:
cp env.example .envEdit .env and add your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key_here
PORT=3000
NODE_ENV=development
- Start the server:
npm start
# or for development with auto-reload:
npm run dev- Open the application:
Navigate to
http://localhost:3000in your web browser.
- Click and hold the microphone button
- Speak naturally about your situation
- Release to send audio to Stacy
- Listen to Stacy's response and guidance
- Emergency Button: Triggers immediate emergency mode
- Location Sharing: Shares current GPS coordinates
- Distress Detection: Automatically detects keywords like "help", "scared", "following me"
Normal Safety Check:
- "I'm walking home alone at night"
- Stacy provides general safety tips
Medium Distress:
- "I feel uncomfortable, there's someone behind me"
- Stacy suggests moving to a safe location and staying alert
High Distress:
- "Help! Someone is following me!"
- Stacy immediately suggests emergency actions and location sharing
GET /- Main application interfaceGET /health- Health check with connection statsGET /api/stats- Detailed server statisticsWebSocket /- Real-time communication endpoint
- server.js: Main Express server with WebSocket handling
- realtime-handler.js: OpenAI Realtime API integration
- WebSocket Server: Manages client connections
- index.html: Main UI with safety-focused design
- app.js: WebRTC client and WebSocket communication
- styles.css: Modern, accessible styling
- Client captures audio via WebRTC
- Audio sent to server via WebSocket
- Server forwards to OpenAI Realtime API
- AI response analyzed for distress indicators
- Response sent back to client with safety recommendations
- High Priority: "help", "emergency", "following me", "danger"
- Medium Priority: "scared", "unsafe", "uncomfortable", "suspicious"
- Location Keywords: "lost", "alone", "dark area", "isolated"
- Low Distress: General safety advice and tips
- Medium Distress: Specific guidance and heightened awareness
- High Distress: Immediate emergency actions and escalation
- Test voice recording functionality
- Try various distress scenarios
- Verify emergency button triggers
- Test location sharing permissions
// Test phrases for different distress levels
const testPhrases = [
"I'm walking home", // Low
"Someone seems to be following me", // Medium
"Help! I'm in danger!", // High
"I'm lost and scared", // Medium-High
];- Chrome/Edge: Full WebRTC support
- Firefox: Full support
- Safari: WebRTC support with some limitations
- Mobile browsers: Touch-optimized interface
- React Native or Swift/Kotlin native apps
- Background location tracking
- Push notifications for safety alerts
- Integration with local emergency services
- AI-powered safe route planning
- Community safety features
- Wearable device support
- End-to-end encryption
- Multi-language support
- Enterprise safety solutions
- Integration with existing security systems
Microphone not working:
- Check browser permissions for microphone access
- Ensure HTTPS for production (required for WebRTC)
- Try different browsers
WebSocket connection fails:
- Check if server is running on correct port
- Verify firewall settings
- Check browser console for errors
OpenAI API errors:
- Verify API key is correct and has Realtime API access
- Check API usage limits
- Monitor server logs for detailed error messages
Location not available:
- Enable location services in browser
- Grant location permissions when prompted
- Check if HTTPS is enabled (required for geolocation)
Set NODE_ENV=development to enable detailed logging:
NODE_ENV=development npm start- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly with various safety scenarios
- Submit a pull request
- Prioritize user safety in all features
- Test with real-world safety scenarios
- Maintain accessibility standards
- Follow security best practices
MIT License - see LICENSE file for details.
This is a prototype application for demonstration purposes. In real emergencies, always contact local emergency services directly (911 in the US, 999 in the UK, etc.).
Stacy is designed to supplement, not replace, traditional emergency services and personal safety practices.