Spaces:
Runtime error
Runtime error
Update templates/result.html
Browse files- templates/result.html +77 -78
templates/result.html
CHANGED
|
@@ -77,7 +77,6 @@
|
|
| 77 |
}
|
| 78 |
.btn-back:hover { background: #475569; }
|
| 79 |
|
| 80 |
-
/* PUDHU CODE: பேசும் பட்டன் டிசைன் 👇 */
|
| 81 |
.btn-voice {
|
| 82 |
width: 100%;
|
| 83 |
padding: 15px;
|
|
@@ -92,7 +91,6 @@
|
|
| 92 |
transition: 0.3s;
|
| 93 |
}
|
| 94 |
.btn-voice:hover { background: #00f2fe; color: #0f172a; }
|
| 95 |
-
/* PUDHU CODE END 👆 */
|
| 96 |
</style>
|
| 97 |
</head>
|
| 98 |
<body>
|
|
@@ -144,6 +142,7 @@
|
|
| 144 |
<button class="btn-voice" id="voiceBtn">
|
| 145 |
<i class="fa-solid fa-volume-high"></i> Listen to AI Report
|
| 146 |
</button>
|
|
|
|
| 147 |
<button class="btn-print" id="downloadBtn" onclick="generatePDF()">Download Medical Report (PDF)</button>
|
| 148 |
<button class="btn-back" onclick="window.location.href='/upload'">Scan Another Image (Go Back)</button>
|
| 149 |
</div>
|
|
@@ -170,9 +169,14 @@
|
|
| 170 |
});
|
| 171 |
}
|
| 172 |
|
| 173 |
-
// --- PUDHU CODE: AI VOICE ASSISTANT (
|
| 174 |
function speakReport(triage, disease) {
|
| 175 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
window.speechSynthesis.cancel();
|
| 177 |
|
| 178 |
let speech = new SpeechSynthesisUtterance();
|
|
@@ -186,11 +190,10 @@
|
|
| 186 |
|
| 187 |
speech.text = dialogue;
|
| 188 |
speech.volume = 1;
|
| 189 |
-
speech.rate = 0.95;
|
| 190 |
-
speech.pitch = 1.1;
|
| 191 |
speech.lang = 'en-US';
|
| 192 |
|
| 193 |
-
// போன்ல இருக்குற வாய்ஸ் லிஸ்டை எடுத்து, "Female" வாய்ஸ் செலக்ட் பண்ற லாஜிக்
|
| 194 |
let voices = window.speechSynthesis.getVoices();
|
| 195 |
let femaleVoice = voices.find(voice => voice.name.includes('Female') || voice.name.includes('Google UK English Female') || voice.name.includes('en-US'));
|
| 196 |
|
|
@@ -198,86 +201,82 @@
|
|
| 198 |
speech.voice = femaleVoice;
|
| 199 |
}
|
| 200 |
|
| 201 |
-
// பேசு!
|
| 202 |
window.speechSynthesis.speak(speech);
|
| 203 |
}
|
| 204 |
-
// வாய்ஸ் லிஸ்டை ரெடியா முன்கூட்டியே லோட் பண்ணி வைக்கும் கோடு
|
| 205 |
-
window.speechSynthesis.onvoiceschanged = function() {
|
| 206 |
-
window.speechSynthesis.getVoices();
|
| 207 |
-
};
|
| 208 |
-
// --- PUDHU CODE END 👆 ---
|
| 209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
window.location.href = '/upload';
|
| 215 |
-
} else {
|
| 216 |
-
const aiData = JSON.parse(aiDataJSON);
|
| 217 |
|
| 218 |
-
if(
|
| 219 |
-
|
| 220 |
-
}
|
| 221 |
-
if(aiData.heat_gen && aiData.heat_img) {
|
| 222 |
-
document.getElementById('display-heat').src = "data:image/jpeg;base64," + aiData.heat_img;
|
| 223 |
} else {
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
|
| 245 |
-
|
| 246 |
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
|
| 273 |
-
|
| 274 |
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
speakReport(aiData.triage, aiData.disease);
|
| 278 |
-
});
|
| 279 |
-
// --- PUDHU CODE END 👆 ---
|
| 280 |
-
}
|
| 281 |
-
</script>
|
| 282 |
-
</body>
|
| 283 |
-
</html>
|
|
|
|
| 77 |
}
|
| 78 |
.btn-back:hover { background: #475569; }
|
| 79 |
|
|
|
|
| 80 |
.btn-voice {
|
| 81 |
width: 100%;
|
| 82 |
padding: 15px;
|
|
|
|
| 91 |
transition: 0.3s;
|
| 92 |
}
|
| 93 |
.btn-voice:hover { background: #00f2fe; color: #0f172a; }
|
|
|
|
| 94 |
</style>
|
| 95 |
</head>
|
| 96 |
<body>
|
|
|
|
| 142 |
<button class="btn-voice" id="voiceBtn">
|
| 143 |
<i class="fa-solid fa-volume-high"></i> Listen to AI Report
|
| 144 |
</button>
|
| 145 |
+
|
| 146 |
<button class="btn-print" id="downloadBtn" onclick="generatePDF()">Download Medical Report (PDF)</button>
|
| 147 |
<button class="btn-back" onclick="window.location.href='/upload'">Scan Another Image (Go Back)</button>
|
| 148 |
</div>
|
|
|
|
| 169 |
});
|
| 170 |
}
|
| 171 |
|
| 172 |
+
// --- PUDHU CODE: AI VOICE ASSISTANT (Crash-Proof Safeguard Added) 👇 ---
|
| 173 |
function speakReport(triage, disease) {
|
| 174 |
+
// மொபைல் ஆப்பில் வாய்ஸ் சப்போர்ட் இல்லை என்றால் எரர் வராமல் தடுக்க
|
| 175 |
+
if (!('speechSynthesis' in window)) {
|
| 176 |
+
alert("⚠️ App Notice: Voice Assistant is not supported in this mobile view. Please check the text report.");
|
| 177 |
+
return;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
window.speechSynthesis.cancel();
|
| 181 |
|
| 182 |
let speech = new SpeechSynthesisUtterance();
|
|
|
|
| 190 |
|
| 191 |
speech.text = dialogue;
|
| 192 |
speech.volume = 1;
|
| 193 |
+
speech.rate = 0.95;
|
| 194 |
+
speech.pitch = 1.1;
|
| 195 |
speech.lang = 'en-US';
|
| 196 |
|
|
|
|
| 197 |
let voices = window.speechSynthesis.getVoices();
|
| 198 |
let femaleVoice = voices.find(voice => voice.name.includes('Female') || voice.name.includes('Google UK English Female') || voice.name.includes('en-US'));
|
| 199 |
|
|
|
|
| 201 |
speech.voice = femaleVoice;
|
| 202 |
}
|
| 203 |
|
|
|
|
| 204 |
window.speechSynthesis.speak(speech);
|
| 205 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
|
| 207 |
+
// போனில் வாய்ஸ் சிஸ்டம் இருந்தால் மட்டும் இதை ரன் பண்ணு (இதுதான் ஆப்பை க்ராஷ் ஆக்கிய வில்லன்!)
|
| 208 |
+
if ('speechSynthesis' in window) {
|
| 209 |
+
window.speechSynthesis.onvoiceschanged = function() {
|
| 210 |
+
window.speechSynthesis.getVoices();
|
| 211 |
+
};
|
| 212 |
+
}
|
| 213 |
+
// --- PUDHU CODE END 👆 ---
|
| 214 |
|
| 215 |
+
// --- PUDHU CODE: Try-Catch பாதுகாப்பு அரண் 👇 ---
|
| 216 |
+
try {
|
| 217 |
+
const aiDataJSON = localStorage.getItem('aiResult');
|
|
|
|
|
|
|
|
|
|
| 218 |
|
| 219 |
+
if(!aiDataJSON || aiDataJSON === "undefined" || aiDataJSON === "null") {
|
| 220 |
+
window.location.href = '/upload';
|
|
|
|
|
|
|
|
|
|
| 221 |
} else {
|
| 222 |
+
const aiData = JSON.parse(aiDataJSON);
|
| 223 |
+
|
| 224 |
+
if(aiData.orig_img) {
|
| 225 |
+
document.getElementById('display-orig').src = "data:image/jpeg;base64," + aiData.orig_img;
|
| 226 |
+
}
|
| 227 |
+
if(aiData.heat_gen && aiData.heat_img) {
|
| 228 |
+
document.getElementById('display-heat').src = "data:image/jpeg;base64," + aiData.heat_img;
|
| 229 |
+
} else {
|
| 230 |
+
document.getElementById('display-heat').src = "data:image/jpeg;base64," + aiData.orig_img;
|
| 231 |
+
document.getElementById('heatmap-caption').innerText = "Healthy Retina (No Heatmap Needed)";
|
| 232 |
+
document.getElementById('heatmap-caption').style.color = "#10b981";
|
| 233 |
+
}
|
| 234 |
|
| 235 |
+
const headerStatus = document.getElementById('header-status');
|
| 236 |
+
const mainCard = document.getElementById('main-result-card');
|
| 237 |
+
const scoreTitle = document.getElementById('pred-title');
|
| 238 |
+
const scoreValue = document.getElementById('pred-score');
|
| 239 |
+
const scoreStatus = document.getElementById('pred-status');
|
| 240 |
+
const dummyCards = document.querySelectorAll('.dummy-card');
|
| 241 |
+
|
| 242 |
+
const verdictBox = document.getElementById('verdict-box');
|
| 243 |
+
const verdictTitle = document.getElementById('verdict-title');
|
| 244 |
+
const verdictText = document.getElementById('verdict-text');
|
| 245 |
|
| 246 |
+
headerStatus.innerText = "● System Diagnosis: " + aiData.triage;
|
| 247 |
+
scoreTitle.innerText = "AI Prediction: " + aiData.disease;
|
| 248 |
+
scoreValue.innerText = aiData.confidence;
|
| 249 |
+
scoreStatus.innerText = "Status: " + aiData.status;
|
| 250 |
|
| 251 |
+
verdictText.innerText = "Action Required: " + aiData.action + " | Doctor Advice: " + aiData.advice;
|
| 252 |
|
| 253 |
+
if(aiData.triage === "SAFE") {
|
| 254 |
+
const color = "#10b981";
|
| 255 |
+
headerStatus.style.color = color;
|
| 256 |
+
scoreValue.style.color = color;
|
| 257 |
+
mainCard.style.borderLeftColor = color;
|
| 258 |
+
verdictBox.style.background = "rgba(16, 185, 129, 0.1)";
|
| 259 |
+
verdictBox.style.borderColor = color;
|
| 260 |
+
verdictTitle.style.color = color;
|
| 261 |
+
} else if(aiData.triage === "URGENT") {
|
| 262 |
+
const color = "#ef4444";
|
| 263 |
+
headerStatus.style.color = color;
|
| 264 |
+
scoreValue.style.color = color;
|
| 265 |
+
mainCard.style.borderLeftColor = color;
|
| 266 |
+
verdictBox.style.background = "rgba(239, 68, 68, 0.1)";
|
| 267 |
+
verdictBox.style.borderColor = color;
|
| 268 |
+
verdictTitle.style.color = color;
|
| 269 |
+
} else {
|
| 270 |
+
const color = "#f59e0b";
|
| 271 |
+
headerStatus.style.color = color;
|
| 272 |
+
scoreValue.style.color = color;
|
| 273 |
+
mainCard.style.borderLeftColor = color;
|
| 274 |
+
verdictBox.style.background = "rgba(245, 158, 11, 0.1)";
|
| 275 |
+
verdictBox.style.borderColor = color;
|
| 276 |
+
verdictTitle.style.color = color;
|
| 277 |
+
}
|
| 278 |
|
| 279 |
+
dummyCards.forEach(card => card.style.display = "none");
|
| 280 |
|
| 281 |
+
// பட்டனை தொட்டா பேசுற லாஜிக்
|
| 282 |
+
document.getElementById('voiceBtn').addEventListener
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|