Spaces:
Runtime error
Runtime error
Update ER_MAP/dashboard.py
Browse filesadded female voice to nurse by hardcoding it because ElevenLabs tokens were exhausting in 1-2 episodes and browser TTS was using same voices for all agents
1083 unmodified lines10841085108610871088108912 unmodified lines1102110311041105110611071108110936 unmodified lines114611471148114911501151115211531083 unmodified linesif (logEndRef.current) logEndRef.current.scrollIntoView({ behavior: 'smooth' });}, [conversationLog]);// ---------------- Audio queue (drives card activation) ----------------const processQueue = useCallback(async () => {if (isPlayingRef.current || audioQueueRef.current.length === 0) return;12 unmodified linesif (synth) {const utter = new SpeechSynthesisUtterance(item.text);utter.rate = 1.05;utter.pitch = item.agent === 'patient' ? 0.9 : item.agent === 'nurse' ? 1.1 : 1.0;utter.volume = 1.0;setActiveAgent(item.agent);utter.onend = () => { setActiveAgent(null); isPlayingRef.current = false; processQueue(); };utter.onerror = () => { setActiveAgent(null); isPlayingRef.current = false; processQueue(); };36 unmodified linesif (synth) {const utter = new SpeechSynthesisUtterance(item.text);utter.rate = 1.05;utter.pitch = item.agent === 'patient' ? 0.9 : item.agent === 'nurse' ? 1.1 : 1.0;utter.volume = 1.0;setActiveAgent(item.agent);utter.onend = () => { setActiveAgent(null); isPlayingRef.current = false; processQueue(); };utter.onerror = () => { setActiveAgent(null); isPlayingRef.current = false; processQueue(); };1083 unmodified lines10841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111312 unmodified lines112611271128112911301131113211331134113536 unmodified lines11721173117411751176117711781179118011811083 unmodified linesif (logEndRef.current) logEndRef.current.scrollIntoView({ behavior: 'smooth' });}, [conversationLog]);// ---- Browser TTS voice picker (female for nurse/patient, male for doctor) ----const pickVoice = useCallback((agent) => {const synth = window.speechSynthesis;if (!synth) return null;const voices = synth.getVoices();if (!voices.length) return null;const wantFemale = (agent === 'nurse' || agent === 'patient');const femaleHints = ['female', 'zira', 'samantha', 'karen', 'victoria', 'fiona', 'google uk english female', 'woman'];const maleHints = ['male', 'david', 'mark', 'james', 'daniel', 'google uk english male', 'man'];const hints = wantFemale ? femaleHints : maleHints;let match = voices.find(v => hints.some(h => v.name.toLowerCase().includes(h)));if (!match && wantFemale) match = voices.find(v => /female/i.test(v.name));if (!match && !wantFemale) match = voices.find(v => /male/i.test(v.name) && !/female/i.test(v.name));return match || null;}, []);// Preload voices (Chrome loads them async)useEffect(() => {if (window.speechSynthesis) {window.speechSynthesis.getVoices();window.speechSynthesis.onvoiceschanged = () => window.speechSynthesis.getVoices();}}, []);// ---------------- Audio queue (drives card activation) ----------------const processQueue = useCallback(async () => {if (isPlayingRef.current || audioQueueRef.current.length === 0) return;12 unmodified linesif (synth) {const utter = new SpeechSynthesisUtterance(item.text);utter.rate = 1.05;utter.pitch = item.agent === 'patient' ? 0.9 : item.agent === 'nurse' ? 1.15 : 1.0;utter.volume = 1.0;const voice = pickVoice(item.agent);if (voice) utter.voice = voice;setActiveAgent(item.agent);utter.onend = () => { setActiveAgent(null); isPlayingRef.current = false; processQueue(); };utter.onerror = () => { setActiveAgent(null); isPlayingRef.current = false; processQueue(); };36 unmodified linesif (synth) {const utter = new SpeechSynthesisUtterance(item.text);utter.rate = 1.05;utter.pitch = item.agent === 'patient' ? 0.9 : item.agent === 'nurse' ? 1.15 : 1.0;utter.volume = 1.0;const voice = pickVoice(item.agent);if (voice) utter.voice = voice;setActiveAgent(item.agent);utter.onend = () => { setActiveAgent(null); isPlayingRef.current = false; processQueue(); };utter.onerror = () => { setActiveAgent(null); isPlayingRef.current = false; processQueue(); };
ER_MAP/dashboard.py+30-2