Early-call, consent-based fraud detection powered by Azure AI Speech and Google Gemini
TrustLens is an intelligent fraud detection system that helps users verify suspicious calls, messages, and links before harm occurs. By analyzing the first 20 seconds of a call or examining text content, TrustLens provides an early risk signal to help users make informed decisions.
- Real-time Audio Analysis: Record the first 20 seconds of suspicious calls
- Consent-Based: User must explicitly enable fraud scanning
- Speech-to-Text: Powered by Azure Cognitive Services
- AI Risk Assessment: Google Gemini analyzes conversation patterns
- Privacy-First: Audio is processed in memory only, never saved
- Analyze suspicious SMS, emails, or chat messages
- Detect common scam patterns and phishing attempts
- Get instant risk assessment with detailed indicators
- Verify suspicious URLs without visiting them
- URL-based analysis (safe - no crawling or fetching)
- Identify potentially malicious domains and patterns
Frontend:
- React 19.2
- React Router 7.11 (SPA routing)
- Vite 7.2 (Build tool)
- Web Audio API (Audio recording)
Backend:
- Node.js + Express
- Azure Cognitive Services Speech SDK
- Google Gemini AI API
- Multer (Multipart form data)
Audio β Azure Speech β Transcript β Gemini β Fraud Result
β
[Memory Only]
β
[Discarded After Processing]
TrustLens/
βββ src/ # Frontend source
β βββ components/ # React components
β β βββ Dashboard.jsx # Main landing page
β β βββ VoiceFraudPage.jsx # Voice call detection flow
β β βββ TextFraudPage.jsx # Message analysis
β β βββ LinkFraudPage.jsx # URL verification
β β βββ IncomingCallScreen.jsx
β β βββ ConsentModal.jsx # User consent UI
β β βββ ScanningScreen.jsx # Recording progress
β β βββ ResultScreen.jsx # Risk assessment display
β βββ hooks/
β β βββ useAudioCapture.js # Audio recording logic
β βββ App.jsx # Main app component
β βββ main.jsx # Entry point
β
βββ backend/ # Backend API
β βββ services/
β β βββ speechService.js # Azure Speech integration
β β βββ geminiService.js # Google Gemini integration
β β βββ aiService.js # AI provider abstraction
β βββ prompts/
β β βββ fraudPrompts.js # Gemini prompt engineering
β βββ server.js # Express server
β
βββ public/ # Static assets
- Node.js 16 or higher
- Azure Cognitive Services Speech subscription
- Google Gemini API key
- Modern web browser with microphone access
git clone <repository-url>
cd TrustLensFrontend:
npm installBackend:
cd backend
npm installCreate a .env file in the backend/ folder:
# Azure Speech Service
AZURE_SPEECH_KEY=your_azure_speech_key_here
AZURE_SPEECH_REGION=your_azure_region_here
# Google Gemini AI
GEMINI_API_KEY=your_gemini_api_key_here
# AI Provider (optional, default: gemini)
AI_PROVIDER=geminiGetting API Keys:
- Azure Speech: portal.azure.com β Create Speech resource
- Google Gemini: aistudio.google.com/apikey
Terminal 1 - Backend:
cd backend
npm start
# Server runs on http://localhost:3001Terminal 2 - Frontend:
npm run dev
# App runs on http://localhost:5173Navigate to http://localhost:5173 and grant microphone permissions when prompted.
- Navigate to the Voice Call Scan section from the dashboard
- Click "Safe Scan" to enable fraud detection
- Accept consent to allow microphone access
- Speak naturally for up to 20 seconds
- View the Early Risk Signal and detailed analysis
- Select Message Scan from the dashboard
- Paste the suspicious message (up to 5,000 characters)
- Click "Analyze Message"
- Review risk indicators and recommendations
- Choose Link Check from the dashboard
- Paste the suspicious URL
- Click "Check Link"
- See the risk assessment (no URL is visited)
- β No Audio Storage: Audio is processed in memory only, never written to disk
- β No Transcript Storage: Text is analyzed and immediately discarded
- β No Database: Zero data persistence
- β User Consent: Explicit permission required for audio recording
- β Local Processing: Recording happens in the browser
- β Secure Transmission: Audio sent via HTTPS to backend
- Uses "Early Risk Signal" terminology instead of "confidence" or "accuracy"
- Clearly states analysis is based on the first 20 seconds only
- Does not claim definitive fraud detection
- Provides probabilistic risk assessment, not absolute judgment
Frontend:
npm run dev # Start dev server with HMR
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLintBackend:
npm start # Start production server
npm run dev # Start with auto-reload (Node --watch)To enable debug output in the frontend (shows transcript and confidence):
- Open
src/components/ResultScreen.jsx - Change
const DEBUG_MODE = falsetoconst DEBUG_MODE = true - Debug info will appear on the result screen
Analyze audio for fraud detection
Request:
Content-Type: multipart/form-dataaudio: Audio file (WAV, WebM, MP3, OGG)
Response:
{
"transcript": "Hello, this is regarding your account...",
"duration": "5.2 seconds",
"confidence": "0.92",
"fraudAssessment": {
"riskLevel": "high",
"riskScore": 87,
"summary": "Multiple fraud indicators detected",
"indicators": [
{
"type": "urgency",
"severity": "high",
"description": "Creates false sense of urgency"
}
],
"recommendation": "Exercise extreme caution",
"confidence": 85
}
}Analyze text message for fraud
Request:
{
"message": "Your account has been suspended. Click here to verify..."
}Analyze URL for potential threats
Request:
{
"url": "https://suspicious-link.example.com"
}Health check endpoint
Response:
{
"status": "ok",
"message": "TrustLens backend is running"
}- Mobile-First Design: Optimized for 420px viewport
- Dark Theme: Modern gradient background (#0f172a β #1e293b)
- Smooth Animations: All transitions use ease timing
- Accessible: Proper ARIA labels and semantic HTML
- Responsive: Natural scrolling with viewport-aware sizing
- Consistent Navigation: "Back to Dashboard" on all pages
- Industry-leading speech-to-text accuracy
- Confidence scores for transcript quality
- Support for real-time and batch processing
- Advanced reasoning capabilities for fraud pattern detection
- JSON-structured responses for reliable parsing
- Cost-effective for text analysis
- Browser-native audio recording
- WAV format (16kHz, 16-bit, mono) for optimal Azure compatibility
- No external dependencies required
- Privacy-first: No user data retention
- Reduced attack surface
- Simplified deployment
- GDPR compliant by design
| Level | Score Range | Color | Meaning |
|---|---|---|---|
| Low | 0-30% | π’ Green | Minimal fraud indicators |
| Medium | 31-69% | π‘ Yellow | Some suspicious patterns |
| High | 70-100% | π΄ Red | Multiple fraud indicators |
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Azure Cognitive Services for speech recognition
- Google Gemini AI for fraud analysis
- React Team for the amazing framework
- Vite Team for the lightning-fast build tool
For issues, questions, or suggestions:
- Open an issue on GitHub
- Review the backend README.md for API details
- Check the Azure Speech SDK docs
- Visit Google AI Studio
Built with β€οΈ for safer digital interactions