Update DMH Hospital Diabetic Dost

This commit is contained in:
Sanika Gurav
2026-10-15 17:37:14 +05:30
parent d92ef47309
commit e7a92cafd4
15 changed files with 188 additions and 84 deletions
+132 -34
View File
@@ -4,11 +4,11 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chellaram Hospital — Diabetes Dost 🩺</title>
<link rel="icon" type="image/png" sizes="32x32" href="/static/chellaram_hospital_logo.png?v=chellaram">
<link rel="icon" type="image/png" sizes="16x16" href="/static/chellaram_hospital_logo.png?v=chellaram">
<link rel="shortcut icon" href="/static/chellaram_hospital_logo.png?v=chellaram">
<link rel="apple-touch-icon" href="/static/chellaram_hospital_logo.png?v=chellaram">
<title>Dinanath Mangeshkar Hospital — Diabetes Dost 🩺</title>
<link rel="icon" type="image/png" sizes="32x32" href="/static/dmh_logo.png?v=dmh">
<link rel="icon" type="image/png" sizes="16x16" href="/static/dmh_logo.png?v=dmh">
<link rel="shortcut icon" href="/static/dmh_logo.png?v=dmh">
<link rel="apple-touch-icon" href="/static/dmh_logo.png?v=dmh">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
@@ -1114,6 +1114,28 @@
cursor: default;
}
.btn-pill-action.send-speech-active {
background: #10b981;
border-color: #059669;
color: #ffffff;
font-weight: 700;
box-shadow: 0 2px 10px rgba(16, 185, 129, 0.35);
transition: all 0.2s ease;
animation: pulseGreen 1.8s infinite ease-in-out;
}
.btn-pill-action.send-speech-active:hover {
background: #059669;
color: #ffffff;
transform: translateY(-1px);
box-shadow: 0 4px 14px rgba(5, 150, 105, 0.45);
}
@keyframes pulseGreen {
0%, 100% { box-shadow: 0 2px 10px rgba(16, 185, 129, 0.35); }
50% { box-shadow: 0 4px 18px rgba(16, 185, 129, 0.6); }
}
/* Bottom 3 Feature Cards & Tagline */
.bottom-features-section {
display: flex;
@@ -2242,9 +2264,9 @@
======================================================== -->
<header class="main-header">
<div class="header-left">
<img src="/static/chellaram_hospital_logo.png?v=chellaram" alt="Chellaram Hospital Logo" class="brand-logo-img">
<img src="/static/dmh_logo.png?v=dmh" alt="Dinanath Mangeshkar Hospital Logo" class="brand-logo-img">
<div class="brand-titles">
<h1>Chellaram Hospital</h1>
<h1>Dinanath Mangeshkar Hospital</h1>
<p>Diabetes Dost — Care Companion</p>
</div>
</div>
@@ -2491,6 +2513,10 @@
<button class="btn-pill-action pause-active" id="btn-pause-resume" onclick="togglePauseMic()">
<span>⏸️</span> Pause
</button>
<button class="btn-pill-action send-speech-active" id="btn-send-speech" onclick="manualSubmitSpeech()" style="display: none;" title="पूर्ण झाले? उत्तर पाठवा / Send Answer">
<span>✅</span> उत्तर पाठवा (Send)
</button>
</div>
<!-- Chat Messages Scroll Container -->
@@ -2687,9 +2713,13 @@
let recognition = null;
let currentSttLang = 'hi-IN';
let silenceTimer = null;
let pauseFeedbackTimer = null;
let speechWatchdogInterval = null;
let speechSafetyTimeout = null;
let currentAccumulatedSpeech = '';
let confirmedSpeechHistory = '';
let currentSessionTranscript = '';
let naturalPauseWaitMs = 4500; // 4.5 seconds generous pause tolerance for natural speech
let currentLivePatientRow = null;
let lastBotPromptText = 'ही तहान तुम्हाला किती दिवसांपासून जाणवते?';
let lastBotAudioUrl = null;
@@ -2739,6 +2769,10 @@
if (recognition) {
recognition.lang = currentSttLang;
}
const sendBtn = document.getElementById('btn-send-speech');
if (sendBtn) {
sendBtn.innerHTML = currentSttLang === 'mr-IN' ? '<span>✅</span> उत्तर पाठवा' : '<span>✅</span> भेजें (Send)';
}
setupVoices();
}
@@ -2854,6 +2888,26 @@
.trim();
}
function resetSpeechAccumulator() {
if (silenceTimer) { clearTimeout(silenceTimer); silenceTimer = null; }
if (pauseFeedbackTimer) { clearTimeout(pauseFeedbackTimer); pauseFeedbackTimer = null; }
confirmedSpeechHistory = '';
currentSessionTranscript = '';
currentAccumulatedSpeech = '';
const sendBtn = document.getElementById('btn-send-speech');
if (sendBtn) sendBtn.style.display = 'none';
}
function manualSubmitSpeech() {
if (isBotSpeaking || isConversationStopped) return;
const textToSend = (currentAccumulatedSpeech || '').trim();
if (textToSend) {
resetSpeechAccumulator();
stopListening();
sendVoiceTurn(textToSend);
}
}
function initSpeechRecognition() {
if (!('webkitSpeechRecognition' in window) && !('SpeechRecognition' in window)) return;
const SpeechRec = window.SpeechRecognition || window.webkitSpeechRecognition;
@@ -2883,37 +2937,72 @@
stopAnyBotSpeech();
}
let sessionTranscript = '';
// Reset pause timers because the patient is actively speaking
if (silenceTimer) { clearTimeout(silenceTimer); silenceTimer = null; }
if (pauseFeedbackTimer) { clearTimeout(pauseFeedbackTimer); pauseFeedbackTimer = null; }
let sessionFinal = '';
let sessionInterim = '';
for (let i = 0; i < event.results.length; ++i) {
if (event.results[i] && event.results[i][0]) {
sessionTranscript += event.results[i][0].transcript + ' ';
const res = event.results[i];
if (res && res[0]) {
if (res.isFinal) {
sessionFinal += res[0].transcript + ' ';
} else {
sessionInterim += res[0].transcript + ' ';
}
}
}
const rawCombined = (currentAccumulatedSpeech + ' ' + sessionTranscript).trim();
const cleanDisplay = cleanSpokenTranscript(rawCombined);
currentSessionTranscript = (sessionFinal + ' ' + sessionInterim).trim();
// Overall speech integrates previously accumulated sentences across pauses + current segment
const combinedSpeech = cleanSpokenTranscript((confirmedSpeechHistory + ' ' + currentSessionTranscript).trim());
if (combinedSpeech) {
currentAccumulatedSpeech = combinedSpeech;
updatePatientLiveBubble(combinedSpeech);
if (cleanDisplay) {
updatePatientLiveBubble(cleanDisplay);
const lbl = document.getElementById('orb-dock-status');
const sub = document.getElementById('orb-dock-subtext');
if (lbl) lbl.textContent = '👂 Listening carefully...';
const sendBtn = document.getElementById('btn-send-speech');
if (lbl) {
lbl.textContent = currentSttLang === 'mr-IN'
? '👂 ऐकतोय... (बोलत राहा)'
: '👂 सुन रहे हैं... (बोलते रहिए)';
}
if (sub) {
sub.textContent = '🗣️ "' + cleanDisplay + '" (Speak at your own pace...)';
sub.textContent = '🗣️ "' + combinedSpeech + '"';
sub.style.color = '#38bdf8';
sub.style.fontWeight = '600';
}
if (silenceTimer) clearTimeout(silenceTimer);
if (sendBtn) {
sendBtn.style.display = 'inline-flex';
sendBtn.title = currentSttLang === 'mr-IN' ? 'पूर्ण झाले? उत्तर पाठवा' : 'हो गया? उत्तर भेजें';
sendBtn.innerHTML = currentSttLang === 'mr-IN' ? '<span>✅</span> उत्तर पाठवा' : '<span>✅</span> भेजें (Send)';
}
// Generous natural pause (2500ms): ensures patient finishes full multi-phrase sentence without punctuation truncation
// Gentle pause indicator: after 1.5s of natural pause, reassure user they have plenty of time
pauseFeedbackTimer = setTimeout(() => {
if (isBotSpeaking || isMicPaused || isConversationStopped) return;
if (lbl) {
lbl.textContent = currentSttLang === 'mr-IN'
? '⏳ वेळ घ्या, ऐकतोय... (किंवा Send दाबा)'
: '⏳ समय लीजिए, सुन रहे हैं... (या Send दबाएं)';
}
}, 1500);
// Generous natural pause (4.5s): captures multi-phrase speech even if patient pauses to think or breathe
silenceTimer = setTimeout(() => {
if (isBotSpeaking || isMicPaused || isConversationStopped) return;
if (cleanDisplay) {
currentAccumulatedSpeech = '';
if (currentAccumulatedSpeech) {
const finalSpeech = currentAccumulatedSpeech;
resetSpeechAccumulator();
stopListening();
sendVoiceTurn(cleanDisplay);
sendVoiceTurn(finalSpeech);
}
}, 2500);
}, naturalPauseWaitMs);
}
};
@@ -2925,10 +3014,19 @@
};
recognition.onend = function () {
// If recognition was ended by browser on silence/pause while listening is still active:
if (isListeningActive && !isMicPaused && !isConversationStopped && !isBotSpeaking) {
// Consolidate currentSessionTranscript into confirmedSpeechHistory so NOTHING is lost
if (currentSessionTranscript) {
confirmedSpeechHistory = cleanSpokenTranscript((confirmedSpeechHistory + ' ' + currentSessionTranscript).trim());
currentSessionTranscript = '';
}
// Seamlessly restart recognition so patient can resume speaking without losing earlier words
setTimeout(() => {
try { recognition.start(); } catch (e) { }
}, 100);
if (isListeningActive && !isMicPaused && !isConversationStopped && !isBotSpeaking) {
try { recognition.start(); } catch (e) { }
}
}, 50);
}
};
} catch (e) { }
@@ -2938,8 +3036,7 @@
async function startListening() {
if (isBotSpeaking || isMicPaused || isConversationStopped) return;
if (silenceTimer) clearTimeout(silenceTimer);
currentAccumulatedSpeech = '';
resetSpeechAccumulator();
currentLivePatientRow = null;
await requestMicPermission();
@@ -2963,10 +3060,13 @@
function stopListening() {
isListeningActive = false;
if (silenceTimer) clearTimeout(silenceTimer);
if (silenceTimer) { clearTimeout(silenceTimer); silenceTimer = null; }
if (pauseFeedbackTimer) { clearTimeout(pauseFeedbackTimer); pauseFeedbackTimer = null; }
if (recognition) {
try { recognition.abort(); } catch (e) { }
}
const sendBtn = document.getElementById('btn-send-speech');
if (sendBtn) sendBtn.style.display = 'none';
updateOrbUI(isMicPaused ? 'paused' : 'idle');
}
@@ -2979,11 +3079,9 @@
initiateVoiceSessionWithUserGesture();
return;
}
// If user has spoken something and clicks the orb, immediately send their full answer!
if (isListeningActive && currentAccumulatedSpeech.trim()) {
const fullText = currentAccumulatedSpeech.trim();
currentAccumulatedSpeech = '';
stopListening();
sendVoiceTurn(fullText);
manualSubmitSpeech();
return;
}
togglePauseMic();
@@ -4321,7 +4419,7 @@
<div>
<div
style="font-size:0.68rem; font-weight:800; color:#0b8082; text-transform:uppercase; letter-spacing:0.5px;">
🏥 Chellaram Hospital
🏥 Dinanath Mangeshkar Hospital
</div>
<h3
style="font-family:'Outfit',sans-serif; font-size:1.18rem; font-weight:800; color:#0f172a; margin:2px 0 0 0;">
@@ -4426,10 +4524,10 @@
onclick="if(event.target.id === 'admin-login-modal') closeAdminLoginModal()">
<div
style="background: #ffffff; border-radius: 16px; padding: 28px 24px; max-width: 400px; width: 100%; box-shadow: var(--shadow-lg); text-align: center; border: 1px solid var(--card-border);">
<img src="/static/chellaram_hospital_logo.png?v=chellaram" alt="Chellaram Hospital"
<img src="/static/dmh_logo.png?v=dmh" alt="Dinanath Mangeshkar Hospital"
style="height: 54px; width: auto; max-width: 220px; border-radius: 12px; object-fit: contain; margin: 0 auto 12px auto; display: block; box-shadow: 0 4px 12px rgba(14, 165, 168, 0.2); border: 1px solid rgba(14, 165, 168, 0.2); background: #ffffff; padding: 4px 10px;">
<h3 style="font-family: 'Outfit', sans-serif; font-size: 1.25rem; font-weight: 800; color: var(--blue-navy);">
Chellaram Hospital Admin
Dinanath Mangeshkar Hospital Admin
</h3>
<p style="font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; margin-bottom: 18px;">
Sign in to view all patient consultations & SQLite records