Skip to content

Commit d4d86ec

Browse files
committedFeb 5, 2025
1 parent 558b361 commit d4d86ec

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "esp-ai",
3-
"version": "2.46.32",
3+
"version": "2.48.34",
44
"description": "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` 集成方案。",
55
"repository": "https://github.com/wangzongming/esp-ai",
66
"main": "src/index.js",

‎src/audio_temp/play_audio.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function play_audio(url, client_ws, task_id, session_id, device_id, seek, on_end
9797
// 真正结束
9898
const end_time = Date.now(); // 结束时间
9999
const play_time = end_time - start_audio_time; // 播放时间
100-
const end_res = await on_end({
100+
const end_res = on_end && await on_end({
101101
start_time: start_audio_time,
102102
end_time: end_time,
103103
play_time: Math.floor(play_time / 1000),
@@ -107,7 +107,7 @@ function play_audio(url, client_ws, task_id, session_id, device_id, seek, on_end
107107
})
108108

109109
// 特殊发一组标志
110-
this.ws.send(Buffer.from(G_session_ids.tts_all_end, 'utf-8'));
110+
client_ws.send(Buffer.from(G_session_ids.tts_all_end, 'utf-8'));
111111

112112
G_devices.set(device_id, {
113113
...G_devices.get(device_id),
@@ -126,7 +126,7 @@ function play_audio(url, client_ws, task_id, session_id, device_id, seek, on_end
126126
...G_devices.get(device_id),
127127
play_audio_ing: true,
128128
play_audio_on_end: (...arg) => {
129-
this.ws.send(Buffer.from(G_session_ids.tts_all_end, 'utf-8'));
129+
client_ws.send(Buffer.from(G_session_ids.tts_all_end, 'utf-8'));
130130
return on_end && on_end(...arg);
131131
},
132132
play_audio_seek: seek || 0,

‎src/instrance_fns/matchIntention.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async function matchIntention(device_id, text, reply) {
4242
intention_for: for (const item of intention) {
4343
const { key = [] } = item;
4444
if (typeof key === "function") {
45-
const res = await key(text, { llm_historys, prev_play_audio_ing });
45+
const res = await key(text, { llm_historys, prev_play_audio_ing, instance: G_Instance, device_id });
4646
if (res) {
4747
task_info = item;
4848
task_info["__name__"] = res;
@@ -164,7 +164,7 @@ async function matchIntention(device_id, text, reply) {
164164
});
165165
// 不延时不能保证播放队列
166166
setTimeout(async () => {
167-
const { url, seek, message: errMessage } = await music_server(__name__, { user_config });
167+
const { url, seek, message: errMessage } = await music_server(__name__, { user_config, instance: G_Instance, device_id });
168168
if (!url) {
169169
await TTS_FN(device_id, {
170170
text: errMessage || "没有找到相关的结果,换个关键词试试吧!",

‎src/instrance_fns/tts.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ async function tts(device_id, text, opts) {
4141
need_record: false,
4242
...opts
4343
})
44-
ws && ws.send("session_end");
44+
// 这里不应发送这个标志。
45+
// ws && ws.send("session_end");
4546
return true;
4647
} catch (err) {
4748
console.log(err);

0 commit comments

Comments
 (0)
Please sign in to comment.