@proj-airi/trace-kit 0.0.0-stage → 0.15.2
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/LICENSE +21 -0
- package/README.md +102 -2
- package/dist/clock-CewQJzn8.d.mts +545 -0
- package/dist/clock-hjTPEs21.mjs +212 -0
- package/dist/collector/index.d.mts +207 -0
- package/dist/collector/index.mjs +601 -0
- package/dist/conventions-DLiC8rkL.mjs +285 -0
- package/dist/index-DV04qeax.d.mts +49 -0
- package/dist/index.d.mts +782 -0
- package/dist/index.mjs +6 -0
- package/dist/keys-DD_VE8Fk.mjs +34 -0
- package/dist/profiles/agent.d.mts +70 -0
- package/dist/profiles/agent.mjs +295 -0
- package/dist/profiles/voice.d.mts +128 -0
- package/dist/profiles/voice.mjs +669 -0
- package/dist/projections/index.d.mts +3 -0
- package/dist/projections/index.mjs +1 -0
- package/dist/semconv-BOVWnou1.d.mts +832 -0
- package/dist/semconv.d.mts +2 -0
- package/dist/semconv.mjs +832 -0
- package/dist/series-ring-CaKfvyWQ.mjs +118 -0
- package/dist/series-ring-DCb7czkl.d.mts +49 -0
- package/dist/sink-BoftsA-W.mjs +501 -0
- package/dist/testing/index.d.mts +79 -0
- package/dist/testing/index.mjs +880 -0
- package/dist/timeline-B4Vc6qQf.mjs +766 -0
- package/dist/types-Fp54Yi6b.d.mts +319 -0
- package/dist/views/index.d.mts +97 -0
- package/dist/views/index.mjs +219 -0
- package/package.json +71 -3
|
@@ -0,0 +1,669 @@
|
|
|
1
|
+
import { B as definePipeline, E as TraceEdgeKinds, H as defineProfile, I as defineEndReason, L as defineIdKey, P as defineAttribute, V as definePreset, W as defineTrack, a as ATTR_DECISION_LATENCY_MS, q as matchTrackPath, z as defineMetric } from "../conventions-DLiC8rkL.mjs";
|
|
2
|
+
import { r as spanKeyOf } from "../keys-DD_VE8Fk.mjs";
|
|
3
|
+
//#region src/profiles/voice.ts
|
|
4
|
+
/** Track path patterns of the voice profile. Fill them with `trackPath`. */
|
|
5
|
+
const VoiceTracks = {
|
|
6
|
+
State: "participants/{actor}/state",
|
|
7
|
+
Wake: "participants/{actor}/wake",
|
|
8
|
+
Input: "participants/{actor}/input",
|
|
9
|
+
Speech: "participants/{actor}/speech",
|
|
10
|
+
ASR: "participants/{actor}/asr",
|
|
11
|
+
Rephrase: "participants/{actor}/rephrase",
|
|
12
|
+
Text: "participants/{actor}/text",
|
|
13
|
+
Output: "participants/{actor}/output",
|
|
14
|
+
TTS: "participants/{actor}/tts",
|
|
15
|
+
Playback: "participants/{actor}/playback",
|
|
16
|
+
Floor: "conversations/{conversation}/floor",
|
|
17
|
+
Endpoint: "conversations/{conversation}/endpoint",
|
|
18
|
+
Speculation: "conversations/{conversation}/speculation"
|
|
19
|
+
};
|
|
20
|
+
/** Value keys of the voice series. */
|
|
21
|
+
const VoiceSeries = {
|
|
22
|
+
/** Audio level from -60 dBFS (0) to full scale (1), on the input and playback tracks. */
|
|
23
|
+
Level: "level",
|
|
24
|
+
/** Speech probability of the VAD, from 0 to 1, on the input track. One sample for each detector window, like the level. */
|
|
25
|
+
Probability: "probability"
|
|
26
|
+
};
|
|
27
|
+
const VoiceIdKeys = {
|
|
28
|
+
Conversation: "conversation",
|
|
29
|
+
Turn: "turn",
|
|
30
|
+
TurnSeq: "turnSeq",
|
|
31
|
+
Input: "input",
|
|
32
|
+
Response: "response",
|
|
33
|
+
Segment: "segment",
|
|
34
|
+
Speculation: "speculation",
|
|
35
|
+
Interrupt: "interrupt",
|
|
36
|
+
Actor: "actor"
|
|
37
|
+
};
|
|
38
|
+
/** Span and instant names. Instants use `<object>.<past-tense verb>`. */
|
|
39
|
+
const VoiceNames = {
|
|
40
|
+
WakeWord: "wake-word",
|
|
41
|
+
VoiceInput: "voice-input",
|
|
42
|
+
SpeechSegment: "speech",
|
|
43
|
+
SpeechRecognition: "asr",
|
|
44
|
+
EndpointJudgement: "endpoint.judgement",
|
|
45
|
+
TranscriptRephrase: "transcript.rephrase",
|
|
46
|
+
SpeechOutput: "speech-output",
|
|
47
|
+
TTSRequest: "tts",
|
|
48
|
+
Playback: "playback",
|
|
49
|
+
SpeechStarted: "speech.started",
|
|
50
|
+
SpeechStopped: "speech.stopped",
|
|
51
|
+
TranscriptPartial: "transcript.partial",
|
|
52
|
+
TranscriptFinal: "transcript.final",
|
|
53
|
+
EndpointDecided: "endpoint.decided",
|
|
54
|
+
TurnEnded: "turn.ended",
|
|
55
|
+
TurnHeld: "turn.held",
|
|
56
|
+
FloorTaken: "floor.taken",
|
|
57
|
+
FloorReleased: "floor.released",
|
|
58
|
+
InterruptStarted: "interrupt.started",
|
|
59
|
+
BackchannelDetected: "backchannel.detected",
|
|
60
|
+
OutputTruncated: "output.truncated",
|
|
61
|
+
TTSFirstByte: "tts.first_byte",
|
|
62
|
+
TTSFirstAudible: "tts.first_audible"
|
|
63
|
+
};
|
|
64
|
+
/** Attributes of the voice profile. */
|
|
65
|
+
const VoiceAttributes = {
|
|
66
|
+
/** `control` (a voice button or Push to Talk), `speech` (VAD), or `wake-word`. */
|
|
67
|
+
InputTrigger: "voice.input.trigger",
|
|
68
|
+
/** `committed`, `drafted`, `cancelled`, or `failed`. */
|
|
69
|
+
InputOutcome: "voice.input.outcome",
|
|
70
|
+
InputReason: "voice.input.reason",
|
|
71
|
+
WakeCharacterId: "voice.wake.character_id",
|
|
72
|
+
WakeText: "voice.wake.text",
|
|
73
|
+
WakeTokens: "voice.wake.tokens",
|
|
74
|
+
SpeechDurationMs: "voice.speech.duration_ms",
|
|
75
|
+
VADAborted: "voice.vad.aborted",
|
|
76
|
+
/** The VAD probability that begins speech, on the input span. The viewer draws it as a dashed line over the probability. */
|
|
77
|
+
VADThreshold: "voice.vad.threshold",
|
|
78
|
+
SpeakerScore: "voice.speaker.score",
|
|
79
|
+
SpeakerScores: "voice.speaker.scores",
|
|
80
|
+
SpeakerVoicedMs: "voice.speaker.voiced_ms",
|
|
81
|
+
SpeakerRejectedCount: "voice.speaker.rejected_count",
|
|
82
|
+
ASRText: "asr.text",
|
|
83
|
+
EndpointTranscriptLength: "endpoint.transcript_length",
|
|
84
|
+
RephraseSegmentCount: "rephrase.segment_count",
|
|
85
|
+
RephraseChangedCount: "rephrase.changed_count",
|
|
86
|
+
TTSText: "tts.text",
|
|
87
|
+
TTSChunkReason: "tts.chunk_reason",
|
|
88
|
+
TTSAudioDurationMs: "tts.audio_duration_ms",
|
|
89
|
+
TTSTtfbMs: "tts.ttfb_ms",
|
|
90
|
+
TurnAddressees: "turn.addressees",
|
|
91
|
+
FloorSelection: "floor.selection",
|
|
92
|
+
FloorTakeReason: "floor.take.reason",
|
|
93
|
+
Interrupter: "interrupter",
|
|
94
|
+
Interrupted: "interrupted",
|
|
95
|
+
OverlapIntent: "overlap.intent",
|
|
96
|
+
OverlapResponse: "overlap.response",
|
|
97
|
+
HeardFrames: "heard.frames",
|
|
98
|
+
PlannedFrames: "planned.frames",
|
|
99
|
+
HeardChars: "heard.chars",
|
|
100
|
+
HeardText: "heard.text",
|
|
101
|
+
HeardMethod: "heard.method"
|
|
102
|
+
};
|
|
103
|
+
const voiceProfile = defineProfile({
|
|
104
|
+
key: "voice",
|
|
105
|
+
version: "1",
|
|
106
|
+
label: {
|
|
107
|
+
"en": "Voice",
|
|
108
|
+
"zh-Hans": "语音"
|
|
109
|
+
},
|
|
110
|
+
description: {
|
|
111
|
+
"en": "A conversation with any number of participants: speech, recognition, end of turn, synthesis, and playback.",
|
|
112
|
+
"zh-Hans": "任意人数参与的对话:说话、识别、轮次结束、合成与播放。"
|
|
113
|
+
},
|
|
114
|
+
tracks: [
|
|
115
|
+
defineTrack({
|
|
116
|
+
path: VoiceTracks.State,
|
|
117
|
+
entity: "actor",
|
|
118
|
+
group: "participants",
|
|
119
|
+
order: 0,
|
|
120
|
+
render: ["state"],
|
|
121
|
+
states: [
|
|
122
|
+
"initializing",
|
|
123
|
+
"idle",
|
|
124
|
+
"listening",
|
|
125
|
+
"thinking",
|
|
126
|
+
"waiting",
|
|
127
|
+
"speaking",
|
|
128
|
+
"away"
|
|
129
|
+
],
|
|
130
|
+
label: {
|
|
131
|
+
"en": "State",
|
|
132
|
+
"zh-Hans": "状态"
|
|
133
|
+
}
|
|
134
|
+
}),
|
|
135
|
+
defineTrack({
|
|
136
|
+
path: VoiceTracks.Wake,
|
|
137
|
+
entity: "actor",
|
|
138
|
+
activity: "thinking",
|
|
139
|
+
group: "participants",
|
|
140
|
+
order: 10,
|
|
141
|
+
render: ["spans"],
|
|
142
|
+
color: "#d946ef",
|
|
143
|
+
icon: "i-mingcute:bell-ringing-line",
|
|
144
|
+
label: {
|
|
145
|
+
"en": "Wake word",
|
|
146
|
+
"zh-Hans": "唤醒词"
|
|
147
|
+
}
|
|
148
|
+
}),
|
|
149
|
+
defineTrack({
|
|
150
|
+
path: VoiceTracks.Input,
|
|
151
|
+
entity: "actor",
|
|
152
|
+
activity: "waiting",
|
|
153
|
+
group: "participants",
|
|
154
|
+
order: 20,
|
|
155
|
+
render: ["spans", "series"],
|
|
156
|
+
unit: "level",
|
|
157
|
+
retention: {
|
|
158
|
+
keep: "window",
|
|
159
|
+
maxHz: 40
|
|
160
|
+
},
|
|
161
|
+
color: "#6366f1",
|
|
162
|
+
icon: "i-mingcute:voice-line",
|
|
163
|
+
label: {
|
|
164
|
+
"en": "Voice input",
|
|
165
|
+
"zh-Hans": "语音输入"
|
|
166
|
+
}
|
|
167
|
+
}),
|
|
168
|
+
defineTrack({
|
|
169
|
+
path: VoiceTracks.Speech,
|
|
170
|
+
entity: "actor",
|
|
171
|
+
activity: "active",
|
|
172
|
+
group: "participants",
|
|
173
|
+
order: 30,
|
|
174
|
+
render: ["spans", "instants"],
|
|
175
|
+
color: "#f59e0b",
|
|
176
|
+
icon: "i-mingcute:sound-line-line",
|
|
177
|
+
label: {
|
|
178
|
+
"en": "Speech",
|
|
179
|
+
"zh-Hans": "说话"
|
|
180
|
+
}
|
|
181
|
+
}),
|
|
182
|
+
defineTrack({
|
|
183
|
+
path: VoiceTracks.ASR,
|
|
184
|
+
entity: "actor",
|
|
185
|
+
activity: "thinking",
|
|
186
|
+
group: "participants",
|
|
187
|
+
order: 40,
|
|
188
|
+
render: ["spans", "instants"],
|
|
189
|
+
color: "#3b82f6",
|
|
190
|
+
icon: "i-mingcute:mic-line",
|
|
191
|
+
label: {
|
|
192
|
+
"en": "Speech recognition",
|
|
193
|
+
"zh-Hans": "语音识别"
|
|
194
|
+
}
|
|
195
|
+
}),
|
|
196
|
+
defineTrack({
|
|
197
|
+
path: VoiceTracks.Rephrase,
|
|
198
|
+
entity: "actor",
|
|
199
|
+
activity: "thinking",
|
|
200
|
+
group: "participants",
|
|
201
|
+
order: 45,
|
|
202
|
+
render: ["spans"],
|
|
203
|
+
color: "#14b8a6",
|
|
204
|
+
icon: "i-mingcute:edit-2-line",
|
|
205
|
+
label: {
|
|
206
|
+
"en": "Rephrase",
|
|
207
|
+
"zh-Hans": "改写"
|
|
208
|
+
}
|
|
209
|
+
}),
|
|
210
|
+
defineTrack({
|
|
211
|
+
path: VoiceTracks.Text,
|
|
212
|
+
entity: "actor",
|
|
213
|
+
group: "participants",
|
|
214
|
+
order: 50,
|
|
215
|
+
render: ["instants"],
|
|
216
|
+
label: {
|
|
217
|
+
"en": "Text",
|
|
218
|
+
"zh-Hans": "文本"
|
|
219
|
+
}
|
|
220
|
+
}),
|
|
221
|
+
defineTrack({
|
|
222
|
+
path: VoiceTracks.Output,
|
|
223
|
+
entity: "actor",
|
|
224
|
+
activity: "waiting",
|
|
225
|
+
group: "participants",
|
|
226
|
+
order: 60,
|
|
227
|
+
render: ["spans"],
|
|
228
|
+
color: "#64748b",
|
|
229
|
+
icon: "i-mingcute:message-3-line",
|
|
230
|
+
label: {
|
|
231
|
+
"en": "Speech output",
|
|
232
|
+
"zh-Hans": "语音输出"
|
|
233
|
+
}
|
|
234
|
+
}),
|
|
235
|
+
defineTrack({
|
|
236
|
+
path: VoiceTracks.TTS,
|
|
237
|
+
entity: "actor",
|
|
238
|
+
activity: "thinking",
|
|
239
|
+
group: "participants",
|
|
240
|
+
order: 70,
|
|
241
|
+
render: ["spans", "instants"],
|
|
242
|
+
color: "#22c55e",
|
|
243
|
+
icon: "i-mingcute:voice-2-line",
|
|
244
|
+
label: {
|
|
245
|
+
"en": "TTS",
|
|
246
|
+
"zh-Hans": "语音合成"
|
|
247
|
+
}
|
|
248
|
+
}),
|
|
249
|
+
defineTrack({
|
|
250
|
+
path: VoiceTracks.Playback,
|
|
251
|
+
entity: "actor",
|
|
252
|
+
activity: "active",
|
|
253
|
+
group: "participants",
|
|
254
|
+
order: 80,
|
|
255
|
+
render: [
|
|
256
|
+
"spans",
|
|
257
|
+
"state",
|
|
258
|
+
"series"
|
|
259
|
+
],
|
|
260
|
+
unit: "level",
|
|
261
|
+
retention: {
|
|
262
|
+
keep: "window",
|
|
263
|
+
maxHz: 40
|
|
264
|
+
},
|
|
265
|
+
states: [
|
|
266
|
+
"idle",
|
|
267
|
+
"playing",
|
|
268
|
+
"paused"
|
|
269
|
+
],
|
|
270
|
+
color: "#06b6d4",
|
|
271
|
+
icon: "i-mingcute:play-line",
|
|
272
|
+
label: {
|
|
273
|
+
"en": "Playback",
|
|
274
|
+
"zh-Hans": "播放"
|
|
275
|
+
}
|
|
276
|
+
}),
|
|
277
|
+
defineTrack({
|
|
278
|
+
path: VoiceTracks.Floor,
|
|
279
|
+
entity: "conversation",
|
|
280
|
+
group: "conversations",
|
|
281
|
+
order: 0,
|
|
282
|
+
render: ["instants"],
|
|
283
|
+
label: {
|
|
284
|
+
"en": "Floor",
|
|
285
|
+
"zh-Hans": "话轮"
|
|
286
|
+
}
|
|
287
|
+
}),
|
|
288
|
+
defineTrack({
|
|
289
|
+
path: VoiceTracks.Endpoint,
|
|
290
|
+
entity: "conversation",
|
|
291
|
+
activity: "thinking",
|
|
292
|
+
group: "conversations",
|
|
293
|
+
order: 10,
|
|
294
|
+
render: ["spans", "instants"],
|
|
295
|
+
color: "#f97316",
|
|
296
|
+
icon: "i-mingcute:balance-line",
|
|
297
|
+
label: {
|
|
298
|
+
"en": "End of turn",
|
|
299
|
+
"zh-Hans": "轮次结束"
|
|
300
|
+
}
|
|
301
|
+
}),
|
|
302
|
+
defineTrack({
|
|
303
|
+
path: VoiceTracks.Speculation,
|
|
304
|
+
entity: "conversation",
|
|
305
|
+
group: "conversations",
|
|
306
|
+
order: 20,
|
|
307
|
+
render: ["state"],
|
|
308
|
+
states: [
|
|
309
|
+
"open",
|
|
310
|
+
"holding",
|
|
311
|
+
"dropping"
|
|
312
|
+
],
|
|
313
|
+
label: {
|
|
314
|
+
"en": "Speculation",
|
|
315
|
+
"zh-Hans": "预测"
|
|
316
|
+
}
|
|
317
|
+
})
|
|
318
|
+
],
|
|
319
|
+
idKeys: Object.values(VoiceIdKeys).map((key) => defineIdKey({ key })),
|
|
320
|
+
attributes: [
|
|
321
|
+
defineAttribute({
|
|
322
|
+
key: VoiceAttributes.ASRText,
|
|
323
|
+
type: "string",
|
|
324
|
+
sensitivity: "content"
|
|
325
|
+
}),
|
|
326
|
+
defineAttribute({
|
|
327
|
+
key: VoiceAttributes.TTSText,
|
|
328
|
+
type: "string",
|
|
329
|
+
sensitivity: "content"
|
|
330
|
+
}),
|
|
331
|
+
defineAttribute({
|
|
332
|
+
key: VoiceAttributes.HeardText,
|
|
333
|
+
type: "string",
|
|
334
|
+
sensitivity: "content"
|
|
335
|
+
}),
|
|
336
|
+
defineAttribute({
|
|
337
|
+
key: VoiceAttributes.WakeText,
|
|
338
|
+
type: "string",
|
|
339
|
+
sensitivity: "content"
|
|
340
|
+
}),
|
|
341
|
+
defineAttribute({
|
|
342
|
+
key: VoiceAttributes.TTSTtfbMs,
|
|
343
|
+
type: "number",
|
|
344
|
+
unit: "ms",
|
|
345
|
+
sensitivity: "none",
|
|
346
|
+
aggregatable: true
|
|
347
|
+
}),
|
|
348
|
+
defineAttribute({
|
|
349
|
+
key: VoiceAttributes.TTSAudioDurationMs,
|
|
350
|
+
type: "number",
|
|
351
|
+
unit: "ms",
|
|
352
|
+
sensitivity: "none",
|
|
353
|
+
aggregatable: true
|
|
354
|
+
}),
|
|
355
|
+
defineAttribute({
|
|
356
|
+
key: VoiceAttributes.SpeechDurationMs,
|
|
357
|
+
type: "number",
|
|
358
|
+
unit: "ms",
|
|
359
|
+
sensitivity: "none",
|
|
360
|
+
aggregatable: true
|
|
361
|
+
})
|
|
362
|
+
],
|
|
363
|
+
endReasons: [defineEndReason({
|
|
364
|
+
reason: "interrupted",
|
|
365
|
+
label: {
|
|
366
|
+
"en": "Interrupted",
|
|
367
|
+
"zh-Hans": "被打断"
|
|
368
|
+
}
|
|
369
|
+
}), defineEndReason({
|
|
370
|
+
reason: "no-audio",
|
|
371
|
+
label: {
|
|
372
|
+
"en": "No audio",
|
|
373
|
+
"zh-Hans": "无音频"
|
|
374
|
+
}
|
|
375
|
+
})],
|
|
376
|
+
metrics: [
|
|
377
|
+
defineMetric({
|
|
378
|
+
key: "voice.response_latency",
|
|
379
|
+
label: {
|
|
380
|
+
"en": "Response latency",
|
|
381
|
+
"zh-Hans": "响应延迟"
|
|
382
|
+
},
|
|
383
|
+
description: {
|
|
384
|
+
"en": "From the speech end of the previous speaker to the first audible frame of the next speaker.",
|
|
385
|
+
"zh-Hans": "从上一位说话人说完,到下一位说话人第一帧可听见的声音。"
|
|
386
|
+
},
|
|
387
|
+
unit: "ms",
|
|
388
|
+
better: "lower",
|
|
389
|
+
dimensions: ["from", "to"],
|
|
390
|
+
value: {
|
|
391
|
+
kind: "derived",
|
|
392
|
+
projection: "voice.floor-transfer"
|
|
393
|
+
}
|
|
394
|
+
}),
|
|
395
|
+
defineMetric({
|
|
396
|
+
key: "voice.floor_transfer_offset",
|
|
397
|
+
label: {
|
|
398
|
+
"en": "Floor transfer offset",
|
|
399
|
+
"zh-Hans": "话轮交接间隔"
|
|
400
|
+
},
|
|
401
|
+
description: {
|
|
402
|
+
"en": "The speech start of the next speaker minus the speech end of the previous speaker. A negative value is an overlap.",
|
|
403
|
+
"zh-Hans": "下一位说话人开始说话的时间减去上一位说完的时间。负值表示重叠。"
|
|
404
|
+
},
|
|
405
|
+
unit: "ms",
|
|
406
|
+
dimensions: ["from", "to"],
|
|
407
|
+
aggregate: [
|
|
408
|
+
"p50",
|
|
409
|
+
"p95",
|
|
410
|
+
"count"
|
|
411
|
+
],
|
|
412
|
+
value: {
|
|
413
|
+
kind: "derived",
|
|
414
|
+
projection: "voice.floor-transfer"
|
|
415
|
+
}
|
|
416
|
+
}),
|
|
417
|
+
defineMetric({
|
|
418
|
+
key: "tts.ttfb_ms",
|
|
419
|
+
label: {
|
|
420
|
+
"en": "TTS first byte",
|
|
421
|
+
"zh-Hans": "TTS 首字节"
|
|
422
|
+
},
|
|
423
|
+
description: {
|
|
424
|
+
"en": "From the TTS request to the first audio byte.",
|
|
425
|
+
"zh-Hans": "从发出 TTS 请求到收到第一个音频字节。"
|
|
426
|
+
},
|
|
427
|
+
unit: "ms",
|
|
428
|
+
better: "lower",
|
|
429
|
+
value: {
|
|
430
|
+
kind: "attribute",
|
|
431
|
+
track: VoiceTracks.TTS,
|
|
432
|
+
record: "span.end",
|
|
433
|
+
attribute: VoiceAttributes.TTSTtfbMs
|
|
434
|
+
}
|
|
435
|
+
}),
|
|
436
|
+
defineMetric({
|
|
437
|
+
key: "voice.endpoint_latency",
|
|
438
|
+
label: {
|
|
439
|
+
"en": "End-of-turn decision",
|
|
440
|
+
"zh-Hans": "轮次结束判断耗时"
|
|
441
|
+
},
|
|
442
|
+
description: {
|
|
443
|
+
"en": "How long one end-of-turn decision took.",
|
|
444
|
+
"zh-Hans": "一次轮次结束判断用了多久。"
|
|
445
|
+
},
|
|
446
|
+
unit: "ms",
|
|
447
|
+
better: "lower",
|
|
448
|
+
value: {
|
|
449
|
+
kind: "attribute",
|
|
450
|
+
track: VoiceTracks.Endpoint,
|
|
451
|
+
record: "span.end",
|
|
452
|
+
attribute: ATTR_DECISION_LATENCY_MS
|
|
453
|
+
}
|
|
454
|
+
})
|
|
455
|
+
],
|
|
456
|
+
pipelines: [definePipeline({
|
|
457
|
+
key: "voice.turn",
|
|
458
|
+
label: {
|
|
459
|
+
"en": "Voice turn",
|
|
460
|
+
"zh-Hans": "语音轮次"
|
|
461
|
+
},
|
|
462
|
+
stages: [
|
|
463
|
+
{
|
|
464
|
+
key: "wake",
|
|
465
|
+
label: {
|
|
466
|
+
"en": "Wake word",
|
|
467
|
+
"zh-Hans": "唤醒词"
|
|
468
|
+
},
|
|
469
|
+
tracks: [VoiceTracks.Wake]
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
key: "input",
|
|
473
|
+
label: {
|
|
474
|
+
"en": "Input",
|
|
475
|
+
"zh-Hans": "输入"
|
|
476
|
+
},
|
|
477
|
+
tracks: [VoiceTracks.Input, VoiceTracks.Speech]
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
key: "asr",
|
|
481
|
+
label: {
|
|
482
|
+
"en": "Recognition",
|
|
483
|
+
"zh-Hans": "识别"
|
|
484
|
+
},
|
|
485
|
+
tracks: [VoiceTracks.ASR]
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
key: "endpoint",
|
|
489
|
+
label: {
|
|
490
|
+
"en": "End of turn",
|
|
491
|
+
"zh-Hans": "轮次结束"
|
|
492
|
+
},
|
|
493
|
+
tracks: [VoiceTracks.Endpoint, VoiceTracks.Rephrase]
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
key: "agent",
|
|
497
|
+
label: {
|
|
498
|
+
"en": "Agent",
|
|
499
|
+
"zh-Hans": "智能体"
|
|
500
|
+
},
|
|
501
|
+
tracks: ["agents/{agent}/turn", "agents/{agent}/llm"]
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
key: "tts",
|
|
505
|
+
label: {
|
|
506
|
+
"en": "Synthesis",
|
|
507
|
+
"zh-Hans": "合成"
|
|
508
|
+
},
|
|
509
|
+
tracks: [VoiceTracks.Output, VoiceTracks.TTS]
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
key: "playback",
|
|
513
|
+
label: {
|
|
514
|
+
"en": "Playback",
|
|
515
|
+
"zh-Hans": "播放"
|
|
516
|
+
},
|
|
517
|
+
tracks: [VoiceTracks.Playback]
|
|
518
|
+
}
|
|
519
|
+
],
|
|
520
|
+
edges: [
|
|
521
|
+
{
|
|
522
|
+
from: "wake",
|
|
523
|
+
to: "input",
|
|
524
|
+
kind: TraceEdgeKinds.Signal,
|
|
525
|
+
name: "wake"
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
from: "input",
|
|
529
|
+
to: "asr",
|
|
530
|
+
kind: TraceEdgeKinds.Audio,
|
|
531
|
+
name: "speech"
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
from: "asr",
|
|
535
|
+
to: "endpoint",
|
|
536
|
+
kind: TraceEdgeKinds.Data,
|
|
537
|
+
name: "transcript"
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
from: "endpoint",
|
|
541
|
+
to: "agent",
|
|
542
|
+
kind: TraceEdgeKinds.Command,
|
|
543
|
+
name: "submit"
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
from: "agent",
|
|
547
|
+
to: "tts",
|
|
548
|
+
kind: TraceEdgeKinds.Data,
|
|
549
|
+
name: "text"
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
from: "tts",
|
|
553
|
+
to: "playback",
|
|
554
|
+
kind: TraceEdgeKinds.Audio,
|
|
555
|
+
name: "audio"
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
from: "playback",
|
|
559
|
+
to: "input",
|
|
560
|
+
kind: TraceEdgeKinds.Signal,
|
|
561
|
+
name: "barge-in"
|
|
562
|
+
}
|
|
563
|
+
]
|
|
564
|
+
})],
|
|
565
|
+
presets: [definePreset({
|
|
566
|
+
key: "voice.turn",
|
|
567
|
+
label: {
|
|
568
|
+
"en": "Voice turn",
|
|
569
|
+
"zh-Hans": "语音轮次"
|
|
570
|
+
},
|
|
571
|
+
tracks: [
|
|
572
|
+
"participants/{actor}/*",
|
|
573
|
+
"conversations/{conversation}/*",
|
|
574
|
+
"agents/{agent}/*"
|
|
575
|
+
]
|
|
576
|
+
}), definePreset({
|
|
577
|
+
key: "voice.barge-in",
|
|
578
|
+
label: {
|
|
579
|
+
"en": "Barge-in",
|
|
580
|
+
"zh-Hans": "插话"
|
|
581
|
+
},
|
|
582
|
+
tracks: [
|
|
583
|
+
VoiceTracks.Input,
|
|
584
|
+
VoiceTracks.Speech,
|
|
585
|
+
VoiceTracks.Playback,
|
|
586
|
+
VoiceTracks.Floor,
|
|
587
|
+
VoiceTracks.Endpoint
|
|
588
|
+
]
|
|
589
|
+
})]
|
|
590
|
+
});
|
|
591
|
+
/** A track path that holds speech of one participant: detected speech, or played audio of an agent. */
|
|
592
|
+
function speakerOf(track) {
|
|
593
|
+
return matchTrackPath(VoiceTracks.Speech, track)?.actor ?? matchTrackPath(VoiceTracks.Playback, track)?.actor;
|
|
594
|
+
}
|
|
595
|
+
/** Opens the speech of a span. A start after the speech of another participant is a floor transfer. */
|
|
596
|
+
function beginSpeech(state, key, open, time) {
|
|
597
|
+
state.open.set(key, open);
|
|
598
|
+
const { actor } = open;
|
|
599
|
+
const last = state.last;
|
|
600
|
+
if (last && last.actor !== actor && last.end !== void 0) {
|
|
601
|
+
const sample = {
|
|
602
|
+
time,
|
|
603
|
+
value: time - last.end,
|
|
604
|
+
dimensions: {
|
|
605
|
+
from: last.actor,
|
|
606
|
+
to: actor
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
(state.samples["voice.floor_transfer_offset"] ??= []).push(sample);
|
|
610
|
+
if (sample.value >= 0) (state.samples["voice.response_latency"] ??= []).push(sample);
|
|
611
|
+
}
|
|
612
|
+
if (!last || last.actor !== actor || last.end !== void 0) state.last = {
|
|
613
|
+
actor,
|
|
614
|
+
end: void 0
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
/** Closes the speech of a span. The speech of its actor ends when no other span of that actor is open. */
|
|
618
|
+
function endSpeech(state, key, actor, time) {
|
|
619
|
+
if (!state.open.delete(key)) return;
|
|
620
|
+
const stillSpeaking = [...state.open.values()].some((open) => open.actor === actor);
|
|
621
|
+
if (state.last?.actor === actor && !stillSpeaking) state.last.end = time;
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Derives floor transfers from speech and playback spans.
|
|
625
|
+
*
|
|
626
|
+
* A transfer from A to B happens when B starts to speak and the last speaker was A. Its offset is the speech start of
|
|
627
|
+
* B minus the speech end of A. For an agent, speech starts at its first played audio. A playback segment that follows
|
|
628
|
+
* another segment of the same agent is the same turn, so it is not a transfer.
|
|
629
|
+
* A start while A still speaks is an overlap. It is not a transfer, and the interruption metrics cover it.
|
|
630
|
+
*/
|
|
631
|
+
function createFloorTransferProjection() {
|
|
632
|
+
return {
|
|
633
|
+
key: "voice.floor-transfer",
|
|
634
|
+
reset: () => ({
|
|
635
|
+
open: /* @__PURE__ */ new Map(),
|
|
636
|
+
samples: {}
|
|
637
|
+
}),
|
|
638
|
+
handleRecord(state, record, context) {
|
|
639
|
+
if (record.type === "source.stopped" || record.type === "source.lost") {
|
|
640
|
+
const { source, epoch } = record.type === "source.lost" ? record.of : record;
|
|
641
|
+
for (const [key, open] of state.open) if (open.source === source && open.epoch === epoch) state.open.delete(key);
|
|
642
|
+
return state;
|
|
643
|
+
}
|
|
644
|
+
if (record.type !== "span.begin" && record.type !== "span.end" && record.type !== "span.complete") return state;
|
|
645
|
+
const actor = speakerOf(record.track);
|
|
646
|
+
if (!actor) return state;
|
|
647
|
+
const key = spanKeyOf(record.source, record.epoch, record.spanId);
|
|
648
|
+
if (record.type === "span.end") {
|
|
649
|
+
endSpeech(state, key, actor, context.time);
|
|
650
|
+
return state;
|
|
651
|
+
}
|
|
652
|
+
if (state.open.has(key)) return state;
|
|
653
|
+
beginSpeech(state, key, {
|
|
654
|
+
actor,
|
|
655
|
+
source: record.source,
|
|
656
|
+
epoch: record.epoch
|
|
657
|
+
}, context.time);
|
|
658
|
+
if (record.type === "span.complete") endSpeech(state, key, actor, context.time + record.durationMs);
|
|
659
|
+
return state;
|
|
660
|
+
},
|
|
661
|
+
evict(state, range) {
|
|
662
|
+
for (const [key, list] of Object.entries(state.samples)) state.samples[key] = list.filter((sample) => sample.time > range.to);
|
|
663
|
+
return state;
|
|
664
|
+
},
|
|
665
|
+
select: (state) => state.samples
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
//#endregion
|
|
669
|
+
export { VoiceAttributes, VoiceIdKeys, VoiceNames, VoiceSeries, VoiceTracks, createFloorTransferProjection, voiceProfile };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { _ as TraceIndexes, a as MetricSamples, b as TraceReader, c as TimelineMarker, d as TimelineSource, f as TimelineSpan, g as TraceApplyContext, h as TimelineTrack, i as MetricSample, l as TimelineProjectionOptions, m as TimelineStateChange, n as EventLogEntry, o as MetricSummary, p as TimelineState, r as EventLogState, s as TimelineInstant, t as AnyTraceProjection, u as TimelineSeries, v as TraceProjection, x as linkTargetKey, y as RecordIndex } from "../types-Fp54Yi6b.mjs";
|
|
2
|
+
import { a as summarizeMetric, i as createAttributeMetricsProjection, n as linksOfSpan, o as createEventLogProjection, r as provisionalFrom, t as createTimelineProjection } from "../index-DV04qeax.mjs";
|
|
3
|
+
export { AnyTraceProjection, EventLogEntry, EventLogState, MetricSample, MetricSamples, MetricSummary, RecordIndex, TimelineInstant, TimelineMarker, TimelineProjectionOptions, TimelineSeries, TimelineSource, TimelineSpan, TimelineState, TimelineStateChange, TimelineTrack, TraceApplyContext, TraceIndexes, TraceProjection, TraceReader, createAttributeMetricsProjection, createEventLogProjection, createTimelineProjection, linkTargetKey, linksOfSpan, provisionalFrom, summarizeMetric };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { i as RecordIndex, a as TraceReader, s as createAttributeMetricsProjection, l as createEventLogProjection, t as createTimelineProjection, o as linkTargetKey, n as linksOfSpan, r as provisionalFrom, c as summarizeMetric } from "../timeline-B4Vc6qQf.mjs";
|