@dxos/plugin-transcription 0.8.4-main.2e9d522 → 0.8.4-main.3eb6e50203
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-MV3JBKLS.mjs +12 -0
- package/dist/lib/browser/blueprint-definition-K3E72ZBC.mjs +19 -0
- package/dist/lib/browser/blueprint-definition-K3E72ZBC.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +9 -0
- package/dist/lib/browser/chunk-AV44VISC.mjs +148 -0
- package/dist/lib/browser/chunk-AV44VISC.mjs.map +7 -0
- package/dist/lib/browser/chunk-HOOPZ7EM.mjs +35 -0
- package/dist/lib/browser/chunk-HOOPZ7EM.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5KPYIC3N.mjs → chunk-K3JJ46VV.mjs} +359 -424
- package/dist/lib/browser/chunk-K3JJ46VV.mjs.map +7 -0
- package/dist/lib/browser/chunk-Q5OC3WVG.mjs +72 -0
- package/dist/lib/browser/chunk-Q5OC3WVG.mjs.map +7 -0
- package/dist/lib/browser/{chunk-4FJIYH7T.mjs → chunk-RUKY36XW.mjs} +2 -2
- package/dist/lib/browser/{chunk-FFEPEPCU.mjs → chunk-TKFU53OZ.mjs} +64 -99
- package/dist/lib/browser/chunk-TKFU53OZ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +63 -70
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-GLEBGPKH.mjs +22 -0
- package/dist/lib/browser/operation-resolver-GLEBGPKH.mjs.map +7 -0
- package/dist/lib/browser/react-surface-AWZ2A5WZ.mjs +35 -0
- package/dist/lib/browser/react-surface-AWZ2A5WZ.mjs.map +7 -0
- package/dist/lib/browser/{transcriber-PXT4QBFY.mjs → transcriber-SLVQP76E.mjs} +17 -13
- package/dist/lib/browser/transcriber-SLVQP76E.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +8 -8
- package/dist/lib/node-esm/{TranscriptContainer-VBAOM5DG.mjs → TranscriptContainer-7M43UAZ2.mjs} +5 -4
- package/dist/lib/node-esm/TranscriptContainer-7M43UAZ2.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-2WIDDA3Y.mjs +20 -0
- package/dist/lib/node-esm/blueprint-definition-2WIDDA3Y.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +10 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4BFY6P2D.mjs +73 -0
- package/dist/lib/node-esm/chunk-4BFY6P2D.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HT3W7LDP.mjs → chunk-EPC27WWV.mjs} +64 -99
- package/dist/lib/node-esm/chunk-EPC27WWV.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NVM2QUMX.mjs +37 -0
- package/dist/lib/node-esm/chunk-NVM2QUMX.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-Y2B4HWSS.mjs → chunk-SNZAN34I.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-TJKAO7VR.mjs → chunk-TIUYXGQN.mjs} +359 -424
- package/dist/lib/node-esm/chunk-TIUYXGQN.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-TTJBW7CY.mjs +149 -0
- package/dist/lib/node-esm/chunk-TTJBW7CY.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +63 -70
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-SMCFTUFM.mjs +23 -0
- package/dist/lib/node-esm/operation-resolver-SMCFTUFM.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-YBBXC4W5.mjs +36 -0
- package/dist/lib/node-esm/react-surface-YBBXC4W5.mjs.map +7 -0
- package/dist/lib/node-esm/{transcriber-YUTEVANE.mjs → transcriber-BO2N3UQ4.mjs} +17 -13
- package/dist/lib/node-esm/transcriber-BO2N3UQ4.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +8 -8
- package/dist/types/src/TranscriptionPlugin.d.ts +2 -1
- package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/transcription-blueprint.d.ts +21 -0
- package/dist/types/src/blueprints/transcription-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +10 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +4 -4
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-handler/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts +5 -0
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/transcriber/index.d.ts +3 -0
- package/dist/types/src/capabilities/transcriber/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/transcriber/transcriber.d.ts +9 -0
- package/dist/types/src/capabilities/transcriber/transcriber.d.ts.map +1 -0
- package/dist/types/src/components/Transcript/Transcript.d.ts +7 -10
- package/dist/types/src/components/Transcript/Transcript.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts +34 -18
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts +12 -12
- 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 +4 -6
- package/dist/types/src/components/TranscriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts +8 -7
- 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 +10 -9
- 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 +11 -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/useQueueModelAdapter.d.ts +1 -1
- package/dist/types/src/hooks/useQueueModelAdapter.d.ts.map +1 -1
- package/dist/types/src/hooks/useTranscriber.d.ts +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/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/message-normalizer.d.ts +5 -5
- package/dist/types/src/segments-normalization/message-normalizer.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/normalization.d.ts +503 -398
- 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 +11 -11
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/transcriber/media-stream-recorder.d.ts +3 -3
- package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.d.ts +4 -4
- package/dist/types/src/transcriber/transcriber.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcription-manager.d.ts +12 -13
- package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
- package/dist/types/src/types/TranscriptAction.d.ts +25 -0
- package/dist/types/src/types/TranscriptAction.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +18 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -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/src/util/index.d.ts +1 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/render-byline.d.ts +4 -0
- package/dist/types/src/util/render-byline.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +86 -70
- package/src/TranscriptionPlugin.tsx +39 -57
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/transcription-blueprint.ts +25 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +24 -0
- package/src/capabilities/blueprint-definition/index.ts +7 -0
- package/src/capabilities/index.ts +4 -7
- package/src/capabilities/operation-handler/index.ts +7 -0
- package/src/capabilities/operation-handler/operation-handler.ts +25 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +25 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +28 -0
- package/src/capabilities/transcriber/index.ts +7 -0
- package/src/capabilities/transcriber/transcriber.ts +85 -0
- package/src/components/Transcript/Transcript.stories.tsx +59 -55
- package/src/components/Transcript/Transcript.tsx +25 -59
- package/src/components/Transcript/deprecated/OldTranscript.tsx +11 -11
- package/src/components/Transcript/transcript-extension.ts +11 -44
- package/src/components/TranscriptContainer.tsx +17 -18
- package/src/components/stories/FileTranscription.stories.tsx +65 -58
- package/src/components/stories/KeyWordRecognition.stories.tsx +17 -13
- package/src/components/stories/MicrophoneTranscription.stories.tsx +79 -79
- package/src/components/stories/TranscriptionStory.tsx +14 -14
- package/src/functions/index.ts +6 -0
- package/src/functions/open.ts +37 -0
- package/src/functions/summarize.ts +103 -0
- package/src/hooks/useAudioFile.ts +49 -53
- package/src/hooks/useQueueModelAdapter.ts +1 -1
- package/src/hooks/useTranscriber.ts +8 -3
- package/src/hooks/useVoiceInput.ts +4 -3
- package/src/index.ts +1 -1
- package/src/meta.ts +9 -6
- package/src/model/model.test.ts +21 -15
- package/src/segments-normalization/message-normalizer.ts +19 -14
- package/src/segments-normalization/normalization.test.ts +10 -15
- package/src/segments-normalization/normalization.ts +43 -42
- package/src/segments-normalization/utils.ts +2 -2
- package/src/testing/testing.ts +35 -25
- package/src/transcriber/media-stream-recorder.ts +4 -4
- package/src/transcriber/transcriber.browser.test.ts +6 -5
- package/src/transcriber/transcriber.ts +8 -7
- package/src/transcriber/transcription-manager.ts +37 -52
- package/src/types/TranscriptAction.ts +32 -0
- package/src/types/capabilities.ts +33 -0
- package/src/types/index.ts +3 -1
- package/src/types/types.ts +0 -23
- package/src/util/index.ts +1 -0
- package/src/util/render-byline.ts +33 -0
- 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 +0 -16
- 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 +0 -34
- 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 +0 -17
- 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 +0 -35
- 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/capabilities/capabilities.d.ts +0 -17
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/transcriber.d.ts +0 -8
- package/dist/types/src/capabilities/transcriber.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -41
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/capabilities.ts +0 -33
- package/src/capabilities/intent-resolver.ts +0 -24
- package/src/capabilities/react-surface.tsx +0 -22
- package/src/capabilities/transcriber.ts +0 -76
- package/src/types/schema.ts +0 -41
- /package/dist/lib/browser/{TranscriptContainer-6WCKCXQ6.mjs.map → TranscriptContainer-MV3JBKLS.mjs.map} +0 -0
- /package/dist/lib/{node-esm/TranscriptContainer-VBAOM5DG.mjs.map → browser/blueprints/index.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-4FJIYH7T.mjs.map → chunk-RUKY36XW.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-Y2B4HWSS.mjs.map → chunk-SNZAN34I.mjs.map} +0 -0
|
@@ -1,36 +1,144 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderByline
|
|
3
|
+
} from "./chunk-HOOPZ7EM.mjs";
|
|
1
4
|
import {
|
|
2
5
|
TranscriptionCapabilities
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-Q5OC3WVG.mjs";
|
|
4
7
|
|
|
5
8
|
// src/components/TranscriptContainer.tsx
|
|
6
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
7
9
|
import React2 from "react";
|
|
8
|
-
import {
|
|
10
|
+
import { Obj } from "@dxos/echo";
|
|
9
11
|
import { useMembers, useQueue } from "@dxos/react-client/echo";
|
|
10
|
-
import {
|
|
12
|
+
import { Layout } from "@dxos/react-ui";
|
|
11
13
|
|
|
12
|
-
// src/
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
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
|
+
};
|
|
19
101
|
|
|
20
|
-
// src/
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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";
|
|
26
133
|
|
|
27
134
|
// src/model/model.ts
|
|
28
135
|
import { Text } from "@codemirror/state";
|
|
29
136
|
import { Event } from "@dxos/async";
|
|
30
137
|
import { invariant } from "@dxos/invariant";
|
|
31
|
-
import { log } from "@dxos/log";
|
|
32
|
-
var
|
|
138
|
+
import { log as log2 } from "@dxos/log";
|
|
139
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/model/model.ts";
|
|
33
140
|
var DocumentAdapter = class {
|
|
141
|
+
_view;
|
|
34
142
|
constructor(_view) {
|
|
35
143
|
this._view = _view;
|
|
36
144
|
}
|
|
@@ -39,13 +147,13 @@ var DocumentAdapter = class {
|
|
|
39
147
|
return this._view.state.doc.lines - 1;
|
|
40
148
|
}
|
|
41
149
|
replaceLines(from, remove, insert) {
|
|
42
|
-
|
|
150
|
+
log2("replaceLines", {
|
|
43
151
|
count: this._view.state.doc.lines,
|
|
44
152
|
from,
|
|
45
153
|
remove,
|
|
46
154
|
insert
|
|
47
155
|
}, {
|
|
48
|
-
F:
|
|
156
|
+
F: __dxlog_file2,
|
|
49
157
|
L: 39,
|
|
50
158
|
S: this,
|
|
51
159
|
C: (f, a) => f(...a)
|
|
@@ -67,13 +175,19 @@ var DocumentAdapter = class {
|
|
|
67
175
|
}
|
|
68
176
|
};
|
|
69
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();
|
|
70
189
|
constructor(_renderer, initialChunks = []) {
|
|
71
190
|
this._renderer = _renderer;
|
|
72
|
-
this._chunks = [];
|
|
73
|
-
this._chunkLineCounts = /* @__PURE__ */ new Map();
|
|
74
|
-
this._lineToChunk = /* @__PURE__ */ new Map();
|
|
75
|
-
this._changes = [];
|
|
76
|
-
this.update = new Event();
|
|
77
191
|
initialChunks.forEach((chunk) => {
|
|
78
192
|
this.appendChunk(chunk);
|
|
79
193
|
});
|
|
@@ -120,7 +234,7 @@ var SerializationModel = class {
|
|
|
120
234
|
updateChunk(chunk) {
|
|
121
235
|
const index = this._chunks.findIndex((c) => c.id === chunk.id);
|
|
122
236
|
invariant(index !== -1, void 0, {
|
|
123
|
-
F:
|
|
237
|
+
F: __dxlog_file2,
|
|
124
238
|
L: 147,
|
|
125
239
|
S: this,
|
|
126
240
|
A: [
|
|
@@ -140,7 +254,7 @@ var SerializationModel = class {
|
|
|
140
254
|
deleteBlock(id) {
|
|
141
255
|
const index = this._chunks.findIndex((c) => c.id === id);
|
|
142
256
|
invariant(index !== -1, void 0, {
|
|
143
|
-
F:
|
|
257
|
+
F: __dxlog_file2,
|
|
144
258
|
L: 156,
|
|
145
259
|
S: this,
|
|
146
260
|
A: [
|
|
@@ -161,10 +275,10 @@ var SerializationModel = class {
|
|
|
161
275
|
* Syncs the tracked changes with the ChunkDocument.
|
|
162
276
|
*/
|
|
163
277
|
sync(document2) {
|
|
164
|
-
|
|
278
|
+
log2("sync", {
|
|
165
279
|
changes: this._changes
|
|
166
280
|
}, {
|
|
167
|
-
F:
|
|
281
|
+
F: __dxlog_file2,
|
|
168
282
|
L: 167,
|
|
169
283
|
S: this,
|
|
170
284
|
C: (f, a) => f(...a)
|
|
@@ -217,361 +331,7 @@ var SerializationModel = class {
|
|
|
217
331
|
}
|
|
218
332
|
};
|
|
219
333
|
|
|
220
|
-
// src/components/Transcript/transcript-extension.ts
|
|
221
|
-
var transcript = ({ model, started, renderButton }) => {
|
|
222
|
-
return [
|
|
223
|
-
// Show timestamps in the gutter.
|
|
224
|
-
gutter({
|
|
225
|
-
class: "cm-timestamp-gutter",
|
|
226
|
-
lineMarkerChange: (update) => update.docChanged || update.viewportChanged,
|
|
227
|
-
markers: (view) => {
|
|
228
|
-
const start = getStartTime(started, model.chunks[0]);
|
|
229
|
-
const builder = new RangeSetBuilder();
|
|
230
|
-
for (const { from, to } of view.visibleRanges) {
|
|
231
|
-
let line = view.state.doc.lineAt(from);
|
|
232
|
-
while (line.from <= to) {
|
|
233
|
-
const block = model.getChunkAtLine(line.number)?.blocks[0];
|
|
234
|
-
const timestamp = block?._tag === "transcript" && block.started;
|
|
235
|
-
if (timestamp) {
|
|
236
|
-
builder.add(line.from, line.from, new TimestampMarker(line.number, new Date(timestamp), start));
|
|
237
|
-
}
|
|
238
|
-
if (line.to + 1 > view.state.doc.length) {
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
line = view.state.doc.lineAt(line.to + 1);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return builder.finish();
|
|
245
|
-
}
|
|
246
|
-
}),
|
|
247
|
-
// Listen for model updates.
|
|
248
|
-
ViewPlugin.fromClass(class {
|
|
249
|
-
constructor(view) {
|
|
250
|
-
this._initialized = false;
|
|
251
|
-
this._adapter = new DocumentAdapter(view);
|
|
252
|
-
const scroller = view.scrollDOM;
|
|
253
|
-
let isAutoScrolling = false;
|
|
254
|
-
let hasScrolled = false;
|
|
255
|
-
let timeout;
|
|
256
|
-
const scrollToBottom = (smooth = false) => {
|
|
257
|
-
scroller.style.scrollBehavior = smooth ? "smooth" : "";
|
|
258
|
-
scroller.classList.add("cm-hide-scrollbar");
|
|
259
|
-
isAutoScrolling = true;
|
|
260
|
-
clearTimeout(timeout);
|
|
261
|
-
timeout = setTimeout(() => {
|
|
262
|
-
this._controls?.classList.add("opacity-0");
|
|
263
|
-
scroller.classList.remove("cm-hide-scrollbar");
|
|
264
|
-
isAutoScrolling = false;
|
|
265
|
-
}, 500);
|
|
266
|
-
view.dispatch({
|
|
267
|
-
effects: EditorView.scrollIntoView(view.state.doc.length, {
|
|
268
|
-
y: "end"
|
|
269
|
-
})
|
|
270
|
-
});
|
|
271
|
-
};
|
|
272
|
-
if (renderButton) {
|
|
273
|
-
this._controls = document.createElement("div");
|
|
274
|
-
this._controls.classList.add("cm-controls", "transition-opacity", "duration-300", "opacity-0");
|
|
275
|
-
view.dom.appendChild(this._controls);
|
|
276
|
-
renderButton(this._controls, {
|
|
277
|
-
onClick: () => {
|
|
278
|
-
scrollToBottom(false);
|
|
279
|
-
}
|
|
280
|
-
}, view);
|
|
281
|
-
}
|
|
282
|
-
this._cleanup = combine(addEventListener(view.scrollDOM, "scroll", () => {
|
|
283
|
-
if (!isAutoScrolling) {
|
|
284
|
-
hasScrolled = true;
|
|
285
|
-
this._controls?.classList.remove("opacity-0");
|
|
286
|
-
}
|
|
287
|
-
}), model.update.on(() => {
|
|
288
|
-
const autoScroll = scroller.scrollHeight - scroller.scrollTop - scroller.clientHeight === 0 || !hasScrolled;
|
|
289
|
-
model.sync(this._adapter);
|
|
290
|
-
if (autoScroll) {
|
|
291
|
-
scrollToBottom(true);
|
|
292
|
-
}
|
|
293
|
-
}));
|
|
294
|
-
}
|
|
295
|
-
update(update) {
|
|
296
|
-
if (!this._initialized) {
|
|
297
|
-
this._initialized = true;
|
|
298
|
-
setTimeout(() => {
|
|
299
|
-
model.sync(this._adapter);
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
destroy() {
|
|
304
|
-
this._controls?.remove();
|
|
305
|
-
this._cleanup();
|
|
306
|
-
}
|
|
307
|
-
}),
|
|
308
|
-
EditorView.theme({
|
|
309
|
-
".cm-scroller": {
|
|
310
|
-
overflowY: "scroll"
|
|
311
|
-
},
|
|
312
|
-
".cm-hide-scrollbar": {
|
|
313
|
-
scrollbarWidth: "none",
|
|
314
|
-
"-ms-overflow-style": "none"
|
|
315
|
-
},
|
|
316
|
-
".cm-hide-scrollbar::-webkit-scrollbar": {
|
|
317
|
-
display: "none"
|
|
318
|
-
},
|
|
319
|
-
".cm-controls": {
|
|
320
|
-
position: "absolute",
|
|
321
|
-
bottom: "0.5rem",
|
|
322
|
-
right: "0.5rem",
|
|
323
|
-
zIndex: 1e3
|
|
324
|
-
},
|
|
325
|
-
".cm-line": {
|
|
326
|
-
paddingRight: "1rem"
|
|
327
|
-
},
|
|
328
|
-
".cm-timestamp-gutter": {
|
|
329
|
-
width: "6rem",
|
|
330
|
-
paddingRight: "1rem"
|
|
331
|
-
},
|
|
332
|
-
".cm-timestamp-gutter > .cm-gutterElement > div": {
|
|
333
|
-
display: "inline-flex",
|
|
334
|
-
textAlign: "right",
|
|
335
|
-
padding: "3px"
|
|
336
|
-
}
|
|
337
|
-
})
|
|
338
|
-
];
|
|
339
|
-
};
|
|
340
|
-
var TimestampMarker = class extends GutterMarker {
|
|
341
|
-
constructor(_line, _timestamp, _started) {
|
|
342
|
-
super(), this._line = _line, this._timestamp = _timestamp, this._started = _started;
|
|
343
|
-
}
|
|
344
|
-
eq(other) {
|
|
345
|
-
return other._timestamp === this._timestamp;
|
|
346
|
-
}
|
|
347
|
-
toDOM(view) {
|
|
348
|
-
const el = document.createElement("div");
|
|
349
|
-
el.className = "text-sm text-subdued hover:bg-hoverSurface cursor-pointer";
|
|
350
|
-
el.textContent = formatTimestamp(this._timestamp, this._started);
|
|
351
|
-
el.onclick = () => {
|
|
352
|
-
const pos = view.state.doc.line(this._line).from;
|
|
353
|
-
view.dispatch({
|
|
354
|
-
effects: EditorView.scrollIntoView(pos, {
|
|
355
|
-
y: "start"
|
|
356
|
-
})
|
|
357
|
-
});
|
|
358
|
-
};
|
|
359
|
-
return el;
|
|
360
|
-
}
|
|
361
|
-
};
|
|
362
|
-
var getStartTime = (started, message) => {
|
|
363
|
-
if (started) {
|
|
364
|
-
return started;
|
|
365
|
-
}
|
|
366
|
-
if (message?.blocks[0]?._tag === "transcript" && message.blocks[0].started) {
|
|
367
|
-
return new Date(message.blocks[0].started);
|
|
368
|
-
}
|
|
369
|
-
return void 0;
|
|
370
|
-
};
|
|
371
|
-
var formatTimestamp = (timestamp, relative) => {
|
|
372
|
-
if (relative) {
|
|
373
|
-
const pad = (n = 0) => String(n).padStart(2, "0");
|
|
374
|
-
const { hours, minutes, seconds } = intervalToDuration({
|
|
375
|
-
start: relative,
|
|
376
|
-
end: timestamp
|
|
377
|
-
});
|
|
378
|
-
return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;
|
|
379
|
-
} else {
|
|
380
|
-
return format(timestamp, "HH:mm:ss");
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
// src/components/Transcript/Transcript.tsx
|
|
385
|
-
var renderMarkdown = (identities) => (message, index, debug = false) => {
|
|
386
|
-
if (message.sender.role === "assistant") {
|
|
387
|
-
return [
|
|
388
|
-
message.blocks.find((block) => block._tag === "transcript")?.text ?? "",
|
|
389
|
-
""
|
|
390
|
-
];
|
|
391
|
-
}
|
|
392
|
-
const identity = identities.find((identity2) => identity2.did === message.sender.identityDid);
|
|
393
|
-
const name = identity?.profile?.displayName ?? message.sender.contact?.target?.fullName ?? message.sender.name ?? message.sender.email ?? message.sender.identityDid;
|
|
394
|
-
const blocks = message.blocks.filter((block) => block._tag === "transcript");
|
|
395
|
-
return [
|
|
396
|
-
`###### ${name}` + (debug ? ` [${index}]:${message.id}` : ""),
|
|
397
|
-
blocks.map((block) => block.text.trim()).join(" "),
|
|
398
|
-
""
|
|
399
|
-
];
|
|
400
|
-
};
|
|
401
|
-
var Transcript = ({ classNames, transcript: object, space, model, attendableId, ignoreAttention }) => {
|
|
402
|
-
var _effect = _useSignals();
|
|
403
|
-
try {
|
|
404
|
-
const { themeMode } = useThemeContext();
|
|
405
|
-
const { parentRef } = useTextEditor(() => {
|
|
406
|
-
return {
|
|
407
|
-
extensions: [
|
|
408
|
-
createBasicExtensions({
|
|
409
|
-
readOnly: true,
|
|
410
|
-
lineWrapping: true
|
|
411
|
-
}),
|
|
412
|
-
createMarkdownExtensions({
|
|
413
|
-
themeMode
|
|
414
|
-
}),
|
|
415
|
-
createThemeExtensions({
|
|
416
|
-
themeMode
|
|
417
|
-
}),
|
|
418
|
-
decorateMarkdown(),
|
|
419
|
-
space && preview(),
|
|
420
|
-
transcript({
|
|
421
|
-
model,
|
|
422
|
-
started: object?.started ? new Date(object.started) : void 0,
|
|
423
|
-
renderButton: createRenderer(({ onClick }) => /* @__PURE__ */ React.createElement(IconButton, {
|
|
424
|
-
icon: "ph--arrow-line-down--regular",
|
|
425
|
-
iconOnly: true,
|
|
426
|
-
label: "Scroll to bottom",
|
|
427
|
-
onClick
|
|
428
|
-
}))
|
|
429
|
-
})
|
|
430
|
-
].filter(isNotFalsy)
|
|
431
|
-
};
|
|
432
|
-
}, [
|
|
433
|
-
space,
|
|
434
|
-
model
|
|
435
|
-
]);
|
|
436
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
437
|
-
ref: parentRef,
|
|
438
|
-
className: mx("flex grow overflow-hidden", editorWidth, classNames),
|
|
439
|
-
"data-popover-collision-boundary": true
|
|
440
|
-
});
|
|
441
|
-
} finally {
|
|
442
|
-
_effect.f();
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
// src/hooks/useAudioFile.ts
|
|
447
|
-
import { useEffect, useState } from "react";
|
|
448
|
-
import { scheduleTask } from "@dxos/async";
|
|
449
|
-
import { Context } from "@dxos/context";
|
|
450
|
-
import { log as log2 } from "@dxos/log";
|
|
451
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/hooks/useAudioFile.ts";
|
|
452
|
-
var useAudioFile = (audioUrl, constraints) => {
|
|
453
|
-
const [{ audio, stream, track }, setStream] = useState({});
|
|
454
|
-
useEffect(() => {
|
|
455
|
-
const ctx = new Context(void 0, {
|
|
456
|
-
F: __dxlog_file2,
|
|
457
|
-
L: 20
|
|
458
|
-
});
|
|
459
|
-
scheduleTask(ctx, async () => {
|
|
460
|
-
const response = await fetch(audioUrl);
|
|
461
|
-
const blob = await response.blob();
|
|
462
|
-
const objectUrl = URL.createObjectURL(blob);
|
|
463
|
-
ctx.onDispose(() => {
|
|
464
|
-
URL.revokeObjectURL(objectUrl);
|
|
465
|
-
});
|
|
466
|
-
const audio2 = new Audio();
|
|
467
|
-
audio2.src = objectUrl;
|
|
468
|
-
await new Promise((resolve, reject) => {
|
|
469
|
-
audio2.addEventListener("error", (err) => {
|
|
470
|
-
log2.error("error", {
|
|
471
|
-
err
|
|
472
|
-
}, {
|
|
473
|
-
F: __dxlog_file2,
|
|
474
|
-
L: 37,
|
|
475
|
-
S: void 0,
|
|
476
|
-
C: (f, a) => f(...a)
|
|
477
|
-
});
|
|
478
|
-
reject(err);
|
|
479
|
-
}, {
|
|
480
|
-
once: true
|
|
481
|
-
});
|
|
482
|
-
audio2.addEventListener("canplay", async () => {
|
|
483
|
-
log2.info("starting...", void 0, {
|
|
484
|
-
F: __dxlog_file2,
|
|
485
|
-
L: 45,
|
|
486
|
-
S: void 0,
|
|
487
|
-
C: (f, a) => f(...a)
|
|
488
|
-
});
|
|
489
|
-
try {
|
|
490
|
-
await audio2.play();
|
|
491
|
-
resolve();
|
|
492
|
-
} catch (playError) {
|
|
493
|
-
log2.error("Play failed", {
|
|
494
|
-
playError
|
|
495
|
-
}, {
|
|
496
|
-
F: __dxlog_file2,
|
|
497
|
-
L: 51,
|
|
498
|
-
S: void 0,
|
|
499
|
-
C: (f, a) => f(...a)
|
|
500
|
-
});
|
|
501
|
-
resolve();
|
|
502
|
-
}
|
|
503
|
-
}, {
|
|
504
|
-
once: true
|
|
505
|
-
});
|
|
506
|
-
audio2.load();
|
|
507
|
-
});
|
|
508
|
-
const audioCtx = new AudioContext();
|
|
509
|
-
if (audioCtx.state === "suspended") {
|
|
510
|
-
await audioCtx.resume();
|
|
511
|
-
}
|
|
512
|
-
const destination = audioCtx.createMediaStreamDestination();
|
|
513
|
-
destination.channelCount = 1;
|
|
514
|
-
const source = audioCtx.createMediaElementSource(audio2);
|
|
515
|
-
source.connect(destination);
|
|
516
|
-
const track2 = destination.stream.getAudioTracks()[0];
|
|
517
|
-
if (constraints) {
|
|
518
|
-
await track2.applyConstraints(constraints).catch((err) => log2.catch(err, void 0, {
|
|
519
|
-
F: __dxlog_file2,
|
|
520
|
-
L: 75,
|
|
521
|
-
S: void 0,
|
|
522
|
-
C: (f, a) => f(...a)
|
|
523
|
-
}));
|
|
524
|
-
}
|
|
525
|
-
setStream({
|
|
526
|
-
audio: audio2,
|
|
527
|
-
stream: destination.stream,
|
|
528
|
-
track: destination.stream.getAudioTracks()[0]
|
|
529
|
-
});
|
|
530
|
-
});
|
|
531
|
-
return () => {
|
|
532
|
-
void ctx.dispose();
|
|
533
|
-
};
|
|
534
|
-
}, [
|
|
535
|
-
audioUrl
|
|
536
|
-
]);
|
|
537
|
-
return {
|
|
538
|
-
audio,
|
|
539
|
-
stream,
|
|
540
|
-
track
|
|
541
|
-
};
|
|
542
|
-
};
|
|
543
|
-
|
|
544
|
-
// src/hooks/useAudioTrack.ts
|
|
545
|
-
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
546
|
-
var useAudioTrack = (active, constraints) => {
|
|
547
|
-
const [track, setTrack] = useState2();
|
|
548
|
-
useEffect2(() => {
|
|
549
|
-
if (!active) {
|
|
550
|
-
track?.stop();
|
|
551
|
-
setTrack(void 0);
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
const initAudio = async () => {
|
|
555
|
-
const audio = new Audio();
|
|
556
|
-
audio.srcObject = await navigator.mediaDevices.getUserMedia({
|
|
557
|
-
audio: constraints ?? true
|
|
558
|
-
});
|
|
559
|
-
const [track2] = audio.srcObject.getAudioTracks();
|
|
560
|
-
if (track2) {
|
|
561
|
-
setTrack(track2);
|
|
562
|
-
}
|
|
563
|
-
};
|
|
564
|
-
if (active) {
|
|
565
|
-
void initAudio();
|
|
566
|
-
}
|
|
567
|
-
}, [
|
|
568
|
-
active
|
|
569
|
-
]);
|
|
570
|
-
return track;
|
|
571
|
-
};
|
|
572
|
-
|
|
573
334
|
// src/hooks/useQueueModelAdapter.ts
|
|
574
|
-
import { useEffect as useEffect3, useMemo, useState as useState3 } from "react";
|
|
575
335
|
var useQueueModelAdapter = (renderer, queue, initialChunks = []) => {
|
|
576
336
|
const model = useMemo(() => new SerializationModel(renderer, initialChunks), [
|
|
577
337
|
queue
|
|
@@ -621,15 +381,7 @@ var useQueueModelAdapter = (renderer, queue, initialChunks = []) => {
|
|
|
621
381
|
|
|
622
382
|
// src/hooks/useTranscriber.ts
|
|
623
383
|
import { useEffect as useEffect4, useMemo as useMemo2 } from "react";
|
|
624
|
-
import { useCapabilities } from "@dxos/app-framework";
|
|
625
|
-
|
|
626
|
-
// src/capabilities/index.ts
|
|
627
|
-
import { lazy } from "@dxos/app-framework";
|
|
628
|
-
var IntentResolver = lazy(() => import("./intent-resolver-3O33MMP5.mjs"));
|
|
629
|
-
var ReactSurface = lazy(() => import("./react-surface-E5D5AE3F.mjs"));
|
|
630
|
-
var Transcriber = lazy(() => import("./transcriber-PXT4QBFY.mjs"));
|
|
631
|
-
|
|
632
|
-
// src/hooks/useTranscriber.ts
|
|
384
|
+
import { useCapabilities } from "@dxos/app-framework/ui";
|
|
633
385
|
var useTranscriber = ({ audioStreamTrack, recorderConfig, transcriberConfig, onSegments }) => {
|
|
634
386
|
const [getTranscriber] = useCapabilities(TranscriptionCapabilities.Transcriber);
|
|
635
387
|
const transcriber = useMemo2(() => {
|
|
@@ -660,7 +412,7 @@ var useTranscriber = ({ audioStreamTrack, recorderConfig, transcriberConfig, onS
|
|
|
660
412
|
};
|
|
661
413
|
|
|
662
414
|
// src/hooks/useVoiceInput.ts
|
|
663
|
-
import {
|
|
415
|
+
import { useCallback, useEffect as useEffect5, useState as useState4 } from "react";
|
|
664
416
|
import { scheduleMicroTask } from "@dxos/async";
|
|
665
417
|
import { Context as Context2 } from "@dxos/context";
|
|
666
418
|
import { log as log3 } from "@dxos/log";
|
|
@@ -682,14 +434,14 @@ var useVoiceInput = ({ active, onUpdate }) => {
|
|
|
682
434
|
useEffect5(() => {
|
|
683
435
|
const ctx = new Context2(void 0, {
|
|
684
436
|
F: __dxlog_file3,
|
|
685
|
-
L:
|
|
437
|
+
L: 44
|
|
686
438
|
});
|
|
687
439
|
scheduleMicroTask(ctx, async () => {
|
|
688
440
|
if (active && transcriber) {
|
|
689
441
|
await transcriber.open();
|
|
690
442
|
log3.info("starting...", void 0, {
|
|
691
443
|
F: __dxlog_file3,
|
|
692
|
-
L:
|
|
444
|
+
L: 48,
|
|
693
445
|
S: void 0,
|
|
694
446
|
C: (f, a) => f(...a)
|
|
695
447
|
});
|
|
@@ -701,7 +453,7 @@ var useVoiceInput = ({ active, onUpdate }) => {
|
|
|
701
453
|
await transcriber?.close();
|
|
702
454
|
log3.info("stopped", void 0, {
|
|
703
455
|
F: __dxlog_file3,
|
|
704
|
-
L:
|
|
456
|
+
L: 55,
|
|
705
457
|
S: void 0,
|
|
706
458
|
C: (f, a) => f(...a)
|
|
707
459
|
});
|
|
@@ -721,43 +473,226 @@ var useVoiceInput = ({ active, onUpdate }) => {
|
|
|
721
473
|
};
|
|
722
474
|
};
|
|
723
475
|
|
|
724
|
-
// src/components/
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
476
|
+
// src/components/Transcript/Transcript.tsx
|
|
477
|
+
import React from "react";
|
|
478
|
+
import { useThemeContext } from "@dxos/react-ui";
|
|
479
|
+
import { useTextEditor } from "@dxos/react-ui-editor";
|
|
480
|
+
import { autoScroll, createBasicExtensions, createMarkdownExtensions, createThemeExtensions, decorateMarkdown, editorSlots, preview } from "@dxos/ui-editor";
|
|
481
|
+
import { mx } from "@dxos/ui-theme";
|
|
482
|
+
import { isTruthy } from "@dxos/util";
|
|
483
|
+
|
|
484
|
+
// src/components/Transcript/transcript-extension.ts
|
|
485
|
+
import { RangeSetBuilder } from "@codemirror/state";
|
|
486
|
+
import { EditorView, GutterMarker, ViewPlugin, gutter } from "@codemirror/view";
|
|
487
|
+
import { format } from "date-fns/format";
|
|
488
|
+
import { intervalToDuration } from "date-fns/intervalToDuration";
|
|
489
|
+
import { addEventListener, combine } from "@dxos/async";
|
|
490
|
+
var transcript = ({ model, started }) => {
|
|
491
|
+
return [
|
|
492
|
+
// Show timestamps in the gutter.
|
|
493
|
+
gutter({
|
|
494
|
+
class: "cm-timestamp-gutter",
|
|
495
|
+
lineMarkerChange: (update) => update.docChanged || update.viewportChanged,
|
|
496
|
+
markers: (view) => {
|
|
497
|
+
const start = getStartTime(started, model.chunks[0]);
|
|
498
|
+
const builder = new RangeSetBuilder();
|
|
499
|
+
for (const { from, to } of view.visibleRanges) {
|
|
500
|
+
let line = view.state.doc.lineAt(from);
|
|
501
|
+
while (line.from <= to) {
|
|
502
|
+
const block = model.getChunkAtLine(line.number)?.blocks[0];
|
|
503
|
+
const timestamp = block?._tag === "transcript" && block.started;
|
|
504
|
+
if (timestamp) {
|
|
505
|
+
builder.add(line.from, line.from, new TimestampMarker(line.number, new Date(timestamp), start));
|
|
506
|
+
}
|
|
507
|
+
if (line.to + 1 > view.state.doc.length) {
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
line = view.state.doc.lineAt(line.to + 1);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return builder.finish();
|
|
514
|
+
}
|
|
515
|
+
}),
|
|
516
|
+
// Listen for model updates.
|
|
517
|
+
ViewPlugin.fromClass(class {
|
|
518
|
+
_controls;
|
|
519
|
+
_cleanup;
|
|
520
|
+
_adapter;
|
|
521
|
+
_initialized = false;
|
|
522
|
+
constructor(view) {
|
|
523
|
+
this._adapter = new DocumentAdapter(view);
|
|
524
|
+
const scroller = view.scrollDOM;
|
|
525
|
+
let isAutoScrolling = false;
|
|
526
|
+
let hasScrolled = false;
|
|
527
|
+
let timeout;
|
|
528
|
+
const scrollToBottom = (smooth = false) => {
|
|
529
|
+
scroller.style.scrollBehavior = smooth ? "smooth" : "";
|
|
530
|
+
scroller.classList.add("cm-hide-scrollbar");
|
|
531
|
+
isAutoScrolling = true;
|
|
532
|
+
clearTimeout(timeout);
|
|
533
|
+
timeout = setTimeout(() => {
|
|
534
|
+
this._controls?.classList.add("opacity-0");
|
|
535
|
+
scroller.classList.remove("cm-hide-scrollbar");
|
|
536
|
+
isAutoScrolling = false;
|
|
537
|
+
}, 500);
|
|
538
|
+
view.dispatch({
|
|
539
|
+
effects: EditorView.scrollIntoView(view.state.doc.length, {
|
|
540
|
+
y: "end"
|
|
541
|
+
})
|
|
542
|
+
});
|
|
543
|
+
};
|
|
544
|
+
this._cleanup = combine(addEventListener(view.scrollDOM, "scroll", () => {
|
|
545
|
+
if (!isAutoScrolling) {
|
|
546
|
+
hasScrolled = true;
|
|
547
|
+
this._controls?.classList.remove("opacity-0");
|
|
548
|
+
}
|
|
549
|
+
}), model.update.on(() => {
|
|
550
|
+
const autoScroll2 = scroller.scrollHeight - scroller.scrollTop - scroller.clientHeight === 0 || !hasScrolled;
|
|
551
|
+
model.sync(this._adapter);
|
|
552
|
+
if (autoScroll2) {
|
|
553
|
+
scrollToBottom(true);
|
|
554
|
+
}
|
|
555
|
+
}));
|
|
556
|
+
}
|
|
557
|
+
update(_update) {
|
|
558
|
+
if (!this._initialized) {
|
|
559
|
+
this._initialized = true;
|
|
560
|
+
setTimeout(() => {
|
|
561
|
+
model.sync(this._adapter);
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
destroy() {
|
|
566
|
+
this._controls?.remove();
|
|
567
|
+
this._cleanup();
|
|
568
|
+
}
|
|
569
|
+
}),
|
|
570
|
+
EditorView.theme({
|
|
571
|
+
".cm-gutters": {
|
|
572
|
+
backgroundColor: "var(--dx-baseSurface)"
|
|
573
|
+
},
|
|
574
|
+
".cm-timestamp-gutter": {
|
|
575
|
+
width: "6rem",
|
|
576
|
+
paddingLeft: "0.5rem",
|
|
577
|
+
paddingRight: "1rem"
|
|
578
|
+
},
|
|
579
|
+
".cm-timestamp-gutter > .cm-gutterElement > div": {
|
|
580
|
+
display: "inline-flex",
|
|
581
|
+
textAlign: "right",
|
|
582
|
+
padding: "3px"
|
|
583
|
+
}
|
|
584
|
+
})
|
|
585
|
+
];
|
|
586
|
+
};
|
|
587
|
+
var TimestampMarker = class extends GutterMarker {
|
|
588
|
+
_line;
|
|
589
|
+
_timestamp;
|
|
590
|
+
_started;
|
|
591
|
+
constructor(_line, _timestamp, _started) {
|
|
592
|
+
super(), this._line = _line, this._timestamp = _timestamp, this._started = _started;
|
|
593
|
+
}
|
|
594
|
+
eq(other) {
|
|
595
|
+
return this._timestamp === other._timestamp;
|
|
596
|
+
}
|
|
597
|
+
toDOM(view) {
|
|
598
|
+
const el = document.createElement("div");
|
|
599
|
+
el.className = "text-sm text-subdued hover:bg-hoverSurface cursor-pointer";
|
|
600
|
+
el.textContent = formatTimestamp(this._timestamp, this._started);
|
|
601
|
+
el.onclick = () => {
|
|
602
|
+
const pos = view.state.doc.line(this._line).from;
|
|
603
|
+
view.dispatch({
|
|
604
|
+
effects: EditorView.scrollIntoView(pos, {
|
|
605
|
+
y: "start"
|
|
606
|
+
})
|
|
607
|
+
});
|
|
608
|
+
};
|
|
609
|
+
return el;
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
var getStartTime = (started, message) => {
|
|
613
|
+
if (started) {
|
|
614
|
+
return started;
|
|
615
|
+
}
|
|
616
|
+
if (message?.blocks[0]?._tag === "transcript" && message.blocks[0].started) {
|
|
617
|
+
return new Date(message.blocks[0].started);
|
|
618
|
+
}
|
|
619
|
+
return void 0;
|
|
620
|
+
};
|
|
621
|
+
var formatTimestamp = (timestamp, relative) => {
|
|
622
|
+
if (relative) {
|
|
623
|
+
const pad = (n = 0) => String(n).padStart(2, "0");
|
|
624
|
+
const { hours, minutes, seconds } = intervalToDuration({
|
|
625
|
+
start: relative,
|
|
626
|
+
end: timestamp
|
|
733
627
|
});
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
}, /* @__PURE__ */ React2.createElement(Transcript, {
|
|
738
|
-
attendableId,
|
|
739
|
-
space,
|
|
740
|
-
model,
|
|
741
|
-
transcript: transcript2
|
|
742
|
-
}));
|
|
743
|
-
} finally {
|
|
744
|
-
_effect.f();
|
|
628
|
+
return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;
|
|
629
|
+
} else {
|
|
630
|
+
return format(timestamp, "HH:mm:ss");
|
|
745
631
|
}
|
|
746
632
|
};
|
|
633
|
+
|
|
634
|
+
// src/components/Transcript/Transcript.tsx
|
|
635
|
+
var TranscriptView = ({ classNames, transcript: object, model }) => {
|
|
636
|
+
const { themeMode } = useThemeContext();
|
|
637
|
+
const { parentRef } = useTextEditor(() => {
|
|
638
|
+
return {
|
|
639
|
+
extensions: [
|
|
640
|
+
createBasicExtensions({
|
|
641
|
+
readOnly: true,
|
|
642
|
+
lineWrapping: true,
|
|
643
|
+
search: true
|
|
644
|
+
}),
|
|
645
|
+
createMarkdownExtensions(),
|
|
646
|
+
createThemeExtensions({
|
|
647
|
+
themeMode,
|
|
648
|
+
slots: editorSlots
|
|
649
|
+
}),
|
|
650
|
+
decorateMarkdown(),
|
|
651
|
+
preview(),
|
|
652
|
+
transcript({
|
|
653
|
+
model,
|
|
654
|
+
started: object?.started ? new Date(object.started) : void 0
|
|
655
|
+
}),
|
|
656
|
+
autoScroll()
|
|
657
|
+
].filter(isTruthy)
|
|
658
|
+
};
|
|
659
|
+
}, [
|
|
660
|
+
model
|
|
661
|
+
]);
|
|
662
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
663
|
+
ref: parentRef,
|
|
664
|
+
className: mx("flex grow overflow-hidden container-max-width", classNames),
|
|
665
|
+
"data-popover-collision-boundary": true
|
|
666
|
+
});
|
|
667
|
+
};
|
|
668
|
+
|
|
669
|
+
// src/components/TranscriptContainer.tsx
|
|
670
|
+
var TranscriptionContainer = ({ role, subject: transcript2 }) => {
|
|
671
|
+
const attendableId = Obj.getDXN(transcript2).toString();
|
|
672
|
+
const db = Obj.getDatabase(transcript2);
|
|
673
|
+
const members = useMembers(db?.spaceId).map((member) => member.identity);
|
|
674
|
+
const queue = useQueue(transcript2.queue.dxn, {
|
|
675
|
+
pollInterval: 1e3
|
|
676
|
+
});
|
|
677
|
+
const model = useQueueModelAdapter(renderByline(members), queue);
|
|
678
|
+
return /* @__PURE__ */ React2.createElement(Layout.Main, {
|
|
679
|
+
role
|
|
680
|
+
}, /* @__PURE__ */ React2.createElement(TranscriptView, {
|
|
681
|
+
attendableId,
|
|
682
|
+
model,
|
|
683
|
+
transcript: transcript2
|
|
684
|
+
}));
|
|
685
|
+
};
|
|
747
686
|
var TranscriptContainer_default = TranscriptionContainer;
|
|
748
687
|
|
|
749
688
|
export {
|
|
750
|
-
|
|
751
|
-
Transcript,
|
|
689
|
+
TranscriptView,
|
|
752
690
|
useAudioFile,
|
|
753
691
|
useAudioTrack,
|
|
754
692
|
useQueueModelAdapter,
|
|
755
693
|
useTranscriber,
|
|
756
694
|
useVoiceInput,
|
|
757
695
|
TranscriptionContainer,
|
|
758
|
-
TranscriptContainer_default
|
|
759
|
-
IntentResolver,
|
|
760
|
-
ReactSurface,
|
|
761
|
-
Transcriber
|
|
696
|
+
TranscriptContainer_default
|
|
762
697
|
};
|
|
763
|
-
//# sourceMappingURL=chunk-
|
|
698
|
+
//# sourceMappingURL=chunk-K3JJ46VV.mjs.map
|