36416-vm/assets/js/voice-analyzer.js
Flatlogic Bot 6cef6ef090 Deris Ai
2025-11-28 17:47:44 +00:00

35 lines
1.0 KiB
JavaScript

if (annyang) {
const startBtn = document.getElementById('start-record-btn');
const stopBtn = document.getElementById('stop-record-btn');
const transcribedText = document.getElementById('transcribed-text');
const commands = {
'*text': (text) => {
transcribedText.value += text + ' ';
}
};
annyang.addCommands(commands);
startBtn.addEventListener('click', () => {
transcribedText.value = '';
annyang.start();
startBtn.classList.add('d-none');
stopBtn.classList.remove('d-none');
});
stopBtn.addEventListener('click', () => {
annyang.abort();
startBtn.classList.remove('d-none');
stopBtn.classList.add('d-none');
});
annyang.addCallback('end', function() {
if (transcribedText.value.trim() === '') {
transcribedText.value = 'Could not hear anything. Please try again.';
}
startBtn.classList.remove('d-none');
stopBtn.classList.add('d-none');
});
}