@siact/sime-x-vue 0.0.23 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1513,13 +1513,11 @@
1513
1513
  }
1514
1514
  };
1515
1515
  const test = () => {
1516
- [
1517
- "1你好,世界,今天是想起五天气横扫的缺点",
1518
- "2你好,世界,今天是想起五天气横扫的缺点",
1519
- "3你好,世界,今天是想起五天气横扫的缺点"
1520
- ].forEach((text, index) => {
1516
+ ["0.732~0.8124"].forEach((text, index) => {
1521
1517
  setTimeout(() => {
1522
- aiChatbotX.speakText(text);
1518
+ aiChatbotX.speakText(text).call(() => {
1519
+ console.log("speak end");
1520
+ });
1523
1521
  }, index * 1e3);
1524
1522
  });
1525
1523
  };
@@ -1687,7 +1685,7 @@
1687
1685
  }
1688
1686
  });
1689
1687
 
1690
- const commandTest = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-36096054"]]);
1688
+ const commandTest = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-74573d6c"]]);
1691
1689
 
1692
1690
  class CommandManager {
1693
1691
  commands = /* @__PURE__ */ new Map();
@@ -1789,7 +1787,8 @@
1789
1787
  voiceAssistantRef.value?.agentInvoke(text);
1790
1788
  },
1791
1789
  speakText: (text) => {
1792
- voiceAssistantRef.value?.speakText(text);
1790
+ return voiceAssistantRef.value?.speakText(text) ?? { call: () => {
1791
+ } };
1793
1792
  },
1794
1793
  stopSpeak: () => {
1795
1794
  voiceAssistantRef.value?.stopSpeak();
@@ -1823,19 +1822,34 @@
1823
1822
  }
1824
1823
  return -1;
1825
1824
  };
1825
+ const DIGIT_TO_CN = {
1826
+ "0": "零",
1827
+ "1": "一",
1828
+ "2": "二",
1829
+ "3": "三",
1830
+ "4": "四",
1831
+ "5": "五",
1832
+ "6": "六",
1833
+ "7": "七",
1834
+ "8": "八",
1835
+ "9": "九"
1836
+ };
1826
1837
  const normalizeNumbers = (text) => {
1827
1838
  return text.replace(/(-?\d[\d,]*\.?\d*)\s*%/g, (_, num) => {
1828
1839
  const cleanNum = num.replace(/,/g, "");
1829
1840
  const n = parseFloat(cleanNum);
1830
- const spoken = cleanNum.replace(".", "点");
1841
+ const [intPart, decPart] = cleanNum.split(".");
1842
+ let spoken = intPart;
1843
+ if (decPart) spoken += "点" + decPart.replace(/\d/g, (d) => DIGIT_TO_CN[d] || d);
1831
1844
  if (n < 0) return `负百分之${spoken.replace("-", "")}`;
1832
1845
  return `百分之${spoken}`;
1833
1846
  }).replace(/(-?\d[\d,]*)\.(\d+)/g, (_, intPart, decPart) => {
1834
1847
  const cleanInt = intPart.replace(/,/g, "");
1848
+ const decCn = decPart.replace(/\d/g, (d) => DIGIT_TO_CN[d] || d);
1835
1849
  if (cleanInt.startsWith("-")) {
1836
- return `负${cleanInt.slice(1)}点${decPart}`;
1850
+ return `负${cleanInt.slice(1)}点${decCn}`;
1837
1851
  }
1838
- return `${cleanInt}点${decPart}`;
1852
+ return `${cleanInt}点${decCn}`;
1839
1853
  }).replace(/-(\d)/g, "负$1");
1840
1854
  };
1841
1855
  const stripMarkdown = (text) => {
@@ -2385,14 +2399,19 @@
2385
2399
  isProcessingSpeakQueue = true;
2386
2400
  tts.hasPendingAudio.value = true;
2387
2401
  while (speakQueue.length > 0) {
2388
- const text = speakQueue.shift();
2402
+ const item = speakQueue.shift();
2389
2403
  bubble.open();
2390
- agent.currentTextContent.value = text;
2404
+ agent.currentTextContent.value = item.text;
2391
2405
  try {
2392
- await tts.speakAndWait(text);
2406
+ await tts.speakAndWait(item.text);
2393
2407
  } catch (e) {
2394
2408
  console.error("[speakQueue] 播报失败:", e);
2395
2409
  }
2410
+ try {
2411
+ item.onComplete?.();
2412
+ } catch (e) {
2413
+ console.error("[speakQueue] onComplete 回调出错:", e);
2414
+ }
2396
2415
  if (speakQueue.length > 0) {
2397
2416
  tts.hasPendingAudio.value = true;
2398
2417
  }
@@ -2402,10 +2421,16 @@
2402
2421
  bubble.scheduleDismiss();
2403
2422
  };
2404
2423
  const speakTextWithBubble = (text) => {
2405
- speakQueue.push(text);
2424
+ const item = { text };
2425
+ speakQueue.push(item);
2406
2426
  if (!isProcessingSpeakQueue) {
2407
2427
  processSpeakQueue();
2408
2428
  }
2429
+ return {
2430
+ call: (fn) => {
2431
+ item.onComplete = fn;
2432
+ }
2433
+ };
2409
2434
  };
2410
2435
  const stopSpeak = () => {
2411
2436
  speakQueue.length = 0;
@@ -2581,7 +2606,7 @@
2581
2606
  }
2582
2607
  });
2583
2608
 
2584
- const voiceAssistant = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-177013f4"]]);
2609
+ const voiceAssistant = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-8ce9ddda"]]);
2585
2610
 
2586
2611
  var clientCommandKey = /* @__PURE__ */ ((clientCommandKey2) => {
2587
2612
  clientCommandKey2["SET_THEME"] = "SiMeAgent_setTheme";