feat: connect AI Scribe to real-time Web Speech API (v5)
Build Curio HMS / build-and-deploy (push) Has been cancelled
Details
Build Curio HMS / build-and-deploy (push) Has been cancelled
Details
This commit is contained in:
parent
2e2b3b33d4
commit
9553ab707a
54
dashboard.js
54
dashboard.js
|
|
@ -131,40 +131,68 @@ if (startRecordBtn) {
|
|||
};
|
||||
}
|
||||
|
||||
// 6. AI Scribe, Summarization & Context Switching Logic
|
||||
// 6. AI Scribe & Speech Recognition Logic
|
||||
let isScribing = false;
|
||||
let currentPatientId = "#012";
|
||||
let recognition;
|
||||
const patientDataStore = {
|
||||
"#012": { notes: "", summary: "" },
|
||||
"#013": { notes: "", summary: "" },
|
||||
"#014": { notes: "", summary: "" }
|
||||
};
|
||||
|
||||
if ('webkitSpeechRecognition' in window) {
|
||||
recognition = new webkitSpeechRecognition();
|
||||
recognition.continuous = true;
|
||||
recognition.interimResults = true;
|
||||
|
||||
recognition.onresult = (event) => {
|
||||
let interimTranscript = '';
|
||||
for (let i = event.resultIndex; i < event.results.length; ++i) {
|
||||
if (event.results[i].isFinal) {
|
||||
document.getElementById("consultationNotes").value += event.results[i][0].transcript + '. ';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
recognition.onerror = (e) => {
|
||||
console.error("Speech Recognition Error:", e);
|
||||
isScribing = false;
|
||||
updateScribeUI();
|
||||
};
|
||||
}
|
||||
|
||||
window.toggleZenScribe = () => {
|
||||
if (!recognition) {
|
||||
alert("Speech Recognition not supported in this browser. Please use Chrome or Edge.");
|
||||
return;
|
||||
}
|
||||
|
||||
isScribing = !isScribing;
|
||||
updateScribeUI();
|
||||
|
||||
if (isScribing) {
|
||||
recognition.start();
|
||||
} else {
|
||||
recognition.stop();
|
||||
generateSummary();
|
||||
}
|
||||
};
|
||||
|
||||
function updateScribeUI() {
|
||||
const btn = document.getElementById("zenScribeBtn");
|
||||
const status = document.getElementById("scribeStatus");
|
||||
const notesArea = document.getElementById("consultationNotes");
|
||||
|
||||
isScribing = !isScribing;
|
||||
|
||||
if (isScribing) {
|
||||
btn.innerText = "🛑 Stop AI Scribe";
|
||||
btn.style.background = "#EF4444";
|
||||
status.classList.remove("hidden");
|
||||
|
||||
// Simulate AI capturing notes
|
||||
setTimeout(() => {
|
||||
if (isScribing) {
|
||||
notesArea.value += "Patient reports symptoms of fatigue and persistent dry cough for 3 days. No fever recorded today. \n";
|
||||
}
|
||||
}, 3000);
|
||||
} else {
|
||||
btn.innerText = "🎙️ Start AI Scribe";
|
||||
btn.style.background = "";
|
||||
status.classList.add("hidden");
|
||||
generateSummary();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function generateSummary() {
|
||||
const notes = document.getElementById("consultationNotes").value;
|
||||
|
|
|
|||
Loading…
Reference in New Issue