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