@dxos/plugin-transcription 0.8.4-main.2e9d522 → 0.8.4-main.5ea62a8
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-OX7OOODC.mjs +11 -0
- package/dist/lib/browser/blueprint-definition-QQSGTX5F.mjs +142 -0
- package/dist/lib/browser/blueprint-definition-QQSGTX5F.mjs.map +7 -0
- package/dist/lib/browser/{chunk-4FJIYH7T.mjs → chunk-26XDG6GQ.mjs} +2 -2
- package/dist/lib/browser/{chunk-5WH45KBY.mjs → chunk-3X7HP44M.mjs} +8 -1
- package/dist/lib/browser/{chunk-5WH45KBY.mjs.map → chunk-3X7HP44M.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-5KPYIC3N.mjs → chunk-5I4BMOGE.mjs} +422 -402
- package/dist/lib/browser/chunk-5I4BMOGE.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FFEPEPCU.mjs → chunk-BA64VLLR.mjs} +85 -94
- package/dist/lib/browser/chunk-BA64VLLR.mjs.map +7 -0
- package/dist/lib/browser/chunk-HXVGV7T6.mjs +63 -0
- package/dist/lib/browser/chunk-HXVGV7T6.mjs.map +7 -0
- package/dist/lib/browser/{chunk-U6QBOGTN.mjs → chunk-TNEQFHIU.mjs} +2 -2
- package/dist/lib/browser/{chunk-U6QBOGTN.mjs.map → chunk-TNEQFHIU.mjs.map} +1 -1
- package/dist/lib/browser/index.mjs +18 -12
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-T3EGLS3L.mjs +25 -0
- package/dist/lib/browser/intent-resolver-T3EGLS3L.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-E5D5AE3F.mjs → react-surface-QYX74JNG.mjs} +8 -8
- package/dist/lib/browser/react-surface-QYX74JNG.mjs.map +7 -0
- package/dist/lib/browser/{transcriber-PXT4QBFY.mjs → transcriber-JOOAQVYV.mjs} +5 -5
- package/dist/lib/browser/transcriber-JOOAQVYV.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +6 -8
- package/dist/lib/node-esm/{TranscriptContainer-VBAOM5DG.mjs → TranscriptContainer-BUWK63SI.mjs} +4 -4
- package/dist/lib/node-esm/blueprint-definition-4PLCTH5Q.mjs +143 -0
- package/dist/lib/node-esm/blueprint-definition-4PLCTH5Q.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-RHF2ALML.mjs → chunk-3QAIZGMW.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-RHF2ALML.mjs.map → chunk-3QAIZGMW.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-TJKAO7VR.mjs → chunk-DT3AOC3E.mjs} +422 -402
- package/dist/lib/node-esm/chunk-DT3AOC3E.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HT3W7LDP.mjs → chunk-J5GQ3KGX.mjs} +85 -94
- package/dist/lib/node-esm/chunk-J5GQ3KGX.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-Y2B4HWSS.mjs → chunk-NWD757KH.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-XMUCZBP3.mjs → chunk-QARUDLHN.mjs} +7 -1
- package/dist/lib/node-esm/{chunk-XMUCZBP3.mjs.map → chunk-QARUDLHN.mjs.map} +1 -1
- package/dist/lib/node-esm/chunk-W72HVQMD.mjs +64 -0
- package/dist/lib/node-esm/chunk-W72HVQMD.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +18 -12
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-VDHCUAIO.mjs +26 -0
- package/dist/lib/node-esm/intent-resolver-VDHCUAIO.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-QRDJOHN5.mjs → react-surface-TM7XOQBR.mjs} +8 -8
- package/dist/lib/node-esm/react-surface-TM7XOQBR.mjs.map +7 -0
- package/dist/lib/node-esm/{transcriber-YUTEVANE.mjs → transcriber-QPS55YP2.mjs} +5 -5
- package/dist/lib/node-esm/transcriber-QPS55YP2.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +6 -8
- 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 +4 -4
- package/dist/types/src/components/Transcript/Transcript.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts +32 -15
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts +2 -2
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.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 -2
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts +10 -5
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts +7 -4
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/TranscriptionStory.d.ts +1 -0
- 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/useVoiceInput.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/normalization.d.ts +366 -321
- package/dist/types/src/segments-normalization/normalization.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +1 -1
- 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.map +1 -1
- package/dist/types/src/transcriber/transcription-manager.d.ts +3 -7
- 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 +55 -53
- package/src/TranscriptionPlugin.tsx +10 -5
- package/src/capabilities/blueprint-definition.ts +31 -0
- package/src/capabilities/capabilities.ts +3 -3
- 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 +12 -13
- package/src/components/Transcript/Transcript.tsx +8 -7
- package/src/components/Transcript/deprecated/OldTranscript.tsx +4 -4
- package/src/components/TranscriptContainer.tsx +5 -4
- package/src/components/stories/FileTranscription.stories.tsx +22 -12
- package/src/components/stories/KeyWordRecognition.stories.tsx +12 -6
- package/src/components/stories/MicrophoneTranscription.stories.tsx +10 -9
- package/src/components/stories/TranscriptionStory.tsx +9 -5
- package/src/functions/index.ts +6 -0
- package/src/functions/open.ts +37 -0
- package/src/functions/summarize.ts +97 -0
- package/src/hooks/useAudioFile.ts +1 -10
- package/src/hooks/useVoiceInput.ts +3 -2
- package/src/model/model.test.ts +1 -1
- package/src/segments-normalization/message-normalizer.ts +1 -1
- package/src/segments-normalization/normalization.test.ts +4 -4
- package/src/segments-normalization/normalization.ts +37 -36
- package/src/testing/testing.ts +3 -3
- package/src/transcriber/media-stream-recorder.ts +1 -1
- package/src/transcriber/transcriber.browser.test.ts +2 -1
- package/src/transcriber/transcriber.ts +2 -1
- package/src/transcriber/transcription-manager.ts +17 -38
- package/src/types/{schema.ts → Transcript.ts} +11 -8
- 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-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/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-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/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-OX7OOODC.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-4FJIYH7T.mjs.map → chunk-26XDG6GQ.mjs.map} +0 -0
- /package/dist/lib/node-esm/{TranscriptContainer-VBAOM5DG.mjs.map → TranscriptContainer-BUWK63SI.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-Y2B4HWSS.mjs.map → chunk-NWD757KH.mjs.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
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-3QAIZGMW.mjs";
|
|
5
5
|
|
|
6
6
|
// src/components/TranscriptContainer.tsx
|
|
7
7
|
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
@@ -10,43 +10,149 @@ import { fullyQualifiedId, getSpace } from "@dxos/client/echo";
|
|
|
10
10
|
import { useMembers, useQueue } from "@dxos/react-client/echo";
|
|
11
11
|
import { StackItem } from "@dxos/react-ui-stack";
|
|
12
12
|
|
|
13
|
-
// src/
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
// src/hooks/useAudioFile.ts
|
|
14
|
+
import { useEffect, useState } from "react";
|
|
15
|
+
import { scheduleTask } from "@dxos/async";
|
|
16
|
+
import { Context } from "@dxos/context";
|
|
17
|
+
import { log } from "@dxos/log";
|
|
18
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/hooks/useAudioFile.ts";
|
|
19
|
+
var useAudioFile = (audioUrl, constraints) => {
|
|
20
|
+
const [{ audio, stream, track }, setStream] = useState({});
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const ctx = new Context(void 0, {
|
|
23
|
+
F: __dxlog_file,
|
|
24
|
+
L: 20
|
|
25
|
+
});
|
|
26
|
+
scheduleTask(ctx, async () => {
|
|
27
|
+
const response = await fetch(audioUrl);
|
|
28
|
+
const blob = await response.blob();
|
|
29
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
30
|
+
ctx.onDispose(() => {
|
|
31
|
+
URL.revokeObjectURL(objectUrl);
|
|
32
|
+
});
|
|
33
|
+
const audio2 = new Audio();
|
|
34
|
+
audio2.src = objectUrl;
|
|
35
|
+
await new Promise((resolve, reject) => {
|
|
36
|
+
audio2.addEventListener("error", (err) => {
|
|
37
|
+
log.error("error", {
|
|
38
|
+
err
|
|
39
|
+
}, {
|
|
40
|
+
F: __dxlog_file,
|
|
41
|
+
L: 37,
|
|
42
|
+
S: void 0,
|
|
43
|
+
C: (f, a) => f(...a)
|
|
44
|
+
});
|
|
45
|
+
reject(err);
|
|
46
|
+
}, {
|
|
47
|
+
once: true
|
|
48
|
+
});
|
|
49
|
+
audio2.addEventListener("canplay", async () => {
|
|
50
|
+
resolve();
|
|
51
|
+
}, {
|
|
52
|
+
once: true
|
|
53
|
+
});
|
|
54
|
+
audio2.load();
|
|
55
|
+
});
|
|
56
|
+
const audioCtx = new AudioContext();
|
|
57
|
+
if (audioCtx.state === "suspended") {
|
|
58
|
+
await audioCtx.resume();
|
|
59
|
+
}
|
|
60
|
+
const destination = audioCtx.createMediaStreamDestination();
|
|
61
|
+
destination.channelCount = 1;
|
|
62
|
+
const source = audioCtx.createMediaElementSource(audio2);
|
|
63
|
+
source.connect(destination);
|
|
64
|
+
const track2 = destination.stream.getAudioTracks()[0];
|
|
65
|
+
if (constraints) {
|
|
66
|
+
await track2.applyConstraints(constraints).catch((err) => log.catch(err, void 0, {
|
|
67
|
+
F: __dxlog_file,
|
|
68
|
+
L: 66,
|
|
69
|
+
S: void 0,
|
|
70
|
+
C: (f, a) => f(...a)
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
setStream({
|
|
74
|
+
audio: audio2,
|
|
75
|
+
stream: destination.stream,
|
|
76
|
+
track: destination.stream.getAudioTracks()[0]
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
return () => {
|
|
80
|
+
void ctx.dispose();
|
|
81
|
+
};
|
|
82
|
+
}, [
|
|
83
|
+
audioUrl
|
|
84
|
+
]);
|
|
85
|
+
return {
|
|
86
|
+
audio,
|
|
87
|
+
stream,
|
|
88
|
+
track
|
|
89
|
+
};
|
|
90
|
+
};
|
|
20
91
|
|
|
21
|
-
// src/
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
92
|
+
// src/hooks/useAudioTrack.ts
|
|
93
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
94
|
+
var useAudioTrack = (active, constraints) => {
|
|
95
|
+
const [track, setTrack] = useState2();
|
|
96
|
+
useEffect2(() => {
|
|
97
|
+
if (!active) {
|
|
98
|
+
track?.stop();
|
|
99
|
+
setTrack(void 0);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const initAudio = async () => {
|
|
103
|
+
const audio = new Audio();
|
|
104
|
+
audio.srcObject = await navigator.mediaDevices.getUserMedia({
|
|
105
|
+
audio: constraints ?? true
|
|
106
|
+
});
|
|
107
|
+
const [track2] = audio.srcObject.getAudioTracks();
|
|
108
|
+
if (track2) {
|
|
109
|
+
setTrack(track2);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
if (active) {
|
|
113
|
+
void initAudio();
|
|
114
|
+
}
|
|
115
|
+
}, [
|
|
116
|
+
active
|
|
117
|
+
]);
|
|
118
|
+
return track;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// src/hooks/useQueueModelAdapter.ts
|
|
122
|
+
import { useEffect as useEffect3, useMemo, useState as useState3 } from "react";
|
|
27
123
|
|
|
28
124
|
// src/model/model.ts
|
|
29
125
|
import { Text } from "@codemirror/state";
|
|
30
126
|
import { Event } from "@dxos/async";
|
|
31
127
|
import { invariant } from "@dxos/invariant";
|
|
32
|
-
import { log } from "@dxos/log";
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
128
|
+
import { log as log2 } from "@dxos/log";
|
|
129
|
+
function _define_property(obj, key, value) {
|
|
130
|
+
if (key in obj) {
|
|
131
|
+
Object.defineProperty(obj, key, {
|
|
132
|
+
value,
|
|
133
|
+
enumerable: true,
|
|
134
|
+
configurable: true,
|
|
135
|
+
writable: true
|
|
136
|
+
});
|
|
137
|
+
} else {
|
|
138
|
+
obj[key] = value;
|
|
37
139
|
}
|
|
140
|
+
return obj;
|
|
141
|
+
}
|
|
142
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/model/model.ts";
|
|
143
|
+
var DocumentAdapter = class {
|
|
38
144
|
/** The document must always have at least one line. */
|
|
39
145
|
lineCount() {
|
|
40
146
|
return this._view.state.doc.lines - 1;
|
|
41
147
|
}
|
|
42
148
|
replaceLines(from, remove, insert) {
|
|
43
|
-
|
|
149
|
+
log2("replaceLines", {
|
|
44
150
|
count: this._view.state.doc.lines,
|
|
45
151
|
from,
|
|
46
152
|
remove,
|
|
47
153
|
insert
|
|
48
154
|
}, {
|
|
49
|
-
F:
|
|
155
|
+
F: __dxlog_file2,
|
|
50
156
|
L: 39,
|
|
51
157
|
S: this,
|
|
52
158
|
C: (f, a) => f(...a)
|
|
@@ -66,19 +172,12 @@ var DocumentAdapter = class {
|
|
|
66
172
|
}
|
|
67
173
|
});
|
|
68
174
|
}
|
|
175
|
+
constructor(_view) {
|
|
176
|
+
_define_property(this, "_view", void 0);
|
|
177
|
+
this._view = _view;
|
|
178
|
+
}
|
|
69
179
|
};
|
|
70
180
|
var SerializationModel = class {
|
|
71
|
-
constructor(_renderer, initialChunks = []) {
|
|
72
|
-
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
|
-
initialChunks.forEach((chunk) => {
|
|
79
|
-
this.appendChunk(chunk);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
181
|
toJSON() {
|
|
83
182
|
return {
|
|
84
183
|
chunks: this._chunks.length,
|
|
@@ -121,7 +220,7 @@ var SerializationModel = class {
|
|
|
121
220
|
updateChunk(chunk) {
|
|
122
221
|
const index = this._chunks.findIndex((c) => c.id === chunk.id);
|
|
123
222
|
invariant(index !== -1, void 0, {
|
|
124
|
-
F:
|
|
223
|
+
F: __dxlog_file2,
|
|
125
224
|
L: 147,
|
|
126
225
|
S: this,
|
|
127
226
|
A: [
|
|
@@ -141,7 +240,7 @@ var SerializationModel = class {
|
|
|
141
240
|
deleteBlock(id) {
|
|
142
241
|
const index = this._chunks.findIndex((c) => c.id === id);
|
|
143
242
|
invariant(index !== -1, void 0, {
|
|
144
|
-
F:
|
|
243
|
+
F: __dxlog_file2,
|
|
145
244
|
L: 156,
|
|
146
245
|
S: this,
|
|
147
246
|
A: [
|
|
@@ -162,10 +261,10 @@ var SerializationModel = class {
|
|
|
162
261
|
* Syncs the tracked changes with the ChunkDocument.
|
|
163
262
|
*/
|
|
164
263
|
sync(document2) {
|
|
165
|
-
|
|
264
|
+
log2("sync", {
|
|
166
265
|
changes: this._changes
|
|
167
266
|
}, {
|
|
168
|
-
F:
|
|
267
|
+
F: __dxlog_file2,
|
|
169
268
|
L: 167,
|
|
170
269
|
S: this,
|
|
171
270
|
C: (f, a) => f(...a)
|
|
@@ -216,95 +315,292 @@ var SerializationModel = class {
|
|
|
216
315
|
this._changes.length = 0;
|
|
217
316
|
return this;
|
|
218
317
|
}
|
|
318
|
+
constructor(_renderer, initialChunks = []) {
|
|
319
|
+
_define_property(this, "_renderer", void 0);
|
|
320
|
+
_define_property(this, "_chunks", void 0);
|
|
321
|
+
_define_property(this, "_chunkLineCounts", void 0);
|
|
322
|
+
_define_property(this, "_lineToChunk", void 0);
|
|
323
|
+
_define_property(this, "_changes", void 0);
|
|
324
|
+
_define_property(this, "update", void 0);
|
|
325
|
+
this._renderer = _renderer;
|
|
326
|
+
this._chunks = [];
|
|
327
|
+
this._chunkLineCounts = /* @__PURE__ */ new Map();
|
|
328
|
+
this._lineToChunk = /* @__PURE__ */ new Map();
|
|
329
|
+
this._changes = [];
|
|
330
|
+
this.update = new Event();
|
|
331
|
+
initialChunks.forEach((chunk) => {
|
|
332
|
+
this.appendChunk(chunk);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
219
335
|
};
|
|
220
336
|
|
|
221
|
-
// src/
|
|
222
|
-
var
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const block = model.getChunkAtLine(line.number)?.blocks[0];
|
|
235
|
-
const timestamp = block?._tag === "transcript" && block.started;
|
|
236
|
-
if (timestamp) {
|
|
237
|
-
builder.add(line.from, line.from, new TimestampMarker(line.number, new Date(timestamp), start));
|
|
238
|
-
}
|
|
239
|
-
if (line.to + 1 > view.state.doc.length) {
|
|
240
|
-
break;
|
|
241
|
-
}
|
|
242
|
-
line = view.state.doc.lineAt(line.to + 1);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
return builder.finish();
|
|
246
|
-
}
|
|
247
|
-
}),
|
|
248
|
-
// Listen for model updates.
|
|
249
|
-
ViewPlugin.fromClass(class {
|
|
250
|
-
constructor(view) {
|
|
251
|
-
this._initialized = false;
|
|
252
|
-
this._adapter = new DocumentAdapter(view);
|
|
253
|
-
const scroller = view.scrollDOM;
|
|
254
|
-
let isAutoScrolling = false;
|
|
255
|
-
let hasScrolled = false;
|
|
256
|
-
let timeout;
|
|
257
|
-
const scrollToBottom = (smooth = false) => {
|
|
258
|
-
scroller.style.scrollBehavior = smooth ? "smooth" : "";
|
|
259
|
-
scroller.classList.add("cm-hide-scrollbar");
|
|
260
|
-
isAutoScrolling = true;
|
|
261
|
-
clearTimeout(timeout);
|
|
262
|
-
timeout = setTimeout(() => {
|
|
263
|
-
this._controls?.classList.add("opacity-0");
|
|
264
|
-
scroller.classList.remove("cm-hide-scrollbar");
|
|
265
|
-
isAutoScrolling = false;
|
|
266
|
-
}, 500);
|
|
267
|
-
view.dispatch({
|
|
268
|
-
effects: EditorView.scrollIntoView(view.state.doc.length, {
|
|
269
|
-
y: "end"
|
|
270
|
-
})
|
|
271
|
-
});
|
|
272
|
-
};
|
|
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
|
-
this._cleanup = combine(addEventListener(view.scrollDOM, "scroll", () => {
|
|
284
|
-
if (!isAutoScrolling) {
|
|
285
|
-
hasScrolled = true;
|
|
286
|
-
this._controls?.classList.remove("opacity-0");
|
|
287
|
-
}
|
|
288
|
-
}), model.update.on(() => {
|
|
289
|
-
const autoScroll = scroller.scrollHeight - scroller.scrollTop - scroller.clientHeight === 0 || !hasScrolled;
|
|
290
|
-
model.sync(this._adapter);
|
|
291
|
-
if (autoScroll) {
|
|
292
|
-
scrollToBottom(true);
|
|
293
|
-
}
|
|
294
|
-
}));
|
|
337
|
+
// src/hooks/useQueueModelAdapter.ts
|
|
338
|
+
var useQueueModelAdapter = (renderer, queue, initialChunks = []) => {
|
|
339
|
+
const model = useMemo(() => new SerializationModel(renderer, initialChunks), [
|
|
340
|
+
queue
|
|
341
|
+
]);
|
|
342
|
+
const [loaded, setLoaded] = useState3(false);
|
|
343
|
+
useEffect3(() => {
|
|
344
|
+
if (!queue) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
const update = () => {
|
|
348
|
+
for (const block of queue?.objects ?? []) {
|
|
349
|
+
model.appendChunk(block);
|
|
295
350
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
351
|
+
setLoaded(true);
|
|
352
|
+
};
|
|
353
|
+
let i;
|
|
354
|
+
if (queue.isLoading) {
|
|
355
|
+
i = setInterval(() => {
|
|
356
|
+
if (!queue?.isLoading) {
|
|
357
|
+
clearInterval(i);
|
|
358
|
+
update();
|
|
359
|
+
}
|
|
360
|
+
}, 1e3);
|
|
361
|
+
} else {
|
|
362
|
+
update();
|
|
363
|
+
}
|
|
364
|
+
return () => clearTimeout(i);
|
|
365
|
+
}, [
|
|
366
|
+
model,
|
|
367
|
+
queue
|
|
368
|
+
]);
|
|
369
|
+
useEffect3(() => {
|
|
370
|
+
if (!loaded || !queue || model.chunks.length === queue.objects.length) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const chunk = queue.objects.at(-1);
|
|
374
|
+
if (chunk) {
|
|
375
|
+
model.appendChunk(chunk);
|
|
376
|
+
}
|
|
377
|
+
}, [
|
|
378
|
+
model,
|
|
379
|
+
loaded,
|
|
380
|
+
queue?.objects.length
|
|
381
|
+
]);
|
|
382
|
+
return model;
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
// src/hooks/useTranscriber.ts
|
|
386
|
+
import { useEffect as useEffect4, useMemo as useMemo2 } from "react";
|
|
387
|
+
import { useCapabilities } from "@dxos/app-framework";
|
|
388
|
+
|
|
389
|
+
// src/capabilities/index.ts
|
|
390
|
+
import { lazy } from "@dxos/app-framework";
|
|
391
|
+
var BlueprintDefinition = lazy(() => import("./blueprint-definition-4PLCTH5Q.mjs"));
|
|
392
|
+
var IntentResolver = lazy(() => import("./intent-resolver-VDHCUAIO.mjs"));
|
|
393
|
+
var ReactSurface = lazy(() => import("./react-surface-TM7XOQBR.mjs"));
|
|
394
|
+
var Transcriber = lazy(() => import("./transcriber-QPS55YP2.mjs"));
|
|
395
|
+
|
|
396
|
+
// src/hooks/useTranscriber.ts
|
|
397
|
+
var useTranscriber = ({ audioStreamTrack, recorderConfig, transcriberConfig, onSegments }) => {
|
|
398
|
+
const [getTranscriber] = useCapabilities(TranscriptionCapabilities.Transcriber);
|
|
399
|
+
const transcriber = useMemo2(() => {
|
|
400
|
+
if (!getTranscriber || !audioStreamTrack || !onSegments) {
|
|
401
|
+
return void 0;
|
|
402
|
+
}
|
|
403
|
+
return getTranscriber({
|
|
404
|
+
audioStreamTrack,
|
|
405
|
+
recorderConfig,
|
|
406
|
+
transcriberConfig,
|
|
407
|
+
onSegments
|
|
408
|
+
});
|
|
409
|
+
}, [
|
|
410
|
+
getTranscriber,
|
|
411
|
+
audioStreamTrack,
|
|
412
|
+
recorderConfig,
|
|
413
|
+
transcriberConfig,
|
|
414
|
+
onSegments
|
|
415
|
+
]);
|
|
416
|
+
useEffect4(() => {
|
|
417
|
+
return () => {
|
|
418
|
+
void transcriber?.close();
|
|
419
|
+
};
|
|
420
|
+
}, [
|
|
421
|
+
transcriber
|
|
422
|
+
]);
|
|
423
|
+
return transcriber;
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
// src/hooks/useVoiceInput.ts
|
|
427
|
+
import { useCallback, useEffect as useEffect5, useState as useState4 } from "react";
|
|
428
|
+
import { scheduleMicroTask } from "@dxos/async";
|
|
429
|
+
import { Context as Context2 } from "@dxos/context";
|
|
430
|
+
import { log as log3 } from "@dxos/log";
|
|
431
|
+
import { useSoundEffect } from "@dxos/react-ui-sfx";
|
|
432
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/hooks/useVoiceInput.ts";
|
|
433
|
+
var useVoiceInput = ({ active, onUpdate }) => {
|
|
434
|
+
const soundStart = useSoundEffect("StartRecording");
|
|
435
|
+
const soundStop = useSoundEffect("StopRecording");
|
|
436
|
+
const handleSegments = useCallback(async (segments) => {
|
|
437
|
+
const text = segments.map((str) => str.text.trim().replace(/[^\w\s]/g, "")).join(" ");
|
|
438
|
+
onUpdate(text);
|
|
439
|
+
}, []);
|
|
440
|
+
const [recording, setRecording] = useState4(false);
|
|
441
|
+
const track = useAudioTrack(active);
|
|
442
|
+
const transcriber = useTranscriber({
|
|
443
|
+
audioStreamTrack: track,
|
|
444
|
+
onSegments: handleSegments
|
|
445
|
+
});
|
|
446
|
+
useEffect5(() => {
|
|
447
|
+
const ctx = new Context2(void 0, {
|
|
448
|
+
F: __dxlog_file3,
|
|
449
|
+
L: 44
|
|
450
|
+
});
|
|
451
|
+
scheduleMicroTask(ctx, async () => {
|
|
452
|
+
if (active && transcriber) {
|
|
453
|
+
await transcriber.open();
|
|
454
|
+
log3.info("starting...", void 0, {
|
|
455
|
+
F: __dxlog_file3,
|
|
456
|
+
L: 48,
|
|
457
|
+
S: void 0,
|
|
458
|
+
C: (f, a) => f(...a)
|
|
459
|
+
});
|
|
460
|
+
setRecording(true);
|
|
461
|
+
void soundStart.play();
|
|
462
|
+
transcriber.startChunksRecording();
|
|
463
|
+
} else if (!active && transcriber?.isOpen) {
|
|
464
|
+
transcriber?.stopChunksRecording();
|
|
465
|
+
await transcriber?.close();
|
|
466
|
+
log3.info("stopped", void 0, {
|
|
467
|
+
F: __dxlog_file3,
|
|
468
|
+
L: 55,
|
|
469
|
+
S: void 0,
|
|
470
|
+
C: (f, a) => f(...a)
|
|
471
|
+
});
|
|
472
|
+
setRecording(false);
|
|
473
|
+
void soundStop.play();
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
return () => {
|
|
477
|
+
void ctx.dispose();
|
|
478
|
+
};
|
|
479
|
+
}, [
|
|
480
|
+
active,
|
|
481
|
+
transcriber
|
|
482
|
+
]);
|
|
483
|
+
return {
|
|
484
|
+
recording
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
// src/components/Transcript/Transcript.tsx
|
|
489
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
490
|
+
import React from "react";
|
|
491
|
+
import { IconButton, useThemeContext } from "@dxos/react-ui";
|
|
492
|
+
import { createBasicExtensions, createMarkdownExtensions, createRenderer, createThemeExtensions, decorateMarkdown, editorWidth, preview, useTextEditor } from "@dxos/react-ui-editor";
|
|
493
|
+
import { mx } from "@dxos/react-ui-theme";
|
|
494
|
+
import { isNotFalsy } from "@dxos/util";
|
|
495
|
+
|
|
496
|
+
// src/components/Transcript/transcript-extension.ts
|
|
497
|
+
import { RangeSetBuilder } from "@codemirror/state";
|
|
498
|
+
import { EditorView, GutterMarker, ViewPlugin, gutter } from "@codemirror/view";
|
|
499
|
+
import { format } from "date-fns/format";
|
|
500
|
+
import { intervalToDuration } from "date-fns/intervalToDuration";
|
|
501
|
+
import { addEventListener, combine } from "@dxos/async";
|
|
502
|
+
function _define_property2(obj, key, value) {
|
|
503
|
+
if (key in obj) {
|
|
504
|
+
Object.defineProperty(obj, key, {
|
|
505
|
+
value,
|
|
506
|
+
enumerable: true,
|
|
507
|
+
configurable: true,
|
|
508
|
+
writable: true
|
|
509
|
+
});
|
|
510
|
+
} else {
|
|
511
|
+
obj[key] = value;
|
|
512
|
+
}
|
|
513
|
+
return obj;
|
|
514
|
+
}
|
|
515
|
+
var transcript = ({ model, started, renderButton }) => {
|
|
516
|
+
return [
|
|
517
|
+
// Show timestamps in the gutter.
|
|
518
|
+
gutter({
|
|
519
|
+
class: "cm-timestamp-gutter",
|
|
520
|
+
lineMarkerChange: (update) => update.docChanged || update.viewportChanged,
|
|
521
|
+
markers: (view) => {
|
|
522
|
+
const start = getStartTime(started, model.chunks[0]);
|
|
523
|
+
const builder = new RangeSetBuilder();
|
|
524
|
+
for (const { from, to } of view.visibleRanges) {
|
|
525
|
+
let line = view.state.doc.lineAt(from);
|
|
526
|
+
while (line.from <= to) {
|
|
527
|
+
const block = model.getChunkAtLine(line.number)?.blocks[0];
|
|
528
|
+
const timestamp = block?._tag === "transcript" && block.started;
|
|
529
|
+
if (timestamp) {
|
|
530
|
+
builder.add(line.from, line.from, new TimestampMarker(line.number, new Date(timestamp), start));
|
|
531
|
+
}
|
|
532
|
+
if (line.to + 1 > view.state.doc.length) {
|
|
533
|
+
break;
|
|
534
|
+
}
|
|
535
|
+
line = view.state.doc.lineAt(line.to + 1);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
return builder.finish();
|
|
539
|
+
}
|
|
540
|
+
}),
|
|
541
|
+
// Listen for model updates.
|
|
542
|
+
ViewPlugin.fromClass(class {
|
|
543
|
+
update(update) {
|
|
544
|
+
if (!this._initialized) {
|
|
545
|
+
this._initialized = true;
|
|
546
|
+
setTimeout(() => {
|
|
547
|
+
model.sync(this._adapter);
|
|
548
|
+
});
|
|
302
549
|
}
|
|
303
550
|
}
|
|
304
551
|
destroy() {
|
|
305
552
|
this._controls?.remove();
|
|
306
553
|
this._cleanup();
|
|
307
554
|
}
|
|
555
|
+
constructor(view) {
|
|
556
|
+
_define_property2(this, "_controls", void 0);
|
|
557
|
+
_define_property2(this, "_cleanup", void 0);
|
|
558
|
+
_define_property2(this, "_adapter", void 0);
|
|
559
|
+
_define_property2(this, "_initialized", false);
|
|
560
|
+
this._adapter = new DocumentAdapter(view);
|
|
561
|
+
const scroller = view.scrollDOM;
|
|
562
|
+
let isAutoScrolling = false;
|
|
563
|
+
let hasScrolled = false;
|
|
564
|
+
let timeout;
|
|
565
|
+
const scrollToBottom = (smooth = false) => {
|
|
566
|
+
scroller.style.scrollBehavior = smooth ? "smooth" : "";
|
|
567
|
+
scroller.classList.add("cm-hide-scrollbar");
|
|
568
|
+
isAutoScrolling = true;
|
|
569
|
+
clearTimeout(timeout);
|
|
570
|
+
timeout = setTimeout(() => {
|
|
571
|
+
this._controls?.classList.add("opacity-0");
|
|
572
|
+
scroller.classList.remove("cm-hide-scrollbar");
|
|
573
|
+
isAutoScrolling = false;
|
|
574
|
+
}, 500);
|
|
575
|
+
view.dispatch({
|
|
576
|
+
effects: EditorView.scrollIntoView(view.state.doc.length, {
|
|
577
|
+
y: "end"
|
|
578
|
+
})
|
|
579
|
+
});
|
|
580
|
+
};
|
|
581
|
+
if (renderButton) {
|
|
582
|
+
this._controls = document.createElement("div");
|
|
583
|
+
this._controls.classList.add("cm-controls", "transition-opacity", "duration-300", "opacity-0");
|
|
584
|
+
view.dom.appendChild(this._controls);
|
|
585
|
+
renderButton(this._controls, {
|
|
586
|
+
onClick: () => {
|
|
587
|
+
scrollToBottom(false);
|
|
588
|
+
}
|
|
589
|
+
}, view);
|
|
590
|
+
}
|
|
591
|
+
this._cleanup = combine(addEventListener(view.scrollDOM, "scroll", () => {
|
|
592
|
+
if (!isAutoScrolling) {
|
|
593
|
+
hasScrolled = true;
|
|
594
|
+
this._controls?.classList.remove("opacity-0");
|
|
595
|
+
}
|
|
596
|
+
}), model.update.on(() => {
|
|
597
|
+
const autoScroll = scroller.scrollHeight - scroller.scrollTop - scroller.clientHeight === 0 || !hasScrolled;
|
|
598
|
+
model.sync(this._adapter);
|
|
599
|
+
if (autoScroll) {
|
|
600
|
+
scrollToBottom(true);
|
|
601
|
+
}
|
|
602
|
+
}));
|
|
603
|
+
}
|
|
308
604
|
}),
|
|
309
605
|
EditorView.theme({
|
|
310
606
|
".cm-scroller": {
|
|
@@ -339,9 +635,6 @@ var transcript = ({ model, started, renderButton }) => {
|
|
|
339
635
|
];
|
|
340
636
|
};
|
|
341
637
|
var TimestampMarker = class extends GutterMarker {
|
|
342
|
-
constructor(_line, _timestamp, _started) {
|
|
343
|
-
super(), this._line = _line, this._timestamp = _timestamp, this._started = _started;
|
|
344
|
-
}
|
|
345
638
|
eq(other) {
|
|
346
639
|
return other._timestamp === this._timestamp;
|
|
347
640
|
}
|
|
@@ -359,6 +652,9 @@ var TimestampMarker = class extends GutterMarker {
|
|
|
359
652
|
};
|
|
360
653
|
return el;
|
|
361
654
|
}
|
|
655
|
+
constructor(_line, _timestamp, _started) {
|
|
656
|
+
super(), _define_property2(this, "_line", void 0), _define_property2(this, "_timestamp", void 0), _define_property2(this, "_started", void 0), this._line = _line, this._timestamp = _timestamp, this._started = _started;
|
|
657
|
+
}
|
|
362
658
|
};
|
|
363
659
|
var getStartTime = (started, message) => {
|
|
364
660
|
if (started) {
|
|
@@ -399,7 +695,7 @@ var renderMarkdown = (identities) => (message, index, debug = false) => {
|
|
|
399
695
|
""
|
|
400
696
|
];
|
|
401
697
|
};
|
|
402
|
-
var
|
|
698
|
+
var TranscriptView = ({ classNames, transcript: object, space, model, attendableId, ignoreAttention }) => {
|
|
403
699
|
var _effect = _useSignals();
|
|
404
700
|
try {
|
|
405
701
|
const { themeMode } = useThemeContext();
|
|
@@ -408,7 +704,8 @@ var Transcript = ({ classNames, transcript: object, space, model, attendableId,
|
|
|
408
704
|
extensions: [
|
|
409
705
|
createBasicExtensions({
|
|
410
706
|
readOnly: true,
|
|
411
|
-
lineWrapping: true
|
|
707
|
+
lineWrapping: true,
|
|
708
|
+
search: true
|
|
412
709
|
}),
|
|
413
710
|
createMarkdownExtensions({
|
|
414
711
|
themeMode
|
|
@@ -444,284 +741,6 @@ var Transcript = ({ classNames, transcript: object, space, model, attendableId,
|
|
|
444
741
|
}
|
|
445
742
|
};
|
|
446
743
|
|
|
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
744
|
// src/components/TranscriptContainer.tsx
|
|
726
745
|
var TranscriptionContainer = ({ transcript: transcript2 }) => {
|
|
727
746
|
var _effect = _useSignals2();
|
|
@@ -735,7 +754,7 @@ var TranscriptionContainer = ({ transcript: transcript2 }) => {
|
|
|
735
754
|
const model = useQueueModelAdapter(renderMarkdown(members), queue);
|
|
736
755
|
return /* @__PURE__ */ React2.createElement(StackItem.Content, {
|
|
737
756
|
classNames: "container-max-width pli-2"
|
|
738
|
-
}, /* @__PURE__ */ React2.createElement(
|
|
757
|
+
}, /* @__PURE__ */ React2.createElement(TranscriptView, {
|
|
739
758
|
attendableId,
|
|
740
759
|
space,
|
|
741
760
|
model,
|
|
@@ -749,7 +768,7 @@ var TranscriptContainer_default = TranscriptionContainer;
|
|
|
749
768
|
|
|
750
769
|
export {
|
|
751
770
|
renderMarkdown,
|
|
752
|
-
|
|
771
|
+
TranscriptView,
|
|
753
772
|
useAudioFile,
|
|
754
773
|
useAudioTrack,
|
|
755
774
|
useQueueModelAdapter,
|
|
@@ -757,8 +776,9 @@ export {
|
|
|
757
776
|
useVoiceInput,
|
|
758
777
|
TranscriptionContainer,
|
|
759
778
|
TranscriptContainer_default,
|
|
779
|
+
BlueprintDefinition,
|
|
760
780
|
IntentResolver,
|
|
761
781
|
ReactSurface,
|
|
762
782
|
Transcriber
|
|
763
783
|
};
|
|
764
|
-
//# sourceMappingURL=chunk-
|
|
784
|
+
//# sourceMappingURL=chunk-DT3AOC3E.mjs.map
|