@ray-js/t-agent-plugin-aistream 0.2.8-beta.3 → 0.2.8-beta.4
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.
- package/dist/buildIn/withBuildIn.js +23 -36
- package/package.json +2 -2
|
@@ -216,52 +216,39 @@ export function withBuildIn(options) {
|
|
|
216
216
|
// 音频包结束时,往气泡里插入一个语音播放按钮(BubbleToolTile)。
|
|
217
217
|
// 只持久化播放所需的音频参数,不含 playing 状态。
|
|
218
218
|
//
|
|
219
|
-
//
|
|
220
|
-
//
|
|
221
|
-
//
|
|
222
|
-
//
|
|
223
|
-
//
|
|
219
|
+
// 注意:音频按流式分多包下发,播放所需的完整参数(path + 格式头
|
|
220
|
+
// codecType/sampleRate/channels/bitDepth)只在首包(START/ONLY_ONE)携带;
|
|
221
|
+
// 后续 END 等包里这些字段是 0(而非 null/undefined),会污染数据。
|
|
222
|
+
// 因此只取每段音频的首包,丢弃后续包,按音频流 id(part.id 在同一段音频的
|
|
223
|
+
// 所有分包间一致)去重。
|
|
224
224
|
onAttachmentsEnd((parts, respMsg) => {
|
|
225
225
|
const audioMap = new Map();
|
|
226
226
|
parts.forEach(i => {
|
|
227
|
-
var _audio$path, _audio$pts, _audio$codecType, _audio$sampleRate, _audio$channels, _audio$bitDepth;
|
|
228
227
|
if (i.attachmentType !== 'audio') {
|
|
229
228
|
return;
|
|
230
229
|
}
|
|
231
230
|
const audio = i.attachment;
|
|
232
|
-
const entry = audioMap.get(i.id) || {
|
|
233
|
-
audio: {},
|
|
234
|
-
complete: false
|
|
235
|
-
};
|
|
236
231
|
|
|
237
|
-
//
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
pts: (_audio$pts = audio.pts) !== null && _audio$pts !== void 0 ? _audio$pts : entry.audio.pts,
|
|
241
|
-
codecType: (_audio$codecType = audio.codecType) !== null && _audio$codecType !== void 0 ? _audio$codecType : entry.audio.codecType,
|
|
242
|
-
sampleRate: (_audio$sampleRate = audio.sampleRate) !== null && _audio$sampleRate !== void 0 ? _audio$sampleRate : entry.audio.sampleRate,
|
|
243
|
-
channels: (_audio$channels = audio.channels) !== null && _audio$channels !== void 0 ? _audio$channels : entry.audio.channels,
|
|
244
|
-
bitDepth: (_audio$bitDepth = audio.bitDepth) !== null && _audio$bitDepth !== void 0 ? _audio$bitDepth : entry.audio.bitDepth
|
|
245
|
-
};
|
|
246
|
-
if (audio.streamFlag === StreamFlag.ONLY_ONE || audio.streamFlag === StreamFlag.END) {
|
|
247
|
-
entry.complete = true;
|
|
248
|
-
// END 包的 path 是最终完整文件,确保覆盖
|
|
249
|
-
if (audio.path) {
|
|
250
|
-
entry.audio.path = audio.path;
|
|
251
|
-
}
|
|
232
|
+
// 只接收首包,后续包直接丢弃
|
|
233
|
+
if (audio.streamFlag !== StreamFlag.START && audio.streamFlag !== StreamFlag.ONLY_ONE) {
|
|
234
|
+
return;
|
|
252
235
|
}
|
|
253
|
-
audioMap.
|
|
254
|
-
|
|
255
|
-
audioMap.forEach(_ref => {
|
|
256
|
-
let {
|
|
257
|
-
audio,
|
|
258
|
-
complete
|
|
259
|
-
} = _ref;
|
|
260
|
-
if (complete) {
|
|
261
|
-
respMsg.bubble.addTile('bubbleTool', {
|
|
262
|
-
audio
|
|
263
|
-
});
|
|
236
|
+
if (audioMap.has(i.id)) {
|
|
237
|
+
return;
|
|
264
238
|
}
|
|
239
|
+
audioMap.set(i.id, {
|
|
240
|
+
path: audio.path,
|
|
241
|
+
pts: audio.pts,
|
|
242
|
+
codecType: audio.codecType,
|
|
243
|
+
sampleRate: audio.sampleRate,
|
|
244
|
+
channels: audio.channels,
|
|
245
|
+
bitDepth: audio.bitDepth
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
audioMap.forEach(audio => {
|
|
249
|
+
respMsg.bubble.addTile('bubbleTool', {
|
|
250
|
+
audio
|
|
251
|
+
});
|
|
265
252
|
});
|
|
266
253
|
});
|
|
267
254
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/t-agent-plugin-aistream",
|
|
3
|
-
"version": "0.2.8-beta.
|
|
3
|
+
"version": "0.2.8-beta.4",
|
|
4
4
|
"author": "Tuya.inc",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/url-parse": "^1.4.11"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "556407c77bdeb9f879a8bb9e89184fc62e4c8bd0"
|
|
40
40
|
}
|