File size: 923 Bytes
09fc539
 
0ee19e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79b753d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// static/js/voice.js

document.addEventListener('DOMContentLoaded', function () {
    const micBtn = document.getElementById('mic-btn');
    const urgencyInputs = document.getElementsByName('urgency');

    if (micBtn) {
        micBtn.addEventListener('click', () => {
            const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
            recognition.lang = 'en-US';
            recognition.start();

            recognition.onresult = function(event) {
                const transcript = event.results[0][0].transcript.toLowerCase();
                console.log("Heard:", transcript);
                if (transcript.includes('low')) urgencyInputs[0].checked = true;
                else if (transcript.includes('medium')) urgencyInputs[1].checked = true;
                else if (transcript.includes('high')) urgencyInputs[2].checked = true;
            };
        });
    }
});