Smart Farming Assistant Project Planning
┌─────────────────────────────────────────────────────────┐
│ USER INTERACTION │
└─────────────────────────────────────────────────────────┘
↓
┌──────────────────────┐
│ Voice or Text Input │
└──────────────────────┘
↓
┌───────────────────────────────┐
│ │
┌────▼────┐ ┌──────▼──────┐
│ VOICE │ │ TEXT │
└────┬────┘ └──────┬──────┘
│ │
│ 1. Upload audio file │ 1. Direct input
│ 2. Save to 'uploads/' │
│ 3. Speech-to-Text │
│ (Hugging Face API) │
└────────┬─────────────────────┘
│
▼
┌────────────────────┐
│ TEXT PROCESSING │
└────────────────────┘
│
▼
┌────────────────────┐
│ OpenAI GPT-3.5 │
│ (Agriculture │
│ Expert System) │
└────────────────────┘
│
▼
┌────────────────────┐
│ AI Response │
└────────────────────┘
│
┌────────┴────────┐
│ │
▼ ▼
┌────────┐ ┌──────────┐
│ TEXT │ │ AUDIO │
│ Output │ │ (gTTS) │
└────────┘ └──────────┘
│ │
└────────┬────────┘
▼
┌────────────────────┐
│ Return JSON │
│ {text, voice_url} │
└────────────────────┘
↓
┌────────────────────┐
│ USER RECEIVES │
│ Answer │
└────────────────────┘
1. Farmer records: "Which fertilizer is best for rice?"
└─> Saved as: uploads/recording_xyz.webm
2. Speech-to-Text Processing:
└─> Hugging Face API transcribes
└─> Result: "which fertilizer is best for rice"
3. AI Processing:
└─> OpenAI receives question
└─> Context: Agriculture expert + Indian seasons info
└─> Generates: "For rice cultivation, NPK fertilizers
with ratio 4:2:1 are recommended during kharif season..."
4. Audio Generation:
└─> gTTS converts response to speech
└─> Saved as: static/audio/AB12CD34.mp3
5. Response to User:
{
"text": "For rice cultivation...",
"voice": "/static/audio/AB12CD34.mp3"
}

