feat: Hyperlocal Voice Assistant - #1888
Merged
Merged
Conversation
|
@Aditya8369 is attempting to deploy a commit to the Om Roy's projects Team on Vercel. A member of the Team first needs to authorize it. |
Thanks for creating a PR for your Issue!
|
Contributor
Author
|
🎉 Congrats @Aditya8369 on getting your PR merged! 🙌 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #1883
Key Components Implemented
backend/api/v1/bot_webhook.py
)
Twilio SMS & WhatsApp Inbound Webhook (POST /api/v1/bot/webhook/twilio):
Ingests inbound farmer messages, voice notes (STT), and plant disease photos.
Automatically responds with localized advisory text and an audio voice note link wrapped in formatted TwiML XML (......).
Meta Cloud WhatsApp Webhook (GET/POST /api/v1/bot/webhook/meta):
Handles Webhook verification handshake (hub.mode, hub.verify_token, hub.challenge).
Processes inbound text messages, WhatsApp voice notes (audio IDs), and leaf images (image IDs).
Sends back localized replies and audio note attachments via Meta Graph API.
Unified Voice Assistant REST API (POST /api/v1/bot/query):
Accepts text queries, audio file uploads/base64, leaf photos, crop selection, and language selection from the frontend widget.
Standalone Audio Endpoints:
POST /api/v1/bot/stt for Whisper / Bhashini / Google Speech-to-Text.
POST /api/v1/bot/tts for gTTS / Bhashini localized Text-to-Speech synthesis.
GET /api/v1/bot/audio/ for streaming audio notes.
GET /api/v1/bot/status for real-time capability matrix & engine status.
Registered Blueprint in
backend/api/v1/init.py
under /api/v1/bot.
2. Bot Advisory Core Service (
backend/services/bot_advisory_service.py
)
Speech-to-Text (STT) Pipeline:
Integrated OpenAI Whisper API (whisper-1) and India's Bhashini ASR pipeline with SpeechRecognition fallback.
Google Gemini 2.5 Flash & Localized Prompt Templates:
Localized system prompt templates for 10 regional languages: Hindi (हिन्दी), Marathi (मराठी), Telugu (తెలుగు), Tamil (தமிழ்), Kannada (ಕನ್ನಡ), Punjabi (ਪੰਜਾਬੀ), Gujarati (ગુજરાતી), Bengali (বাংলা), Malayalam (മലയാളം), and English.
Tailored specifically for Indian farmers (smallholders, progressive farmers), covering sowing timings, seed treatment, irrigation scheduling, organic remedies (neem oil, dashaparni ark), chemical dosages, PM-KISAN, PMFBY, Soil Health Cards, and mandi prices.
Rule-based agronomy knowledge base fallback for seamless continuous operation.
Multimodal Plant Disease Detection:
Automatically pipes incoming WhatsApp/Twilio/Widget leaf photos into
AIDiseaseDetectionService.analyze_crop_image
.
Formats diagnostic findings (disease name, severity, symptoms, organic/biological solution, chemical remedy, and preventive measures) and returns both concise text cards and audio notes.
Text-to-Speech (TTS):
Generates localized audio notes using gTTS and Bhashini TTS with cached audio URLs.
3. Frontend Floating Voice Assistant Widget & Offline Fallback (
voice-input.js
)
Floating UI Widget (#agri-voice-assistant):
Floating microphone trigger with a pulsing ring animation.
Expandable modal with interactive microphone trigger, live audio waveforms, language selector, and crop selector.
Multimodal Camera / Photo Uploader: Farmers can snap/upload a leaf photo directly in the voice assistant modal alongside their voice query.
Audio Controls: Replay voice notes, pause/play audio stream, and view formatted prescription notes.