Update app.py
Browse files
app.py
CHANGED
@@ -53,13 +53,29 @@ def generate_gemini_response(disease_list, user_context="", conversation_history
|
|
53 |
|
54 |
# Ask Gemini for a structured diagnosis
|
55 |
prompt += """
|
56 |
-
|
57 |
-
1.
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
response = model.generate_content(prompt)
|
65 |
return response.text if response else "No response from Gemini."
|
@@ -210,10 +226,12 @@ if uploaded_file:
|
|
210 |
|
211 |
# Convert diagnosis to speech if enabled
|
212 |
|
213 |
-
|
214 |
if tts_enabled:
|
215 |
if st.button("π Listen to Diagnosis"):
|
216 |
with st.spinner("Generating audio... π΅"):
|
|
|
|
|
217 |
audio_bytes = text_to_speech(diagnosis, language)
|
218 |
if audio_bytes:
|
219 |
st.audio(audio_bytes, format="audio/mp3")
|
|
|
53 |
|
54 |
# Ask Gemini for a structured diagnosis
|
55 |
prompt += """
|
56 |
+
For each detected disease, provide a structured analysis following this format:
|
57 |
+
1. Disease Name: [Name]
|
58 |
+
- Pathogen: [Causative organism]
|
59 |
+
- Severity Level: [Based on visual symptoms]
|
60 |
+
- Key Symptoms:
|
61 |
+
* [Symptom 1]
|
62 |
+
* [Symptom 2]
|
63 |
+
- Economic Impact:
|
64 |
+
* [Brief description of potential crop losses]
|
65 |
+
- Treatment Options:
|
66 |
+
* Immediate actions: [Short-term solutions]
|
67 |
+
* Long-term management: [Preventive measures]
|
68 |
+
- Environmental Conditions:
|
69 |
+
* Favorable conditions for disease development
|
70 |
+
* Risk factors
|
71 |
+
2. Recommendations:
|
72 |
+
- Immediate Steps:
|
73 |
+
* [Action items for immediate control]
|
74 |
+
- Prevention Strategy:
|
75 |
+
* [Long-term prevention measures]
|
76 |
+
- Monitoring Protocol:
|
77 |
+
* [What to watch for]"""
|
78 |
+
|
79 |
|
80 |
response = model.generate_content(prompt)
|
81 |
return response.text if response else "No response from Gemini."
|
|
|
226 |
|
227 |
# Convert diagnosis to speech if enabled
|
228 |
|
229 |
+
translator = Translator()
|
230 |
if tts_enabled:
|
231 |
if st.button("π Listen to Diagnosis"):
|
232 |
with st.spinner("Generating audio... π΅"):
|
233 |
+
if language != "en":
|
234 |
+
diagnosis = translator.translate(diagnosis, dest=language)
|
235 |
audio_bytes = text_to_speech(diagnosis, language)
|
236 |
if audio_bytes:
|
237 |
st.audio(audio_bytes, format="audio/mp3")
|