@dxos/plugin-transcription 0.8.4-main.2e9d522 → 0.8.4-main.548089c
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/lib/browser/TranscriptContainer-EKSP5DQ6.mjs +11 -0
- package/dist/lib/browser/blueprint-definition-WBWHO4OH.mjs +150 -0
- package/dist/lib/browser/blueprint-definition-WBWHO4OH.mjs.map +7 -0
- package/dist/lib/browser/{chunk-U6QBOGTN.mjs → chunk-3MKZ2MNQ.mjs} +5 -5
- package/dist/lib/browser/chunk-3MKZ2MNQ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5KPYIC3N.mjs → chunk-EHT3TE6U.mjs} +341 -366
- package/dist/lib/browser/chunk-EHT3TE6U.mjs.map +7 -0
- package/dist/lib/browser/{chunk-4FJIYH7T.mjs → chunk-OCI42DWB.mjs} +2 -2
- package/dist/lib/browser/{chunk-FFEPEPCU.mjs → chunk-PVU4XCKI.mjs} +51 -80
- package/dist/lib/browser/chunk-PVU4XCKI.mjs.map +7 -0
- package/dist/lib/browser/chunk-VBUIO677.mjs +29 -0
- package/dist/lib/browser/chunk-VBUIO677.mjs.map +7 -0
- package/dist/lib/browser/chunk-W7WKZTM4.mjs +63 -0
- package/dist/lib/browser/chunk-W7WKZTM4.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +25 -20
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-ZTKTEAQX.mjs +25 -0
- package/dist/lib/browser/intent-resolver-ZTKTEAQX.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-E5D5AE3F.mjs → react-surface-NARMYO2O.mjs} +10 -10
- package/dist/lib/browser/react-surface-NARMYO2O.mjs.map +7 -0
- package/dist/lib/browser/{transcriber-PXT4QBFY.mjs → transcriber-E2KAOXPS.mjs} +7 -7
- package/dist/lib/browser/transcriber-E2KAOXPS.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +6 -8
- package/dist/lib/node-esm/{TranscriptContainer-VBAOM5DG.mjs → TranscriptContainer-WU3EDQR3.mjs} +4 -4
- package/dist/lib/node-esm/blueprint-definition-WUHZFRWZ.mjs +151 -0
- package/dist/lib/node-esm/blueprint-definition-WUHZFRWZ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-TJKAO7VR.mjs → chunk-7XASA7DX.mjs} +341 -366
- package/dist/lib/node-esm/chunk-7XASA7DX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-OLMSTF3M.mjs +64 -0
- package/dist/lib/node-esm/chunk-OLMSTF3M.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-RHF2ALML.mjs → chunk-SWUVPFKR.mjs} +5 -5
- package/dist/lib/node-esm/chunk-SWUVPFKR.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HT3W7LDP.mjs → chunk-UVOYXXDJ.mjs} +51 -80
- package/dist/lib/node-esm/chunk-UVOYXXDJ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-Y2B4HWSS.mjs → chunk-X5BKN32O.mjs} +2 -2
- package/dist/lib/node-esm/chunk-YVNQN2J6.mjs +30 -0
- package/dist/lib/node-esm/chunk-YVNQN2J6.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +25 -20
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-55WH2GY6.mjs +26 -0
- package/dist/lib/node-esm/intent-resolver-55WH2GY6.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-QRDJOHN5.mjs → react-surface-5MQA3IUS.mjs} +10 -10
- package/dist/lib/node-esm/react-surface-5MQA3IUS.mjs.map +7 -0
- package/dist/lib/node-esm/{transcriber-YUTEVANE.mjs → transcriber-ZPJM4U2W.mjs} +7 -7
- package/dist/lib/node-esm/transcriber-ZPJM4U2W.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +6 -8
- package/dist/types/src/TranscriptionPlugin.d.ts +1 -1
- package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +3 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/transcriber.d.ts +1 -1
- package/dist/types/src/capabilities/transcriber.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/Transcript.d.ts +7 -7
- package/dist/types/src/components/Transcript/Transcript.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts +33 -18
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts +3 -3
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/transcript-extension.d.ts +3 -7
- package/dist/types/src/components/Transcript/transcript-extension.d.ts.map +1 -1
- package/dist/types/src/components/TranscriptContainer.d.ts +2 -2
- package/dist/types/src/components/TranscriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts +5 -4
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts +10 -6
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts +7 -6
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/TranscriptionStory.d.ts +4 -3
- package/dist/types/src/components/stories/TranscriptionStory.d.ts.map +1 -1
- package/dist/types/src/functions/index.d.ts +3 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/open.d.ts +7 -0
- package/dist/types/src/functions/open.d.ts.map +1 -0
- package/dist/types/src/functions/summarize.d.ts +11 -0
- package/dist/types/src/functions/summarize.d.ts.map +1 -0
- package/dist/types/src/hooks/useAudioFile.d.ts.map +1 -1
- package/dist/types/src/hooks/useTranscriber.d.ts.map +1 -1
- package/dist/types/src/hooks/useVoiceInput.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/message-normalizer.d.ts +3 -3
- package/dist/types/src/segments-normalization/message-normalizer.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/normalization.d.ts +388 -328
- package/dist/types/src/segments-normalization/normalization.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/utils.d.ts +2 -2
- package/dist/types/src/segments-normalization/utils.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +7 -7
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/transcriber/media-stream-recorder.d.ts +1 -1
- package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.d.ts +2 -2
- package/dist/types/src/transcriber/transcriber.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcription-manager.d.ts +6 -10
- package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
- package/dist/types/src/types/Transcript.d.ts +30 -0
- package/dist/types/src/types/Transcript.d.ts.map +1 -0
- package/dist/types/src/types/TranscriptAction.d.ts +23 -0
- package/dist/types/src/types/TranscriptAction.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +0 -26
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +66 -63
- package/src/TranscriptionPlugin.tsx +59 -54
- package/src/capabilities/blueprint-definition.ts +31 -0
- package/src/capabilities/capabilities.ts +6 -6
- package/src/capabilities/index.ts +1 -0
- package/src/capabilities/intent-resolver.ts +5 -11
- package/src/capabilities/react-surface.tsx +2 -2
- package/src/capabilities/transcriber.ts +3 -2
- package/src/components/Transcript/Transcript.stories.tsx +37 -34
- package/src/components/Transcript/Transcript.tsx +25 -31
- package/src/components/Transcript/deprecated/OldTranscript.tsx +9 -9
- package/src/components/Transcript/transcript-extension.ts +11 -44
- package/src/components/TranscriptContainer.tsx +12 -10
- package/src/components/stories/FileTranscription.stories.tsx +54 -42
- package/src/components/stories/KeyWordRecognition.stories.tsx +15 -11
- package/src/components/stories/MicrophoneTranscription.stories.tsx +49 -45
- package/src/components/stories/TranscriptionStory.tsx +12 -8
- package/src/functions/index.ts +6 -0
- package/src/functions/open.ts +39 -0
- package/src/functions/summarize.ts +103 -0
- package/src/hooks/useAudioFile.ts +49 -53
- package/src/hooks/useTranscriber.ts +7 -2
- package/src/hooks/useVoiceInput.ts +3 -2
- package/src/meta.ts +7 -4
- package/src/model/model.test.ts +12 -12
- package/src/segments-normalization/message-normalizer.ts +7 -7
- package/src/segments-normalization/normalization.test.ts +10 -10
- package/src/segments-normalization/normalization.ts +43 -42
- package/src/segments-normalization/utils.ts +2 -2
- package/src/testing/testing.ts +27 -22
- package/src/transcriber/media-stream-recorder.ts +1 -1
- package/src/transcriber/transcriber.browser.test.ts +5 -4
- package/src/transcriber/transcriber.ts +5 -4
- package/src/transcriber/transcription-manager.ts +23 -44
- package/src/types/{schema.ts → Transcript.ts} +12 -9
- package/src/types/TranscriptAction.ts +24 -0
- package/src/types/index.ts +2 -1
- package/src/types/types.ts +0 -23
- package/dist/lib/browser/TranscriptContainer-6WCKCXQ6.mjs +0 -11
- package/dist/lib/browser/chunk-5KPYIC3N.mjs.map +0 -7
- package/dist/lib/browser/chunk-5WH45KBY.mjs +0 -19
- package/dist/lib/browser/chunk-5WH45KBY.mjs.map +0 -7
- package/dist/lib/browser/chunk-FFEPEPCU.mjs.map +0 -7
- package/dist/lib/browser/chunk-R7INNNUQ.mjs +0 -55
- package/dist/lib/browser/chunk-R7INNNUQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-U6QBOGTN.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-3O33MMP5.mjs +0 -30
- package/dist/lib/browser/intent-resolver-3O33MMP5.mjs.map +0 -7
- package/dist/lib/browser/react-surface-E5D5AE3F.mjs.map +0 -7
- package/dist/lib/browser/transcriber-PXT4QBFY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HT3W7LDP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RHF2ALML.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TJKAO7VR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-U65ZWK3L.mjs +0 -56
- package/dist/lib/node-esm/chunk-U65ZWK3L.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XMUCZBP3.mjs +0 -21
- package/dist/lib/node-esm/chunk-XMUCZBP3.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-YMN5SXNC.mjs +0 -31
- package/dist/lib/node-esm/intent-resolver-YMN5SXNC.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-QRDJOHN5.mjs.map +0 -7
- package/dist/lib/node-esm/transcriber-YUTEVANE.mjs.map +0 -7
- package/dist/types/src/types/schema.d.ts +0 -41
- package/dist/types/src/types/schema.d.ts.map +0 -1
- /package/dist/lib/browser/{TranscriptContainer-6WCKCXQ6.mjs.map → TranscriptContainer-EKSP5DQ6.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-4FJIYH7T.mjs.map → chunk-OCI42DWB.mjs.map} +0 -0
- /package/dist/lib/node-esm/{TranscriptContainer-VBAOM5DG.mjs.map → TranscriptContainer-WU3EDQR3.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-Y2B4HWSS.mjs.map → chunk-X5BKN32O.mjs.map} +0 -0
|
@@ -1,37 +1,144 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
TranscriptionCapabilities
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-SWUVPFKR.mjs";
|
|
5
5
|
|
|
6
6
|
// src/components/TranscriptContainer.tsx
|
|
7
7
|
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
8
8
|
import React2 from "react";
|
|
9
|
-
import {
|
|
9
|
+
import { getSpace } from "@dxos/client/echo";
|
|
10
|
+
import { Obj } from "@dxos/echo";
|
|
10
11
|
import { useMembers, useQueue } from "@dxos/react-client/echo";
|
|
11
12
|
import { StackItem } from "@dxos/react-ui-stack";
|
|
12
13
|
|
|
13
|
-
// src/
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
// src/hooks/useAudioFile.ts
|
|
15
|
+
import { useEffect, useState } from "react";
|
|
16
|
+
import { scheduleTask } from "@dxos/async";
|
|
17
|
+
import { Context } from "@dxos/context";
|
|
18
|
+
import { log } from "@dxos/log";
|
|
19
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/hooks/useAudioFile.ts";
|
|
20
|
+
var useAudioFile = (audioUrl, constraints) => {
|
|
21
|
+
const [{ audio, stream, track }, setStream] = useState({});
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const ctx = new Context(void 0, {
|
|
24
|
+
F: __dxlog_file,
|
|
25
|
+
L: 20
|
|
26
|
+
});
|
|
27
|
+
scheduleTask(ctx, async () => {
|
|
28
|
+
try {
|
|
29
|
+
const response = await fetch(audioUrl);
|
|
30
|
+
const blob = await response.blob();
|
|
31
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
32
|
+
ctx.onDispose(() => {
|
|
33
|
+
URL.revokeObjectURL(objectUrl);
|
|
34
|
+
});
|
|
35
|
+
const audio2 = new Audio();
|
|
36
|
+
audio2.src = objectUrl;
|
|
37
|
+
await new Promise((resolve, reject) => {
|
|
38
|
+
audio2.addEventListener("error", (err) => {
|
|
39
|
+
log.error("error", {
|
|
40
|
+
err
|
|
41
|
+
}, {
|
|
42
|
+
F: __dxlog_file,
|
|
43
|
+
L: 39,
|
|
44
|
+
S: void 0,
|
|
45
|
+
C: (f, a) => f(...a)
|
|
46
|
+
});
|
|
47
|
+
reject(err);
|
|
48
|
+
}, {
|
|
49
|
+
once: true
|
|
50
|
+
});
|
|
51
|
+
audio2.addEventListener("canplay", async () => {
|
|
52
|
+
resolve();
|
|
53
|
+
}, {
|
|
54
|
+
once: true
|
|
55
|
+
});
|
|
56
|
+
audio2.load();
|
|
57
|
+
});
|
|
58
|
+
const audioCtx = new AudioContext();
|
|
59
|
+
if (audioCtx.state === "suspended") {
|
|
60
|
+
await audioCtx.resume();
|
|
61
|
+
}
|
|
62
|
+
const destination = audioCtx.createMediaStreamDestination();
|
|
63
|
+
destination.channelCount = 1;
|
|
64
|
+
const source = audioCtx.createMediaElementSource(audio2);
|
|
65
|
+
source.connect(destination);
|
|
66
|
+
const track2 = destination.stream.getAudioTracks()[0];
|
|
67
|
+
if (constraints) {
|
|
68
|
+
await track2.applyConstraints(constraints).catch((err) => log.catch(err, void 0, {
|
|
69
|
+
F: __dxlog_file,
|
|
70
|
+
L: 68,
|
|
71
|
+
S: void 0,
|
|
72
|
+
C: (f, a) => f(...a)
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
setStream({
|
|
76
|
+
audio: audio2,
|
|
77
|
+
stream: destination.stream,
|
|
78
|
+
track: destination.stream.getAudioTracks()[0]
|
|
79
|
+
});
|
|
80
|
+
} catch (err) {
|
|
81
|
+
log.catch(err, void 0, {
|
|
82
|
+
F: __dxlog_file,
|
|
83
|
+
L: 78,
|
|
84
|
+
S: void 0,
|
|
85
|
+
C: (f, a) => f(...a)
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return () => {
|
|
90
|
+
void ctx.dispose();
|
|
91
|
+
};
|
|
92
|
+
}, [
|
|
93
|
+
audioUrl
|
|
94
|
+
]);
|
|
95
|
+
return {
|
|
96
|
+
audio,
|
|
97
|
+
stream,
|
|
98
|
+
track
|
|
99
|
+
};
|
|
100
|
+
};
|
|
20
101
|
|
|
21
|
-
// src/
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
102
|
+
// src/hooks/useAudioTrack.ts
|
|
103
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
104
|
+
var useAudioTrack = (active, constraints) => {
|
|
105
|
+
const [track, setTrack] = useState2();
|
|
106
|
+
useEffect2(() => {
|
|
107
|
+
if (!active) {
|
|
108
|
+
track?.stop();
|
|
109
|
+
setTrack(void 0);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const initAudio = async () => {
|
|
113
|
+
const audio = new Audio();
|
|
114
|
+
audio.srcObject = await navigator.mediaDevices.getUserMedia({
|
|
115
|
+
audio: constraints ?? true
|
|
116
|
+
});
|
|
117
|
+
const [track2] = audio.srcObject.getAudioTracks();
|
|
118
|
+
if (track2) {
|
|
119
|
+
setTrack(track2);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
if (active) {
|
|
123
|
+
void initAudio();
|
|
124
|
+
}
|
|
125
|
+
}, [
|
|
126
|
+
active
|
|
127
|
+
]);
|
|
128
|
+
return track;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// src/hooks/useQueueModelAdapter.ts
|
|
132
|
+
import { useEffect as useEffect3, useMemo, useState as useState3 } from "react";
|
|
27
133
|
|
|
28
134
|
// src/model/model.ts
|
|
29
135
|
import { Text } from "@codemirror/state";
|
|
30
136
|
import { Event } from "@dxos/async";
|
|
31
137
|
import { invariant } from "@dxos/invariant";
|
|
32
|
-
import { log } from "@dxos/log";
|
|
33
|
-
var
|
|
138
|
+
import { log as log2 } from "@dxos/log";
|
|
139
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/model/model.ts";
|
|
34
140
|
var DocumentAdapter = class {
|
|
141
|
+
_view;
|
|
35
142
|
constructor(_view) {
|
|
36
143
|
this._view = _view;
|
|
37
144
|
}
|
|
@@ -40,13 +147,13 @@ var DocumentAdapter = class {
|
|
|
40
147
|
return this._view.state.doc.lines - 1;
|
|
41
148
|
}
|
|
42
149
|
replaceLines(from, remove, insert) {
|
|
43
|
-
|
|
150
|
+
log2("replaceLines", {
|
|
44
151
|
count: this._view.state.doc.lines,
|
|
45
152
|
from,
|
|
46
153
|
remove,
|
|
47
154
|
insert
|
|
48
155
|
}, {
|
|
49
|
-
F:
|
|
156
|
+
F: __dxlog_file2,
|
|
50
157
|
L: 39,
|
|
51
158
|
S: this,
|
|
52
159
|
C: (f, a) => f(...a)
|
|
@@ -68,13 +175,19 @@ var DocumentAdapter = class {
|
|
|
68
175
|
}
|
|
69
176
|
};
|
|
70
177
|
var SerializationModel = class {
|
|
178
|
+
_renderer;
|
|
179
|
+
/** Ordered set of chunks. */
|
|
180
|
+
_chunks = [];
|
|
181
|
+
/** Map of chunk IDs to their current line counts. */
|
|
182
|
+
_chunkLineCounts = /* @__PURE__ */ new Map();
|
|
183
|
+
/** Map of line numbers to chunk IDs. */
|
|
184
|
+
_lineToChunk = /* @__PURE__ */ new Map();
|
|
185
|
+
/** Track chunk changes since last sync. */
|
|
186
|
+
_changes = [];
|
|
187
|
+
/** Emits when the document is updated. */
|
|
188
|
+
update = new Event();
|
|
71
189
|
constructor(_renderer, initialChunks = []) {
|
|
72
190
|
this._renderer = _renderer;
|
|
73
|
-
this._chunks = [];
|
|
74
|
-
this._chunkLineCounts = /* @__PURE__ */ new Map();
|
|
75
|
-
this._lineToChunk = /* @__PURE__ */ new Map();
|
|
76
|
-
this._changes = [];
|
|
77
|
-
this.update = new Event();
|
|
78
191
|
initialChunks.forEach((chunk) => {
|
|
79
192
|
this.appendChunk(chunk);
|
|
80
193
|
});
|
|
@@ -121,7 +234,7 @@ var SerializationModel = class {
|
|
|
121
234
|
updateChunk(chunk) {
|
|
122
235
|
const index = this._chunks.findIndex((c) => c.id === chunk.id);
|
|
123
236
|
invariant(index !== -1, void 0, {
|
|
124
|
-
F:
|
|
237
|
+
F: __dxlog_file2,
|
|
125
238
|
L: 147,
|
|
126
239
|
S: this,
|
|
127
240
|
A: [
|
|
@@ -141,7 +254,7 @@ var SerializationModel = class {
|
|
|
141
254
|
deleteBlock(id) {
|
|
142
255
|
const index = this._chunks.findIndex((c) => c.id === id);
|
|
143
256
|
invariant(index !== -1, void 0, {
|
|
144
|
-
F:
|
|
257
|
+
F: __dxlog_file2,
|
|
145
258
|
L: 156,
|
|
146
259
|
S: this,
|
|
147
260
|
A: [
|
|
@@ -162,10 +275,10 @@ var SerializationModel = class {
|
|
|
162
275
|
* Syncs the tracked changes with the ChunkDocument.
|
|
163
276
|
*/
|
|
164
277
|
sync(document2) {
|
|
165
|
-
|
|
278
|
+
log2("sync", {
|
|
166
279
|
changes: this._changes
|
|
167
280
|
}, {
|
|
168
|
-
F:
|
|
281
|
+
F: __dxlog_file2,
|
|
169
282
|
L: 167,
|
|
170
283
|
S: this,
|
|
171
284
|
C: (f, a) => f(...a)
|
|
@@ -218,8 +331,172 @@ var SerializationModel = class {
|
|
|
218
331
|
}
|
|
219
332
|
};
|
|
220
333
|
|
|
334
|
+
// src/hooks/useQueueModelAdapter.ts
|
|
335
|
+
var useQueueModelAdapter = (renderer, queue, initialChunks = []) => {
|
|
336
|
+
const model = useMemo(() => new SerializationModel(renderer, initialChunks), [
|
|
337
|
+
queue
|
|
338
|
+
]);
|
|
339
|
+
const [loaded, setLoaded] = useState3(false);
|
|
340
|
+
useEffect3(() => {
|
|
341
|
+
if (!queue) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const update = () => {
|
|
345
|
+
for (const block of queue?.objects ?? []) {
|
|
346
|
+
model.appendChunk(block);
|
|
347
|
+
}
|
|
348
|
+
setLoaded(true);
|
|
349
|
+
};
|
|
350
|
+
let i;
|
|
351
|
+
if (queue.isLoading) {
|
|
352
|
+
i = setInterval(() => {
|
|
353
|
+
if (!queue?.isLoading) {
|
|
354
|
+
clearInterval(i);
|
|
355
|
+
update();
|
|
356
|
+
}
|
|
357
|
+
}, 1e3);
|
|
358
|
+
} else {
|
|
359
|
+
update();
|
|
360
|
+
}
|
|
361
|
+
return () => clearTimeout(i);
|
|
362
|
+
}, [
|
|
363
|
+
model,
|
|
364
|
+
queue
|
|
365
|
+
]);
|
|
366
|
+
useEffect3(() => {
|
|
367
|
+
if (!loaded || !queue || model.chunks.length === queue.objects.length) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
const chunk = queue.objects.at(-1);
|
|
371
|
+
if (chunk) {
|
|
372
|
+
model.appendChunk(chunk);
|
|
373
|
+
}
|
|
374
|
+
}, [
|
|
375
|
+
model,
|
|
376
|
+
loaded,
|
|
377
|
+
queue?.objects.length
|
|
378
|
+
]);
|
|
379
|
+
return model;
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
// src/hooks/useTranscriber.ts
|
|
383
|
+
import { useEffect as useEffect4, useMemo as useMemo2 } from "react";
|
|
384
|
+
import { useCapabilities } from "@dxos/app-framework/react";
|
|
385
|
+
|
|
386
|
+
// src/capabilities/index.ts
|
|
387
|
+
import { lazy } from "@dxos/app-framework";
|
|
388
|
+
var BlueprintDefinition = lazy(() => import("./blueprint-definition-WUHZFRWZ.mjs"));
|
|
389
|
+
var IntentResolver = lazy(() => import("./intent-resolver-55WH2GY6.mjs"));
|
|
390
|
+
var ReactSurface = lazy(() => import("./react-surface-5MQA3IUS.mjs"));
|
|
391
|
+
var Transcriber = lazy(() => import("./transcriber-ZPJM4U2W.mjs"));
|
|
392
|
+
|
|
393
|
+
// src/hooks/useTranscriber.ts
|
|
394
|
+
var useTranscriber = ({ audioStreamTrack, recorderConfig, transcriberConfig, onSegments }) => {
|
|
395
|
+
const [getTranscriber] = useCapabilities(TranscriptionCapabilities.Transcriber);
|
|
396
|
+
const transcriber = useMemo2(() => {
|
|
397
|
+
if (!getTranscriber || !audioStreamTrack || !onSegments) {
|
|
398
|
+
return void 0;
|
|
399
|
+
}
|
|
400
|
+
return getTranscriber({
|
|
401
|
+
audioStreamTrack,
|
|
402
|
+
recorderConfig,
|
|
403
|
+
transcriberConfig,
|
|
404
|
+
onSegments
|
|
405
|
+
});
|
|
406
|
+
}, [
|
|
407
|
+
getTranscriber,
|
|
408
|
+
audioStreamTrack,
|
|
409
|
+
recorderConfig,
|
|
410
|
+
transcriberConfig,
|
|
411
|
+
onSegments
|
|
412
|
+
]);
|
|
413
|
+
useEffect4(() => {
|
|
414
|
+
return () => {
|
|
415
|
+
void transcriber?.close();
|
|
416
|
+
};
|
|
417
|
+
}, [
|
|
418
|
+
transcriber
|
|
419
|
+
]);
|
|
420
|
+
return transcriber;
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
// src/hooks/useVoiceInput.ts
|
|
424
|
+
import { useCallback, useEffect as useEffect5, useState as useState4 } from "react";
|
|
425
|
+
import { scheduleMicroTask } from "@dxos/async";
|
|
426
|
+
import { Context as Context2 } from "@dxos/context";
|
|
427
|
+
import { log as log3 } from "@dxos/log";
|
|
428
|
+
import { useSoundEffect } from "@dxos/react-ui-sfx";
|
|
429
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/hooks/useVoiceInput.ts";
|
|
430
|
+
var useVoiceInput = ({ active, onUpdate }) => {
|
|
431
|
+
const soundStart = useSoundEffect("StartRecording");
|
|
432
|
+
const soundStop = useSoundEffect("StopRecording");
|
|
433
|
+
const handleSegments = useCallback(async (segments) => {
|
|
434
|
+
const text = segments.map((str) => str.text.trim().replace(/[^\w\s]/g, "")).join(" ");
|
|
435
|
+
onUpdate(text);
|
|
436
|
+
}, []);
|
|
437
|
+
const [recording, setRecording] = useState4(false);
|
|
438
|
+
const track = useAudioTrack(active);
|
|
439
|
+
const transcriber = useTranscriber({
|
|
440
|
+
audioStreamTrack: track,
|
|
441
|
+
onSegments: handleSegments
|
|
442
|
+
});
|
|
443
|
+
useEffect5(() => {
|
|
444
|
+
const ctx = new Context2(void 0, {
|
|
445
|
+
F: __dxlog_file3,
|
|
446
|
+
L: 44
|
|
447
|
+
});
|
|
448
|
+
scheduleMicroTask(ctx, async () => {
|
|
449
|
+
if (active && transcriber) {
|
|
450
|
+
await transcriber.open();
|
|
451
|
+
log3.info("starting...", void 0, {
|
|
452
|
+
F: __dxlog_file3,
|
|
453
|
+
L: 48,
|
|
454
|
+
S: void 0,
|
|
455
|
+
C: (f, a) => f(...a)
|
|
456
|
+
});
|
|
457
|
+
setRecording(true);
|
|
458
|
+
void soundStart.play();
|
|
459
|
+
transcriber.startChunksRecording();
|
|
460
|
+
} else if (!active && transcriber?.isOpen) {
|
|
461
|
+
transcriber?.stopChunksRecording();
|
|
462
|
+
await transcriber?.close();
|
|
463
|
+
log3.info("stopped", void 0, {
|
|
464
|
+
F: __dxlog_file3,
|
|
465
|
+
L: 55,
|
|
466
|
+
S: void 0,
|
|
467
|
+
C: (f, a) => f(...a)
|
|
468
|
+
});
|
|
469
|
+
setRecording(false);
|
|
470
|
+
void soundStop.play();
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
return () => {
|
|
474
|
+
void ctx.dispose();
|
|
475
|
+
};
|
|
476
|
+
}, [
|
|
477
|
+
active,
|
|
478
|
+
transcriber
|
|
479
|
+
]);
|
|
480
|
+
return {
|
|
481
|
+
recording
|
|
482
|
+
};
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
// src/components/Transcript/Transcript.tsx
|
|
486
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
487
|
+
import React from "react";
|
|
488
|
+
import { useThemeContext } from "@dxos/react-ui";
|
|
489
|
+
import { autoScroll, createBasicExtensions, createMarkdownExtensions, createThemeExtensions, decorateMarkdown, editorSlots, preview, useTextEditor } from "@dxos/react-ui-editor";
|
|
490
|
+
import { mx } from "@dxos/react-ui-theme";
|
|
491
|
+
import { isTruthy } from "@dxos/util";
|
|
492
|
+
|
|
221
493
|
// src/components/Transcript/transcript-extension.ts
|
|
222
|
-
|
|
494
|
+
import { RangeSetBuilder } from "@codemirror/state";
|
|
495
|
+
import { EditorView, GutterMarker, ViewPlugin, gutter } from "@codemirror/view";
|
|
496
|
+
import { format } from "date-fns/format";
|
|
497
|
+
import { intervalToDuration } from "date-fns/intervalToDuration";
|
|
498
|
+
import { addEventListener, combine } from "@dxos/async";
|
|
499
|
+
var transcript = ({ model, started }) => {
|
|
223
500
|
return [
|
|
224
501
|
// Show timestamps in the gutter.
|
|
225
502
|
gutter({
|
|
@@ -247,8 +524,11 @@ var transcript = ({ model, started, renderButton }) => {
|
|
|
247
524
|
}),
|
|
248
525
|
// Listen for model updates.
|
|
249
526
|
ViewPlugin.fromClass(class {
|
|
527
|
+
_controls;
|
|
528
|
+
_cleanup;
|
|
529
|
+
_adapter;
|
|
530
|
+
_initialized = false;
|
|
250
531
|
constructor(view) {
|
|
251
|
-
this._initialized = false;
|
|
252
532
|
this._adapter = new DocumentAdapter(view);
|
|
253
533
|
const scroller = view.scrollDOM;
|
|
254
534
|
let isAutoScrolling = false;
|
|
@@ -270,30 +550,20 @@ var transcript = ({ model, started, renderButton }) => {
|
|
|
270
550
|
})
|
|
271
551
|
});
|
|
272
552
|
};
|
|
273
|
-
if (renderButton) {
|
|
274
|
-
this._controls = document.createElement("div");
|
|
275
|
-
this._controls.classList.add("cm-controls", "transition-opacity", "duration-300", "opacity-0");
|
|
276
|
-
view.dom.appendChild(this._controls);
|
|
277
|
-
renderButton(this._controls, {
|
|
278
|
-
onClick: () => {
|
|
279
|
-
scrollToBottom(false);
|
|
280
|
-
}
|
|
281
|
-
}, view);
|
|
282
|
-
}
|
|
283
553
|
this._cleanup = combine(addEventListener(view.scrollDOM, "scroll", () => {
|
|
284
554
|
if (!isAutoScrolling) {
|
|
285
555
|
hasScrolled = true;
|
|
286
556
|
this._controls?.classList.remove("opacity-0");
|
|
287
557
|
}
|
|
288
558
|
}), model.update.on(() => {
|
|
289
|
-
const
|
|
559
|
+
const autoScroll2 = scroller.scrollHeight - scroller.scrollTop - scroller.clientHeight === 0 || !hasScrolled;
|
|
290
560
|
model.sync(this._adapter);
|
|
291
|
-
if (
|
|
561
|
+
if (autoScroll2) {
|
|
292
562
|
scrollToBottom(true);
|
|
293
563
|
}
|
|
294
564
|
}));
|
|
295
565
|
}
|
|
296
|
-
update(
|
|
566
|
+
update(_update) {
|
|
297
567
|
if (!this._initialized) {
|
|
298
568
|
this._initialized = true;
|
|
299
569
|
setTimeout(() => {
|
|
@@ -307,27 +577,12 @@ var transcript = ({ model, started, renderButton }) => {
|
|
|
307
577
|
}
|
|
308
578
|
}),
|
|
309
579
|
EditorView.theme({
|
|
310
|
-
".cm-
|
|
311
|
-
|
|
312
|
-
},
|
|
313
|
-
".cm-hide-scrollbar": {
|
|
314
|
-
scrollbarWidth: "none",
|
|
315
|
-
"-ms-overflow-style": "none"
|
|
316
|
-
},
|
|
317
|
-
".cm-hide-scrollbar::-webkit-scrollbar": {
|
|
318
|
-
display: "none"
|
|
319
|
-
},
|
|
320
|
-
".cm-controls": {
|
|
321
|
-
position: "absolute",
|
|
322
|
-
bottom: "0.5rem",
|
|
323
|
-
right: "0.5rem",
|
|
324
|
-
zIndex: 1e3
|
|
325
|
-
},
|
|
326
|
-
".cm-line": {
|
|
327
|
-
paddingRight: "1rem"
|
|
580
|
+
".cm-gutters": {
|
|
581
|
+
backgroundColor: "var(--dx-baseSurface)"
|
|
328
582
|
},
|
|
329
583
|
".cm-timestamp-gutter": {
|
|
330
584
|
width: "6rem",
|
|
585
|
+
paddingLeft: "0.5rem",
|
|
331
586
|
paddingRight: "1rem"
|
|
332
587
|
},
|
|
333
588
|
".cm-timestamp-gutter > .cm-gutterElement > div": {
|
|
@@ -339,11 +594,14 @@ var transcript = ({ model, started, renderButton }) => {
|
|
|
339
594
|
];
|
|
340
595
|
};
|
|
341
596
|
var TimestampMarker = class extends GutterMarker {
|
|
597
|
+
_line;
|
|
598
|
+
_timestamp;
|
|
599
|
+
_started;
|
|
342
600
|
constructor(_line, _timestamp, _started) {
|
|
343
601
|
super(), this._line = _line, this._timestamp = _timestamp, this._started = _started;
|
|
344
602
|
}
|
|
345
603
|
eq(other) {
|
|
346
|
-
return
|
|
604
|
+
return this._timestamp === other._timestamp;
|
|
347
605
|
}
|
|
348
606
|
toDOM(view) {
|
|
349
607
|
const el = document.createElement("div");
|
|
@@ -383,7 +641,7 @@ var formatTimestamp = (timestamp, relative) => {
|
|
|
383
641
|
};
|
|
384
642
|
|
|
385
643
|
// src/components/Transcript/Transcript.tsx
|
|
386
|
-
var
|
|
644
|
+
var renderByline = (identities) => (message, index, debug = false) => {
|
|
387
645
|
if (message.sender.role === "assistant") {
|
|
388
646
|
return [
|
|
389
647
|
message.blocks.find((block) => block._tag === "transcript")?.text ?? "",
|
|
@@ -394,12 +652,13 @@ var renderMarkdown = (identities) => (message, index, debug = false) => {
|
|
|
394
652
|
const name = identity?.profile?.displayName ?? message.sender.contact?.target?.fullName ?? message.sender.name ?? message.sender.email ?? message.sender.identityDid;
|
|
395
653
|
const blocks = message.blocks.filter((block) => block._tag === "transcript");
|
|
396
654
|
return [
|
|
655
|
+
// TODO(thure): Use an XML tag with the bits needed here.
|
|
397
656
|
`###### ${name}` + (debug ? ` [${index}]:${message.id}` : ""),
|
|
398
657
|
blocks.map((block) => block.text.trim()).join(" "),
|
|
399
658
|
""
|
|
400
659
|
];
|
|
401
660
|
};
|
|
402
|
-
var
|
|
661
|
+
var TranscriptView = ({ classNames, space, transcript: object, model }) => {
|
|
403
662
|
var _effect = _useSignals();
|
|
404
663
|
try {
|
|
405
664
|
const { themeMode } = useThemeContext();
|
|
@@ -408,27 +667,22 @@ var Transcript = ({ classNames, transcript: object, space, model, attendableId,
|
|
|
408
667
|
extensions: [
|
|
409
668
|
createBasicExtensions({
|
|
410
669
|
readOnly: true,
|
|
411
|
-
lineWrapping: true
|
|
412
|
-
|
|
413
|
-
createMarkdownExtensions({
|
|
414
|
-
themeMode
|
|
670
|
+
lineWrapping: true,
|
|
671
|
+
search: true
|
|
415
672
|
}),
|
|
673
|
+
createMarkdownExtensions(),
|
|
416
674
|
createThemeExtensions({
|
|
417
|
-
themeMode
|
|
675
|
+
themeMode,
|
|
676
|
+
slots: editorSlots
|
|
418
677
|
}),
|
|
419
678
|
decorateMarkdown(),
|
|
420
|
-
|
|
679
|
+
preview(),
|
|
421
680
|
transcript({
|
|
422
681
|
model,
|
|
423
|
-
started: object?.started ? new Date(object.started) : void 0
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
label: "Scroll to bottom",
|
|
428
|
-
onClick
|
|
429
|
-
}))
|
|
430
|
-
})
|
|
431
|
-
].filter(isNotFalsy)
|
|
682
|
+
started: object?.started ? new Date(object.started) : void 0
|
|
683
|
+
}),
|
|
684
|
+
autoScroll()
|
|
685
|
+
].filter(isTruthy)
|
|
432
686
|
};
|
|
433
687
|
}, [
|
|
434
688
|
space,
|
|
@@ -436,7 +690,7 @@ var Transcript = ({ classNames, transcript: object, space, model, attendableId,
|
|
|
436
690
|
]);
|
|
437
691
|
return /* @__PURE__ */ React.createElement("div", {
|
|
438
692
|
ref: parentRef,
|
|
439
|
-
className: mx("flex grow overflow-hidden",
|
|
693
|
+
className: mx("flex grow overflow-hidden container-max-width", classNames),
|
|
440
694
|
"data-popover-collision-boundary": true
|
|
441
695
|
});
|
|
442
696
|
} finally {
|
|
@@ -444,298 +698,18 @@ var Transcript = ({ classNames, transcript: object, space, model, attendableId,
|
|
|
444
698
|
}
|
|
445
699
|
};
|
|
446
700
|
|
|
447
|
-
// src/hooks/useAudioFile.ts
|
|
448
|
-
import { useEffect, useState } from "react";
|
|
449
|
-
import { scheduleTask } from "@dxos/async";
|
|
450
|
-
import { Context } from "@dxos/context";
|
|
451
|
-
import { log as log2 } from "@dxos/log";
|
|
452
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/hooks/useAudioFile.ts";
|
|
453
|
-
var useAudioFile = (audioUrl, constraints) => {
|
|
454
|
-
const [{ audio, stream, track }, setStream] = useState({});
|
|
455
|
-
useEffect(() => {
|
|
456
|
-
const ctx = new Context(void 0, {
|
|
457
|
-
F: __dxlog_file2,
|
|
458
|
-
L: 20
|
|
459
|
-
});
|
|
460
|
-
scheduleTask(ctx, async () => {
|
|
461
|
-
const response = await fetch(audioUrl);
|
|
462
|
-
const blob = await response.blob();
|
|
463
|
-
const objectUrl = URL.createObjectURL(blob);
|
|
464
|
-
ctx.onDispose(() => {
|
|
465
|
-
URL.revokeObjectURL(objectUrl);
|
|
466
|
-
});
|
|
467
|
-
const audio2 = new Audio();
|
|
468
|
-
audio2.src = objectUrl;
|
|
469
|
-
await new Promise((resolve, reject) => {
|
|
470
|
-
audio2.addEventListener("error", (err) => {
|
|
471
|
-
log2.error("error", {
|
|
472
|
-
err
|
|
473
|
-
}, {
|
|
474
|
-
F: __dxlog_file2,
|
|
475
|
-
L: 37,
|
|
476
|
-
S: void 0,
|
|
477
|
-
C: (f, a) => f(...a)
|
|
478
|
-
});
|
|
479
|
-
reject(err);
|
|
480
|
-
}, {
|
|
481
|
-
once: true
|
|
482
|
-
});
|
|
483
|
-
audio2.addEventListener("canplay", async () => {
|
|
484
|
-
log2.info("starting...", void 0, {
|
|
485
|
-
F: __dxlog_file2,
|
|
486
|
-
L: 45,
|
|
487
|
-
S: void 0,
|
|
488
|
-
C: (f, a) => f(...a)
|
|
489
|
-
});
|
|
490
|
-
try {
|
|
491
|
-
await audio2.play();
|
|
492
|
-
resolve();
|
|
493
|
-
} catch (playError) {
|
|
494
|
-
log2.error("Play failed", {
|
|
495
|
-
playError
|
|
496
|
-
}, {
|
|
497
|
-
F: __dxlog_file2,
|
|
498
|
-
L: 51,
|
|
499
|
-
S: void 0,
|
|
500
|
-
C: (f, a) => f(...a)
|
|
501
|
-
});
|
|
502
|
-
resolve();
|
|
503
|
-
}
|
|
504
|
-
}, {
|
|
505
|
-
once: true
|
|
506
|
-
});
|
|
507
|
-
audio2.load();
|
|
508
|
-
});
|
|
509
|
-
const audioCtx = new AudioContext();
|
|
510
|
-
if (audioCtx.state === "suspended") {
|
|
511
|
-
await audioCtx.resume();
|
|
512
|
-
}
|
|
513
|
-
const destination = audioCtx.createMediaStreamDestination();
|
|
514
|
-
destination.channelCount = 1;
|
|
515
|
-
const source = audioCtx.createMediaElementSource(audio2);
|
|
516
|
-
source.connect(destination);
|
|
517
|
-
const track2 = destination.stream.getAudioTracks()[0];
|
|
518
|
-
if (constraints) {
|
|
519
|
-
await track2.applyConstraints(constraints).catch((err) => log2.catch(err, void 0, {
|
|
520
|
-
F: __dxlog_file2,
|
|
521
|
-
L: 75,
|
|
522
|
-
S: void 0,
|
|
523
|
-
C: (f, a) => f(...a)
|
|
524
|
-
}));
|
|
525
|
-
}
|
|
526
|
-
setStream({
|
|
527
|
-
audio: audio2,
|
|
528
|
-
stream: destination.stream,
|
|
529
|
-
track: destination.stream.getAudioTracks()[0]
|
|
530
|
-
});
|
|
531
|
-
});
|
|
532
|
-
return () => {
|
|
533
|
-
void ctx.dispose();
|
|
534
|
-
};
|
|
535
|
-
}, [
|
|
536
|
-
audioUrl
|
|
537
|
-
]);
|
|
538
|
-
return {
|
|
539
|
-
audio,
|
|
540
|
-
stream,
|
|
541
|
-
track
|
|
542
|
-
};
|
|
543
|
-
};
|
|
544
|
-
|
|
545
|
-
// src/hooks/useAudioTrack.ts
|
|
546
|
-
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
547
|
-
var useAudioTrack = (active, constraints) => {
|
|
548
|
-
const [track, setTrack] = useState2();
|
|
549
|
-
useEffect2(() => {
|
|
550
|
-
if (!active) {
|
|
551
|
-
track?.stop();
|
|
552
|
-
setTrack(void 0);
|
|
553
|
-
return;
|
|
554
|
-
}
|
|
555
|
-
const initAudio = async () => {
|
|
556
|
-
const audio = new Audio();
|
|
557
|
-
audio.srcObject = await navigator.mediaDevices.getUserMedia({
|
|
558
|
-
audio: constraints ?? true
|
|
559
|
-
});
|
|
560
|
-
const [track2] = audio.srcObject.getAudioTracks();
|
|
561
|
-
if (track2) {
|
|
562
|
-
setTrack(track2);
|
|
563
|
-
}
|
|
564
|
-
};
|
|
565
|
-
if (active) {
|
|
566
|
-
void initAudio();
|
|
567
|
-
}
|
|
568
|
-
}, [
|
|
569
|
-
active
|
|
570
|
-
]);
|
|
571
|
-
return track;
|
|
572
|
-
};
|
|
573
|
-
|
|
574
|
-
// src/hooks/useQueueModelAdapter.ts
|
|
575
|
-
import { useEffect as useEffect3, useMemo, useState as useState3 } from "react";
|
|
576
|
-
var useQueueModelAdapter = (renderer, queue, initialChunks = []) => {
|
|
577
|
-
const model = useMemo(() => new SerializationModel(renderer, initialChunks), [
|
|
578
|
-
queue
|
|
579
|
-
]);
|
|
580
|
-
const [loaded, setLoaded] = useState3(false);
|
|
581
|
-
useEffect3(() => {
|
|
582
|
-
if (!queue) {
|
|
583
|
-
return;
|
|
584
|
-
}
|
|
585
|
-
const update = () => {
|
|
586
|
-
for (const block of queue?.objects ?? []) {
|
|
587
|
-
model.appendChunk(block);
|
|
588
|
-
}
|
|
589
|
-
setLoaded(true);
|
|
590
|
-
};
|
|
591
|
-
let i;
|
|
592
|
-
if (queue.isLoading) {
|
|
593
|
-
i = setInterval(() => {
|
|
594
|
-
if (!queue?.isLoading) {
|
|
595
|
-
clearInterval(i);
|
|
596
|
-
update();
|
|
597
|
-
}
|
|
598
|
-
}, 1e3);
|
|
599
|
-
} else {
|
|
600
|
-
update();
|
|
601
|
-
}
|
|
602
|
-
return () => clearTimeout(i);
|
|
603
|
-
}, [
|
|
604
|
-
model,
|
|
605
|
-
queue
|
|
606
|
-
]);
|
|
607
|
-
useEffect3(() => {
|
|
608
|
-
if (!loaded || !queue || model.chunks.length === queue.objects.length) {
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
const chunk = queue.objects.at(-1);
|
|
612
|
-
if (chunk) {
|
|
613
|
-
model.appendChunk(chunk);
|
|
614
|
-
}
|
|
615
|
-
}, [
|
|
616
|
-
model,
|
|
617
|
-
loaded,
|
|
618
|
-
queue?.objects.length
|
|
619
|
-
]);
|
|
620
|
-
return model;
|
|
621
|
-
};
|
|
622
|
-
|
|
623
|
-
// src/hooks/useTranscriber.ts
|
|
624
|
-
import { useEffect as useEffect4, useMemo as useMemo2 } from "react";
|
|
625
|
-
import { useCapabilities } from "@dxos/app-framework";
|
|
626
|
-
|
|
627
|
-
// src/capabilities/index.ts
|
|
628
|
-
import { lazy } from "@dxos/app-framework";
|
|
629
|
-
var IntentResolver = lazy(() => import("./intent-resolver-YMN5SXNC.mjs"));
|
|
630
|
-
var ReactSurface = lazy(() => import("./react-surface-QRDJOHN5.mjs"));
|
|
631
|
-
var Transcriber = lazy(() => import("./transcriber-YUTEVANE.mjs"));
|
|
632
|
-
|
|
633
|
-
// src/hooks/useTranscriber.ts
|
|
634
|
-
var useTranscriber = ({ audioStreamTrack, recorderConfig, transcriberConfig, onSegments }) => {
|
|
635
|
-
const [getTranscriber] = useCapabilities(TranscriptionCapabilities.Transcriber);
|
|
636
|
-
const transcriber = useMemo2(() => {
|
|
637
|
-
if (!getTranscriber || !audioStreamTrack || !onSegments) {
|
|
638
|
-
return void 0;
|
|
639
|
-
}
|
|
640
|
-
return getTranscriber({
|
|
641
|
-
audioStreamTrack,
|
|
642
|
-
recorderConfig,
|
|
643
|
-
transcriberConfig,
|
|
644
|
-
onSegments
|
|
645
|
-
});
|
|
646
|
-
}, [
|
|
647
|
-
getTranscriber,
|
|
648
|
-
audioStreamTrack,
|
|
649
|
-
recorderConfig,
|
|
650
|
-
transcriberConfig,
|
|
651
|
-
onSegments
|
|
652
|
-
]);
|
|
653
|
-
useEffect4(() => {
|
|
654
|
-
return () => {
|
|
655
|
-
void transcriber?.close();
|
|
656
|
-
};
|
|
657
|
-
}, [
|
|
658
|
-
transcriber
|
|
659
|
-
]);
|
|
660
|
-
return transcriber;
|
|
661
|
-
};
|
|
662
|
-
|
|
663
|
-
// src/hooks/useVoiceInput.ts
|
|
664
|
-
import { useState as useState4, useEffect as useEffect5, useCallback } from "react";
|
|
665
|
-
import { scheduleMicroTask } from "@dxos/async";
|
|
666
|
-
import { Context as Context2 } from "@dxos/context";
|
|
667
|
-
import { log as log3 } from "@dxos/log";
|
|
668
|
-
import { useSoundEffect } from "@dxos/react-ui-sfx";
|
|
669
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/hooks/useVoiceInput.ts";
|
|
670
|
-
var useVoiceInput = ({ active, onUpdate }) => {
|
|
671
|
-
const soundStart = useSoundEffect("StartRecording");
|
|
672
|
-
const soundStop = useSoundEffect("StopRecording");
|
|
673
|
-
const handleSegments = useCallback(async (segments) => {
|
|
674
|
-
const text = segments.map((str) => str.text.trim().replace(/[^\w\s]/g, "")).join(" ");
|
|
675
|
-
onUpdate(text);
|
|
676
|
-
}, []);
|
|
677
|
-
const [recording, setRecording] = useState4(false);
|
|
678
|
-
const track = useAudioTrack(active);
|
|
679
|
-
const transcriber = useTranscriber({
|
|
680
|
-
audioStreamTrack: track,
|
|
681
|
-
onSegments: handleSegments
|
|
682
|
-
});
|
|
683
|
-
useEffect5(() => {
|
|
684
|
-
const ctx = new Context2(void 0, {
|
|
685
|
-
F: __dxlog_file3,
|
|
686
|
-
L: 43
|
|
687
|
-
});
|
|
688
|
-
scheduleMicroTask(ctx, async () => {
|
|
689
|
-
if (active && transcriber) {
|
|
690
|
-
await transcriber.open();
|
|
691
|
-
log3.info("starting...", void 0, {
|
|
692
|
-
F: __dxlog_file3,
|
|
693
|
-
L: 47,
|
|
694
|
-
S: void 0,
|
|
695
|
-
C: (f, a) => f(...a)
|
|
696
|
-
});
|
|
697
|
-
setRecording(true);
|
|
698
|
-
void soundStart.play();
|
|
699
|
-
transcriber.startChunksRecording();
|
|
700
|
-
} else if (!active && transcriber?.isOpen) {
|
|
701
|
-
transcriber?.stopChunksRecording();
|
|
702
|
-
await transcriber?.close();
|
|
703
|
-
log3.info("stopped", void 0, {
|
|
704
|
-
F: __dxlog_file3,
|
|
705
|
-
L: 54,
|
|
706
|
-
S: void 0,
|
|
707
|
-
C: (f, a) => f(...a)
|
|
708
|
-
});
|
|
709
|
-
setRecording(false);
|
|
710
|
-
void soundStop.play();
|
|
711
|
-
}
|
|
712
|
-
});
|
|
713
|
-
return () => {
|
|
714
|
-
void ctx.dispose();
|
|
715
|
-
};
|
|
716
|
-
}, [
|
|
717
|
-
active,
|
|
718
|
-
transcriber
|
|
719
|
-
]);
|
|
720
|
-
return {
|
|
721
|
-
recording
|
|
722
|
-
};
|
|
723
|
-
};
|
|
724
|
-
|
|
725
701
|
// src/components/TranscriptContainer.tsx
|
|
726
702
|
var TranscriptionContainer = ({ transcript: transcript2 }) => {
|
|
727
703
|
var _effect = _useSignals2();
|
|
728
704
|
try {
|
|
729
|
-
const attendableId =
|
|
705
|
+
const attendableId = Obj.getDXN(transcript2).toString();
|
|
730
706
|
const space = getSpace(transcript2);
|
|
731
707
|
const members = useMembers(space?.key).map((member) => member.identity);
|
|
732
708
|
const queue = useQueue(transcript2.queue.dxn, {
|
|
733
709
|
pollInterval: 1e3
|
|
734
710
|
});
|
|
735
|
-
const model = useQueueModelAdapter(
|
|
736
|
-
return /* @__PURE__ */ React2.createElement(StackItem.Content, {
|
|
737
|
-
classNames: "container-max-width pli-2"
|
|
738
|
-
}, /* @__PURE__ */ React2.createElement(Transcript, {
|
|
711
|
+
const model = useQueueModelAdapter(renderByline(members), queue);
|
|
712
|
+
return /* @__PURE__ */ React2.createElement(StackItem.Content, null, /* @__PURE__ */ React2.createElement(TranscriptView, {
|
|
739
713
|
attendableId,
|
|
740
714
|
space,
|
|
741
715
|
model,
|
|
@@ -748,8 +722,8 @@ var TranscriptionContainer = ({ transcript: transcript2 }) => {
|
|
|
748
722
|
var TranscriptContainer_default = TranscriptionContainer;
|
|
749
723
|
|
|
750
724
|
export {
|
|
751
|
-
|
|
752
|
-
|
|
725
|
+
renderByline,
|
|
726
|
+
TranscriptView,
|
|
753
727
|
useAudioFile,
|
|
754
728
|
useAudioTrack,
|
|
755
729
|
useQueueModelAdapter,
|
|
@@ -757,8 +731,9 @@ export {
|
|
|
757
731
|
useVoiceInput,
|
|
758
732
|
TranscriptionContainer,
|
|
759
733
|
TranscriptContainer_default,
|
|
734
|
+
BlueprintDefinition,
|
|
760
735
|
IntentResolver,
|
|
761
736
|
ReactSurface,
|
|
762
737
|
Transcriber
|
|
763
738
|
};
|
|
764
|
-
//# sourceMappingURL=chunk-
|
|
739
|
+
//# sourceMappingURL=chunk-7XASA7DX.mjs.map
|