esp-ai
Version:
Provide a complete set of AI dialogue solutions for your development board, including but not limited to the IAT+LLM+TTS integration solution for the ESP32 series development board. | 为你的开发板提供全套的AI对话方案,包括但不限于 `ESP32` 系列开发板的 `IAT+LLM+TTS` 集成方案。
31 lines (30 loc) • 770 B
JavaScript
class TTS_buffer_chunk_queue {
constructor(device_id) {
this.device_id = device_id;
this.queue = [];
this.stoped = true;
this.runing = false;
this.queue_listen_timer = true;
}
push(args) {
this.queue.push(args);
!this.runing && this.run();
}
async run() {
if (!this.queue.length) {
this.stoped = true;
this.runing = false;
return;
}
this.runing = true;
const tts_queue = this.queue.shift();
await tts_queue();
this.run();
}
clear() {
this.runing = false;
this.stoped = true;
this.queue = [];
}
}
module.exports = TTS_buffer_chunk_queue;