@vunk/plus 1.10.2 → 1.11.0

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.
Files changed (43) hide show
  1. package/components/WebGLRenderer.mjs +1 -1
  2. package/components/WebGPURenderer.mjs +1 -1
  3. package/components/broadcasting-markdown/index.mjs +21 -9
  4. package/components/broadcasting-markdown/src/ctx.d.ts +7 -0
  5. package/components/broadcasting-markdown/src/index.vue.d.ts +55 -46
  6. package/components/browserAll.mjs +1 -1
  7. package/components/index2.mjs +127 -69
  8. package/components/metahuman-broadcasting/index.d.ts +0 -1
  9. package/components/metahuman-broadcasting/index.mjs +58 -68
  10. package/components/metahuman-broadcasting/src/ctx.d.ts +4 -0
  11. package/components/metahuman-broadcasting/src/index.vue.d.ts +144 -167
  12. package/components/pixi-frame/index.d.ts +4 -1
  13. package/components/pixi-frame/index.mjs +2 -2
  14. package/components/pixi-frame/src/bitmap-generator.vue.d.ts +146 -0
  15. package/components/pixi-frame/src/bitmap.vue.d.ts +4 -5
  16. package/components/pixi-frame/src/index.vue.d.ts +4 -5
  17. package/components/webworkerAll.mjs +1 -1
  18. package/package.json +4 -20
  19. package/shared/data/blobToAudioBuffer.d.ts +1 -0
  20. package/shared/data/imgUrlToBitmap.d.ts +1 -0
  21. package/shared/data/index.d.ts +2 -0
  22. package/shared/data/index.mjs +25 -0
  23. package/shared/StreamingInferenceService.mjs +0 -204
  24. package/shared/audioToFrames/index.d.ts +0 -19
  25. package/shared/audioToFrames/index.mjs +0 -44
  26. package/shared/audioToFrames/src/assets/mask.d.ts +0 -2
  27. package/shared/audioToFrames/src/audio/StreamingFeatureExtractorService.d.ts +0 -125
  28. package/shared/audioToFrames/src/audio/index.d.ts +0 -5
  29. package/shared/audioToFrames/src/audio/index.mjs +0 -375
  30. package/shared/audioToFrames/src/config.d.ts +0 -4
  31. package/shared/audioToFrames/src/core/constants.d.ts +0 -17
  32. package/shared/audioToFrames/src/core/index.d.ts +0 -6
  33. package/shared/audioToFrames/src/core/index.mjs +0 -24
  34. package/shared/audioToFrames/src/core/utils.d.ts +0 -26
  35. package/shared/audioToFrames/src/inference/StreamingInferenceService.d.ts +0 -189
  36. package/shared/audioToFrames/src/inference/index.d.ts +0 -5
  37. package/shared/audioToFrames/src/inference/index.mjs +0 -3
  38. package/shared/audioToFrames/src/media/DataLoaderService.d.ts +0 -59
  39. package/shared/audioToFrames/src/media/PredictiveFrameLoader.d.ts +0 -81
  40. package/shared/audioToFrames/src/media/index.d.ts +0 -6
  41. package/shared/audioToFrames/src/media/index.mjs +0 -236
  42. package/shared/config.mjs +0 -5
  43. package/shared/constants.mjs +0 -7
@@ -1,11 +1,11 @@
1
- import { defineComponent, ref, shallowReactive, onMounted, openBlock, createElementBlock, Fragment, createVNode, mergeProps, createBlock, createCommentVNode } from 'vue';
1
+ import { defineComponent, ref, onMounted, openBlock, createElementBlock, Fragment, createVNode, mergeProps, withCtx, renderSlot } from 'vue';
2
2
  import { VkBroadcastingMarkdown } from '@vunk/plus/components/broadcasting-markdown';
3
- import { VkPixiFrameBitmap, VkPixiFrameCore } from '@vunk/plus/components/pixi-frame';
4
- import { StreamingInferenceService, getStremingStartData, processStreaming, blobToAudioBuffer } from '@vunk/plus/shared/audioToFrames';
5
- export { workerConfig } from '@vunk/plus/shared/audioToFrames';
6
- import { useDeferred, useModelComputed } from '@vunk/core/composables';
3
+ import { VkPixiFrameBitmap, VkPixiFrameBitmapGenerator } from '@vunk/plus/components/pixi-frame';
4
+ import { blobToAudioBuffer } from '@vunk/plus/shared/data';
5
+ import { useModelComputed } from '@vunk/core/composables';
7
6
  import { setData } from '@vunk/core/shared';
8
7
  import { TickerStatus } from '@vunk/shared/enum';
8
+ import { FeatureExtractor, InferenceEngine, loadDataset } from 'sophontalk-services';
9
9
  import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
10
10
 
11
11
  const props = {
@@ -58,6 +58,10 @@ const props = {
58
58
  playAfterCache: {
59
59
  type: Number,
60
60
  default: 100
61
+ },
62
+ disabled: {
63
+ type: Boolean,
64
+ default: false
61
65
  }
62
66
  };
63
67
  const emits = {
@@ -77,58 +81,47 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
77
81
  const props = __props;
78
82
  const emit = __emit;
79
83
  const paragraphData = ref([]);
80
- const streamingInferenceService = new StreamingInferenceService(props.modelUrl);
81
- const frameUrls = ref([]);
82
- const silentFrameUrls = shallowReactive([]);
83
- const startedDef = useDeferred();
84
+ const extractor = new FeatureExtractor();
85
+ const engine = new InferenceEngine({
86
+ onFrame,
87
+ onError(error) {
88
+ console.error("Inference engine error:", error);
89
+ },
90
+ onProgress
91
+ });
92
+ const silentFrameGenerator = engine.createSilentFrameGenerator();
93
+ const slientFrameStatus = ref(TickerStatus.pending);
94
+ const frames = ref([]);
84
95
  const frameStatus = useModelComputed({
85
96
  default: TickerStatus.pending,
86
97
  key: "status"
87
98
  }, props, emit);
88
- const slientFrameStatus = ref(TickerStatus.pending);
89
99
  onMounted(async () => {
90
- await streamingInferenceService.when();
91
- const { blendingMaskBitmap, dataset, zipBlob, zip } = await getStremingStartData({
92
- datasetUrl: props.datasetUrl,
93
- sourceUrl: props.sourceUrl
100
+ const { dataset, zipBuffer } = await loadDataset({
101
+ jsonUrl: props.datasetUrl,
102
+ zipUrl: props.sourceUrl
94
103
  });
95
- loadAllSilentFrames(dataset, zip);
96
- await streamingInferenceService.startStreaming({
97
- blendingMaskBitmap,
104
+ engine.init({
105
+ modelPath: props.modelUrl,
98
106
  dataset,
99
- zipBlob
100
- }, {
101
- onFrame(frame) {
102
- frameUrls.value.push(frame);
103
- },
104
- onProgress(processed, total) {
105
- if (total < props.playAfterCache && processed === total || processed === props.playAfterCache) {
106
- frameStatus.value = TickerStatus.play;
107
- }
108
- }
107
+ zipBuffer
109
108
  });
110
- startedDef.resolve();
109
+ await engine.when();
110
+ slientFrameStatus.value = TickerStatus.play;
111
111
  });
112
- async function requestProcessStreaming(buffer) {
113
- await streamingInferenceService.when();
114
- await startedDef.promise;
115
- try {
116
- await processStreaming(buffer, {
117
- onChunkComplete(result) {
118
- streamingInferenceService.addChunk(result);
119
- }
120
- });
121
- } catch (error) {
122
- console.error("\u97F3\u9891\u5904\u7406\u9519\u8BEF:", error);
123
- }
124
- }
125
112
  async function processingParagraph(item) {
126
113
  if (!item.blob) {
127
114
  return;
128
115
  }
129
116
  try {
130
117
  const audioBuffer = await blobToAudioBuffer(item.blob);
131
- await requestProcessStreaming(audioBuffer);
118
+ const { dimensions, features } = await extractor.process(audioBuffer);
119
+ await engine.when();
120
+ engine.run({
121
+ audioFeatures: features,
122
+ audioDimensions: dimensions,
123
+ reset: false
124
+ });
132
125
  } catch (error) {
133
126
  console.error("Error processing paragraph:", error);
134
127
  }
@@ -136,30 +129,23 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
136
129
  function allParagraphCompleted() {
137
130
  if (paragraphData.value.length) {
138
131
  frameStatus.value = TickerStatus.stop;
139
- frameUrls.value.length = 0;
132
+ frames.value.length = 0;
140
133
  }
141
134
  }
142
- const ready = ref(false);
143
- async function loadAllSilentFrames(dataset, zip) {
144
- for (const image of dataset.images) {
145
- const imageFile = zip.file(image.full_image);
146
- if (imageFile) {
147
- const blob = await imageFile.async("blob");
148
- const url = URL.createObjectURL(blob);
149
- silentFrameUrls.push(url);
150
- }
151
- if (slientFrameStatus.value === TickerStatus.pending) {
152
- slientFrameStatus.value = TickerStatus.play;
153
- }
135
+ function onProgress(processed, total) {
136
+ if (total < props.playAfterCache && processed === total || processed === props.playAfterCache) {
137
+ frameStatus.value = TickerStatus.play;
154
138
  }
155
- ready.value = true;
156
139
  }
157
- const __returned__ = { props, emit, paragraphData, streamingInferenceService, frameUrls, silentFrameUrls, startedDef, frameStatus, slientFrameStatus, requestProcessStreaming, processingParagraph, allParagraphCompleted, ready, loadAllSilentFrames, get VkBroadcastingMarkdown() {
140
+ function onFrame(frame) {
141
+ frames.value.push(frame);
142
+ }
143
+ const __returned__ = { props, emit, paragraphData, extractor, engine, silentFrameGenerator, slientFrameStatus, frames, frameStatus, processingParagraph, allParagraphCompleted, onProgress, onFrame, get VkBroadcastingMarkdown() {
158
144
  return VkBroadcastingMarkdown;
159
145
  }, get VkPixiFrameBitmap() {
160
146
  return VkPixiFrameBitmap;
161
- }, get VkPixiFrameCore() {
162
- return VkPixiFrameCore;
147
+ }, get VkPixiFrameBitmapGenerator() {
148
+ return VkPixiFrameBitmapGenerator;
163
149
  }, get setData() {
164
150
  return setData;
165
151
  }, get TickerStatus() {
@@ -181,24 +167,28 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
181
167
  "text-to-speech": _ctx.textToSpeech,
182
168
  source: _ctx.source,
183
169
  processing: $setup.processingParagraph,
170
+ disabled: _ctx.disabled,
184
171
  onSetData: _cache[0] || (_cache[0] = ($event) => $setup.setData($setup.paragraphData, $event)),
185
172
  onComplete: $setup.allParagraphCompleted
186
- }), null, 16, ["status", "data", "text-to-speech", "source"]),
173
+ }), {
174
+ default: withCtx(({ paragraphs }) => [
175
+ renderSlot(_ctx.$slots, "default", { paragraphs })
176
+ ]),
177
+ _: 3
178
+ /* FORWARDED */
179
+ }, 16, ["status", "data", "text-to-speech", "source", "disabled"]),
187
180
  createVNode($setup["VkPixiFrameBitmap"], {
188
181
  status: $setup.frameStatus,
189
182
  "onUpdate:status": _cache[1] || (_cache[1] = ($event) => $setup.frameStatus = $event),
190
- data: $setup.frameUrls,
191
- onSetData: _cache[2] || (_cache[2] = ($event) => $setup.setData($setup.frameUrls, $event))
183
+ data: $setup.frames,
184
+ onSetData: _cache[2] || (_cache[2] = ($event) => $setup.setData($setup.frames, $event))
192
185
  }, null, 8, ["status", "data"]),
193
- $setup.ready ? (openBlock(), createBlock($setup["VkPixiFrameCore"], {
194
- key: 0,
186
+ createVNode($setup["VkPixiFrameBitmapGenerator"], {
195
187
  status: $setup.slientFrameStatus,
196
188
  "onUpdate:status": _cache[3] || (_cache[3] = ($event) => $setup.slientFrameStatus = $event),
197
- data: $setup.silentFrameUrls,
198
- loop: true,
199
- prerender: true,
189
+ generator: $setup.silentFrameGenerator,
200
190
  visible: $setup.frameStatus !== $setup.TickerStatus.playing
201
- }, null, 8, ["status", "data", "visible"])) : createCommentVNode("v-if", true)
191
+ }, null, 8, ["status", "generator", "visible"])
202
192
  ],
203
193
  64
204
194
  /* STABLE_FRAGMENT */
@@ -51,6 +51,10 @@ export declare const props: {
51
51
  type: NumberConstructor;
52
52
  default: number;
53
53
  };
54
+ disabled: {
55
+ type: BooleanConstructor;
56
+ default: boolean;
57
+ };
54
58
  };
55
59
  export declare const emits: {
56
60
  'update:status': null;