feat: implement Deep Scribe with Whisper API rollout (v7)
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
63e30d9f5c
commit
96af67ce68
60
dashboard.js
60
dashboard.js
|
|
@ -145,8 +145,13 @@ if ('webkitSpeechRecognition' in window) {
|
|||
recognition = new webkitSpeechRecognition();
|
||||
recognition.continuous = true;
|
||||
recognition.interimResults = true;
|
||||
recognition.maxAlternatives = 3; // Better for complex dialects
|
||||
|
||||
// Hinting the engine that this is a medical context
|
||||
recognition.onstart = () => {
|
||||
console.log("Listening for clinical context in " + recognition.lang);
|
||||
};
|
||||
|
||||
recognition.onresult = (event) => {
|
||||
let interimTranscript = '';
|
||||
for (let i = event.resultIndex; i < event.results.length; ++i) {
|
||||
if (event.results[i].isFinal) {
|
||||
|
|
@ -162,26 +167,32 @@ if ('webkitSpeechRecognition' in window) {
|
|||
};
|
||||
}
|
||||
|
||||
window.toggleZenScribe = () => {
|
||||
window.toggleZenScribe = async () => {
|
||||
if (!recognition) {
|
||||
alert("Speech Recognition not supported in this browser. Please use Chrome or Edge.");
|
||||
return;
|
||||
}
|
||||
|
||||
const lang = document.getElementById("scribeLang") ? document.getElementById("scribeLang").value : 'te-IN';
|
||||
recognition.lang = lang;
|
||||
|
||||
isScribing = !isScribing;
|
||||
updateScribeUI();
|
||||
|
||||
if (isScribing) {
|
||||
recognition.start();
|
||||
startDeepScribe();
|
||||
} else {
|
||||
recognition.stop();
|
||||
generateSummary();
|
||||
if (mediaRecorder) mediaRecorder.stop();
|
||||
// Summary is triggered inside processWithWhisper or fallback
|
||||
}
|
||||
};
|
||||
|
||||
function updateScribeUI() {
|
||||
const btn = document.getElementById("zenScribeBtn");
|
||||
const status = document.getElementById("scribeStatus");
|
||||
if (!btn || !status) return;
|
||||
|
||||
if (isScribing) {
|
||||
btn.innerText = "🛑 Stop AI Scribe";
|
||||
|
|
@ -194,6 +205,49 @@ function updateScribeUI() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
let mediaRecorder;
|
||||
let audioChunks = [];
|
||||
|
||||
async function startDeepScribe() {
|
||||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||
mediaRecorder = new MediaRecorder(stream);
|
||||
audioChunks = [];
|
||||
|
||||
mediaRecorder.ondataavailable = (event) => {
|
||||
audioChunks.push(event.data);
|
||||
};
|
||||
|
||||
mediaRecorder.onstop = async () => {
|
||||
const audioBlob = new Blob(audioChunks, { type: 'audio/wav' });
|
||||
processWithWhisper(audioBlob);
|
||||
};
|
||||
|
||||
mediaRecorder.start();
|
||||
}
|
||||
|
||||
async function processWithWhisper(blob) {
|
||||
console.log("Sending to Deep Scribe (Whisper)...");
|
||||
const formData = new FormData();
|
||||
formData.append("file", blob, "audio.wav");
|
||||
formData.append("model", "base");
|
||||
|
||||
try {
|
||||
const response = await fetch("https://curio.applaude.net/api/whisper/v1/transcribe", {
|
||||
method: "POST",
|
||||
body: formData
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data.text) {
|
||||
document.getElementById("consultationNotes").value += "\n[DEEP SCRIBE]: " + data.text;
|
||||
generateSummary(true); // Always use Telugu-capable summary for Deep Scribe
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("Whisper API not reachable, falling back to Browser Summary.");
|
||||
generateSummary(document.getElementById("scribeLang").value === 'te-IN');
|
||||
}
|
||||
}
|
||||
|
||||
function generateSummary(isTelugu = false) {
|
||||
const notesArea = document.getElementById("consultationNotes");
|
||||
const notes = notesArea.value;
|
||||
|
|
|
|||
Loading…
Reference in New Issue