mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
update: 录音按钮新增防抖
This commit is contained in:
parent
e4cfabeb7e
commit
4f72a516d3
1 changed files with 22 additions and 15 deletions
|
|
@ -168,7 +168,13 @@ class UIController {
|
||||||
// Record button
|
// Record button
|
||||||
const recordBtn = document.getElementById('recordBtn');
|
const recordBtn = document.getElementById('recordBtn');
|
||||||
if (recordBtn) {
|
if (recordBtn) {
|
||||||
|
let recordTimer = null;
|
||||||
recordBtn.addEventListener('click', () => {
|
recordBtn.addEventListener('click', () => {
|
||||||
|
if (recordTimer) {
|
||||||
|
clearTimeout(recordTimer);
|
||||||
|
recordTimer = null;
|
||||||
|
}
|
||||||
|
recordTimer = setTimeout(() => {
|
||||||
const audioRecorder = getAudioRecorder();
|
const audioRecorder = getAudioRecorder();
|
||||||
if (audioRecorder.isRecording) {
|
if (audioRecorder.isRecording) {
|
||||||
audioRecorder.stop();
|
audioRecorder.stop();
|
||||||
|
|
@ -185,6 +191,7 @@ class UIController {
|
||||||
audioRecorder.start();
|
audioRecorder.start();
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
}, 300);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue