ruiyun-human 1.0.14 → 1.0.16

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.
@@ -400,35 +400,36 @@ const _sfc_main = {
400
400
  },
401
401
  emits: ["loaded", "changed", "paused", "resumed", "audio-ready"],
402
402
  setup(__props, { expose: __expose, emit: __emit }) {
403
- const TTS_URL = "http://localhost:6039";
404
- const ASR_URL = "http://localhost:6039";
403
+ const TTS_URL = "https://sqsyky.xzspj.suqian.gov.cn:8443";
404
+ const ASR_URL = "/api";
405
+ const szrUrl = `${TTS_URL}szrimage/`;
405
406
  const HUMAN_PRESETS = {
406
407
  1: {
407
408
  humanId: 1,
408
409
  title: "西装动漫男",
409
410
  // TODO: 替换为真实资源
410
- folder: "http://192.168.3.107:8088/img/xiangyu-green-suit",
411
- folder_mobile: "http://192.168.3.107:8088/img/xiangyu-green-suit-header",
411
+ folder: `${szrUrl}/xiangyu-green-suit`,
412
+ folder_mobile: `${szrUrl}/xiangyu-green-suit-header`,
412
413
  standby: { interval: 100, standbyNum: 11 },
413
414
  speak: { interval: 30, speakNum: 0 },
414
415
  humanType: 1,
415
- timbre: 1
416
+ timbre: 47
416
417
  },
417
418
  2: {
418
419
  humanId: 2,
419
420
  title: "西装动漫女",
420
- folder: "http://192.168.3.107:8088/img/anime-woman",
421
- folder_mobile: "http://192.168.3.107:8088/img/anime-woman-header",
421
+ folder: `${szrUrl}/anime-woman`,
422
+ folder_mobile: `${szrUrl}/anime-woman-header`,
422
423
  standby: { interval: 100, standbyNum: 1 },
423
424
  speak: { interval: 30, speakNum: 75 },
424
425
  humanType: 1,
425
- timbre: 3
426
+ timbre: 45
426
427
  },
427
428
  3: {
428
429
  humanId: 3,
429
430
  title: "真人形象男",
430
- folder: "http://192.168.3.107:8088/img/real-man",
431
- folder_mobile: "http://192.168.3.107:8088/img/real-man-header",
431
+ folder: `${szrUrl}/real-man`,
432
+ folder_mobile: `${szrUrl}/real-man-header`,
432
433
  standby: { interval: 100, standbyNum: 1 },
433
434
  speak: { interval: 30, speakNum: 139 },
434
435
  humanType: 1,
@@ -437,8 +438,8 @@ const _sfc_main = {
437
438
  4: {
438
439
  humanId: 4,
439
440
  title: "真人形象女",
440
- folder: "http://192.168.3.107:8088/img/real-woman",
441
- folder_mobile: "http://192.168.3.107:8088/img/real-woman-header",
441
+ folder: `${szrUrl}/real-woman`,
442
+ folder_mobile: `${szrUrl}/real-woman-header`,
442
443
  standby: { interval: 100, standbyNum: 2 },
443
444
  speak: { interval: 40, speakNum: 139 },
444
445
  humanType: 1,
@@ -447,12 +448,12 @@ const _sfc_main = {
447
448
  5: {
448
449
  humanId: 5,
449
450
  title: "Q版形象",
450
- folder: "http://192.168.3.107:8088/img/xiangyu-q",
451
- folder_mobile: "http://192.168.3.107:8088/img/xiangyu-q-header",
451
+ folder: `${szrUrl}/xiangyu-q`,
452
+ folder_mobile: `${szrUrl}/xiangyu-q-header`,
452
453
  standby: { interval: 100, standbyNum: 28 },
453
454
  speak: { interval: 30, speakNum: 118 },
454
455
  humanType: 1,
455
- timbre: 34
456
+ timbre: 47
456
457
  }
457
458
  };
458
459
  const isMobile = () => {
@@ -721,6 +722,7 @@ const _sfc_main = {
721
722
  timestamp.value = null;
722
723
  frameIndex.value = 1;
723
724
  currentHuman.value = human;
725
+ console.log("init", currentHuman.value);
724
726
  const canvas = canvasRef.value;
725
727
  const dpr = window.devicePixelRatio || 1;
726
728
  const width = containerRef.value.clientWidth;
@@ -797,10 +799,11 @@ const _sfc_main = {
797
799
  return pcmToWavBlob(buf);
798
800
  };
799
801
  const requestTTSAudio = async (text, signal) => {
800
- var _a;
802
+ var _a, _b;
801
803
  let lastError = null;
802
804
  for (let attempt = 1; attempt <= TTS_MAX_RETRIES; attempt++) {
803
805
  if (signal == null ? void 0 : signal.aborted) throw new DOMException("Aborted", "AbortError");
806
+ console.log("[TTS] 提交合成请求1111:", ((_a = currentHuman.value) == null ? void 0 : _a.timbre) ?? 1);
804
807
  const res = await fetch(`${TTS_URL}/web/voice/jd/text-to-speech`, {
805
808
  method: "POST",
806
809
  headers: {
@@ -808,7 +811,7 @@ const _sfc_main = {
808
811
  clientid: VOICE_CLIENT_ID,
809
812
  "tenant-id": VOICE_TENANT_ID
810
813
  },
811
- body: JSON.stringify({ text, user: TTS_USER, timbre: ((_a = currentHuman.value) == null ? void 0 : _a.timbre) ?? 1 }),
814
+ body: JSON.stringify({ text, user: TTS_USER, timbre: ((_b = currentHuman.value) == null ? void 0 : _b.timbre) ?? 1 }),
812
815
  signal
813
816
  });
814
817
  if (!res.ok) {
@@ -879,8 +882,12 @@ const _sfc_main = {
879
882
  }
880
883
  };
881
884
  const playTTS = async (text) => {
882
- var _a;
883
- if (!text || !((_a = currentHuman.value) == null ? void 0 : _a.isMuted)) return;
885
+ if (!text) return;
886
+ const latest = props.human ? resolveHuman(props.human) : null;
887
+ if (latest) {
888
+ if (!latest.isMuted) return;
889
+ Object.assign(currentHuman.value || {}, latest);
890
+ }
884
891
  abortTTS();
885
892
  ttsAbortController = new AbortController();
886
893
  const { signal } = ttsAbortController;
@@ -889,7 +896,7 @@ const _sfc_main = {
889
896
  try {
890
897
  const cleanText = text.replace(/```[\s\S]*?```/g, "").replace(/`[^`]+`/g, "").replace(/[#*_~]/g, "").replace(/\n+/g, ",").replace(/\s+/g, " ").replace(/[,。!?]{2,}/g, ",").trim();
891
898
  if (!cleanText) return;
892
- console.log("[TTS] 提交合成请求:", { text: cleanText, length: cleanText.length });
899
+ console.log("[TTS] 提交合成请求:", { human: currentHuman.value, text: cleanText, length: cleanText.length });
893
900
  const audioBlob = await requestTTSAudio(cleanText, signal);
894
901
  if (signal.aborted || currentTtsRequestId.value !== requestId) return;
895
902
  if (!audioBlob || audioBlob.size === 0) {
@@ -1002,6 +1009,7 @@ const _sfc_main = {
1002
1009
  switchHuman
1003
1010
  });
1004
1011
  vue.onMounted(() => {
1012
+ console.log("onMounted", props.human);
1005
1013
  initRecorder();
1006
1014
  init();
1007
1015
  });
@@ -1026,7 +1034,7 @@ const _sfc_main = {
1026
1034
  };
1027
1035
  }
1028
1036
  };
1029
- const DigitalHuman = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-eb00f641"]]);
1037
+ const DigitalHuman = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-97ef7e2a"]]);
1030
1038
  DigitalHuman.install = (app) => app.component("DigitalHuman", DigitalHuman);
1031
1039
  const components = [DemoButton, DemoInput, DigitalHuman];
1032
1040
  const install = (app) => {
@@ -398,35 +398,36 @@ const _sfc_main = {
398
398
  },
399
399
  emits: ["loaded", "changed", "paused", "resumed", "audio-ready"],
400
400
  setup(__props, { expose: __expose, emit: __emit }) {
401
- const TTS_URL = "http://localhost:6039";
402
- const ASR_URL = "http://localhost:6039";
401
+ const TTS_URL = "https://sqsyky.xzspj.suqian.gov.cn:8443";
402
+ const ASR_URL = "/api";
403
+ const szrUrl = `${TTS_URL}szrimage/`;
403
404
  const HUMAN_PRESETS = {
404
405
  1: {
405
406
  humanId: 1,
406
407
  title: "西装动漫男",
407
408
  // TODO: 替换为真实资源
408
- folder: "http://192.168.3.107:8088/img/xiangyu-green-suit",
409
- folder_mobile: "http://192.168.3.107:8088/img/xiangyu-green-suit-header",
409
+ folder: `${szrUrl}/xiangyu-green-suit`,
410
+ folder_mobile: `${szrUrl}/xiangyu-green-suit-header`,
410
411
  standby: { interval: 100, standbyNum: 11 },
411
412
  speak: { interval: 30, speakNum: 0 },
412
413
  humanType: 1,
413
- timbre: 1
414
+ timbre: 47
414
415
  },
415
416
  2: {
416
417
  humanId: 2,
417
418
  title: "西装动漫女",
418
- folder: "http://192.168.3.107:8088/img/anime-woman",
419
- folder_mobile: "http://192.168.3.107:8088/img/anime-woman-header",
419
+ folder: `${szrUrl}/anime-woman`,
420
+ folder_mobile: `${szrUrl}/anime-woman-header`,
420
421
  standby: { interval: 100, standbyNum: 1 },
421
422
  speak: { interval: 30, speakNum: 75 },
422
423
  humanType: 1,
423
- timbre: 3
424
+ timbre: 45
424
425
  },
425
426
  3: {
426
427
  humanId: 3,
427
428
  title: "真人形象男",
428
- folder: "http://192.168.3.107:8088/img/real-man",
429
- folder_mobile: "http://192.168.3.107:8088/img/real-man-header",
429
+ folder: `${szrUrl}/real-man`,
430
+ folder_mobile: `${szrUrl}/real-man-header`,
430
431
  standby: { interval: 100, standbyNum: 1 },
431
432
  speak: { interval: 30, speakNum: 139 },
432
433
  humanType: 1,
@@ -435,8 +436,8 @@ const _sfc_main = {
435
436
  4: {
436
437
  humanId: 4,
437
438
  title: "真人形象女",
438
- folder: "http://192.168.3.107:8088/img/real-woman",
439
- folder_mobile: "http://192.168.3.107:8088/img/real-woman-header",
439
+ folder: `${szrUrl}/real-woman`,
440
+ folder_mobile: `${szrUrl}/real-woman-header`,
440
441
  standby: { interval: 100, standbyNum: 2 },
441
442
  speak: { interval: 40, speakNum: 139 },
442
443
  humanType: 1,
@@ -445,12 +446,12 @@ const _sfc_main = {
445
446
  5: {
446
447
  humanId: 5,
447
448
  title: "Q版形象",
448
- folder: "http://192.168.3.107:8088/img/xiangyu-q",
449
- folder_mobile: "http://192.168.3.107:8088/img/xiangyu-q-header",
449
+ folder: `${szrUrl}/xiangyu-q`,
450
+ folder_mobile: `${szrUrl}/xiangyu-q-header`,
450
451
  standby: { interval: 100, standbyNum: 28 },
451
452
  speak: { interval: 30, speakNum: 118 },
452
453
  humanType: 1,
453
- timbre: 34
454
+ timbre: 47
454
455
  }
455
456
  };
456
457
  const isMobile = () => {
@@ -719,6 +720,7 @@ const _sfc_main = {
719
720
  timestamp.value = null;
720
721
  frameIndex.value = 1;
721
722
  currentHuman.value = human;
723
+ console.log("init", currentHuman.value);
722
724
  const canvas = canvasRef.value;
723
725
  const dpr = window.devicePixelRatio || 1;
724
726
  const width = containerRef.value.clientWidth;
@@ -795,10 +797,11 @@ const _sfc_main = {
795
797
  return pcmToWavBlob(buf);
796
798
  };
797
799
  const requestTTSAudio = async (text, signal) => {
798
- var _a;
800
+ var _a, _b;
799
801
  let lastError = null;
800
802
  for (let attempt = 1; attempt <= TTS_MAX_RETRIES; attempt++) {
801
803
  if (signal == null ? void 0 : signal.aborted) throw new DOMException("Aborted", "AbortError");
804
+ console.log("[TTS] 提交合成请求1111:", ((_a = currentHuman.value) == null ? void 0 : _a.timbre) ?? 1);
802
805
  const res = await fetch(`${TTS_URL}/web/voice/jd/text-to-speech`, {
803
806
  method: "POST",
804
807
  headers: {
@@ -806,7 +809,7 @@ const _sfc_main = {
806
809
  clientid: VOICE_CLIENT_ID,
807
810
  "tenant-id": VOICE_TENANT_ID
808
811
  },
809
- body: JSON.stringify({ text, user: TTS_USER, timbre: ((_a = currentHuman.value) == null ? void 0 : _a.timbre) ?? 1 }),
812
+ body: JSON.stringify({ text, user: TTS_USER, timbre: ((_b = currentHuman.value) == null ? void 0 : _b.timbre) ?? 1 }),
810
813
  signal
811
814
  });
812
815
  if (!res.ok) {
@@ -877,8 +880,12 @@ const _sfc_main = {
877
880
  }
878
881
  };
879
882
  const playTTS = async (text) => {
880
- var _a;
881
- if (!text || !((_a = currentHuman.value) == null ? void 0 : _a.isMuted)) return;
883
+ if (!text) return;
884
+ const latest = props.human ? resolveHuman(props.human) : null;
885
+ if (latest) {
886
+ if (!latest.isMuted) return;
887
+ Object.assign(currentHuman.value || {}, latest);
888
+ }
882
889
  abortTTS();
883
890
  ttsAbortController = new AbortController();
884
891
  const { signal } = ttsAbortController;
@@ -887,7 +894,7 @@ const _sfc_main = {
887
894
  try {
888
895
  const cleanText = text.replace(/```[\s\S]*?```/g, "").replace(/`[^`]+`/g, "").replace(/[#*_~]/g, "").replace(/\n+/g, ",").replace(/\s+/g, " ").replace(/[,。!?]{2,}/g, ",").trim();
889
896
  if (!cleanText) return;
890
- console.log("[TTS] 提交合成请求:", { text: cleanText, length: cleanText.length });
897
+ console.log("[TTS] 提交合成请求:", { human: currentHuman.value, text: cleanText, length: cleanText.length });
891
898
  const audioBlob = await requestTTSAudio(cleanText, signal);
892
899
  if (signal.aborted || currentTtsRequestId.value !== requestId) return;
893
900
  if (!audioBlob || audioBlob.size === 0) {
@@ -1000,6 +1007,7 @@ const _sfc_main = {
1000
1007
  switchHuman
1001
1008
  });
1002
1009
  onMounted(() => {
1010
+ console.log("onMounted", props.human);
1003
1011
  initRecorder();
1004
1012
  init();
1005
1013
  });
@@ -1024,7 +1032,7 @@ const _sfc_main = {
1024
1032
  };
1025
1033
  }
1026
1034
  };
1027
- const DigitalHuman = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-eb00f641"]]);
1035
+ const DigitalHuman = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-97ef7e2a"]]);
1028
1036
  DigitalHuman.install = (app) => app.component("DigitalHuman", DigitalHuman);
1029
1037
  const components = [DemoButton, DemoInput, DigitalHuman];
1030
1038
  const install = (app) => {
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .demo-btn[data-v-9a48516a]{padding:6px 14px;border-radius:4px;border:none;cursor:pointer;font-size:14px}.primary[data-v-9a48516a]{background:#409eff;color:#fff}.success[data-v-9a48516a]{background:#67c23a;color:#fff}.warning[data-v-9a48516a]{background:#e6a23c;color:#fff}.demo-input-wrap[data-v-28a3493c]{display:inline-flex;align-items:center;border:1px solid #dcdcdc;border-radius:4px;padding:0 10px}.demo-input-wrap[data-v-28a3493c]:focus-within{border-color:#409eff}.demo-input[data-v-28a3493c]{border:none;outline:none;padding:8px 6px;flex:1}.prefix[data-v-28a3493c],.suffix[data-v-28a3493c]{color:#909399}.digital-human[data-v-eb00f641]{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.digital-human canvas[data-v-eb00f641]{max-width:100%;max-height:100%}
1
+ .demo-btn[data-v-9a48516a]{padding:6px 14px;border-radius:4px;border:none;cursor:pointer;font-size:14px}.primary[data-v-9a48516a]{background:#409eff;color:#fff}.success[data-v-9a48516a]{background:#67c23a;color:#fff}.warning[data-v-9a48516a]{background:#e6a23c;color:#fff}.demo-input-wrap[data-v-28a3493c]{display:inline-flex;align-items:center;border:1px solid #dcdcdc;border-radius:4px;padding:0 10px}.demo-input-wrap[data-v-28a3493c]:focus-within{border-color:#409eff}.demo-input[data-v-28a3493c]{border:none;outline:none;padding:8px 6px;flex:1}.prefix[data-v-28a3493c],.suffix[data-v-28a3493c]{color:#909399}.digital-human[data-v-97ef7e2a]{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.digital-human canvas[data-v-97ef7e2a]{max-width:100%;max-height:100%}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ruiyun-human",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "type": "module",
5
5
  "description": "数字人初步实现",
6
6
  "main": "./dist/ruiyun-human.cjs.js",