@dxos/plugin-transcription 0.8.2-staging.7ac8446 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/TranscriptContainer-PFKLKRPQ.mjs +11 -0
- package/dist/lib/browser/{chunk-YCZISX63.mjs → chunk-4KCUYW2F.mjs} +139 -95
- package/dist/lib/browser/chunk-4KCUYW2F.mjs.map +7 -0
- package/dist/lib/browser/{chunk-6ZR5MDK3.mjs → chunk-GOF7MJNV.mjs} +3 -3
- package/dist/lib/browser/{chunk-6ZR5MDK3.mjs.map → chunk-GOF7MJNV.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-K7FOYAXO.mjs → chunk-IGEKO7ZU.mjs} +2 -2
- package/dist/lib/browser/chunk-NODIXNQP.mjs +54 -0
- package/dist/lib/browser/chunk-NODIXNQP.mjs.map +7 -0
- package/dist/lib/browser/chunk-TJPJBE45.mjs +764 -0
- package/dist/lib/browser/chunk-TJPJBE45.mjs.map +7 -0
- package/dist/lib/browser/{chunk-YEPT334A.mjs → chunk-W2KNYJD6.mjs} +4 -4
- package/dist/lib/browser/chunk-W2KNYJD6.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +30 -216
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{intent-resolver-4R66ZCKT.mjs → intent-resolver-I2LJSQDR.mjs} +7 -11
- package/dist/lib/browser/intent-resolver-I2LJSQDR.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-FQUHU5G7.mjs → react-surface-ID2MLJHZ.mjs} +11 -9
- package/dist/lib/browser/react-surface-ID2MLJHZ.mjs.map +7 -0
- package/dist/lib/browser/transcriber-NA7CIFIT.mjs +56 -0
- package/dist/lib/browser/transcriber-NA7CIFIT.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -8
- package/dist/lib/node/{TranscriptContainer-QEYTTT2V.cjs → TranscriptContainer-LHMC7553.cjs} +9 -8
- package/dist/lib/node/TranscriptContainer-LHMC7553.cjs.map +7 -0
- package/dist/lib/node/chunk-3GS5UNO5.cjs +778 -0
- package/dist/lib/node/chunk-3GS5UNO5.cjs.map +7 -0
- package/dist/lib/node/{chunk-LP4FG423.cjs → chunk-5J3FBCON.cjs} +5 -5
- package/dist/lib/node/{chunk-NVZWGFJL.cjs → chunk-AFUZI63A.cjs} +6 -6
- package/dist/lib/node/{chunk-NVZWGFJL.cjs.map → chunk-AFUZI63A.cjs.map} +1 -1
- package/dist/lib/node/chunk-EIMUQYCZ.cjs +74 -0
- package/dist/lib/node/chunk-EIMUQYCZ.cjs.map +7 -0
- package/dist/lib/node/{chunk-CZMLKKWT.cjs → chunk-FKDJNJ57.cjs} +8 -8
- package/dist/lib/node/chunk-FKDJNJ57.cjs.map +7 -0
- package/dist/lib/node/{chunk-FCCJALOT.cjs → chunk-ZFTXJZXH.cjs} +138 -95
- package/dist/lib/node/chunk-ZFTXJZXH.cjs.map +7 -0
- package/dist/lib/node/index.cjs +59 -251
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/{intent-resolver-WMMCOUEH.cjs → intent-resolver-LLMGF5I5.cjs} +10 -11
- package/dist/lib/node/intent-resolver-LLMGF5I5.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-WI2MGWCC.cjs → react-surface-SEQLEL4K.cjs} +13 -11
- package/dist/lib/node/react-surface-SEQLEL4K.cjs.map +7 -0
- package/dist/lib/node/transcriber-RKKN7LDU.cjs +68 -0
- package/dist/lib/node/transcriber-RKKN7LDU.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +7 -11
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/{TranscriptContainer-ZXUCOWGY.mjs → TranscriptContainer-DLNRFVTA.mjs} +4 -3
- package/dist/lib/node-esm/chunk-BRPFVRAD.mjs +55 -0
- package/dist/lib/node-esm/chunk-BRPFVRAD.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-YQYBLFNI.mjs → chunk-EFIWBQDF.mjs} +139 -95
- package/dist/lib/node-esm/chunk-EFIWBQDF.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-J4D2RBBH.mjs → chunk-KUWWHMOA.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-PTZHDZ36.mjs → chunk-MFJPEIVB.mjs} +4 -4
- package/dist/lib/node-esm/chunk-MFJPEIVB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-PR7EYODX.mjs +765 -0
- package/dist/lib/node-esm/chunk-PR7EYODX.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-X4DDJIVL.mjs → chunk-TXMDLLBR.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-X4DDJIVL.mjs.map → chunk-TXMDLLBR.mjs.map} +1 -1
- package/dist/lib/node-esm/index.mjs +30 -216
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/{intent-resolver-QN2LO5TX.mjs → intent-resolver-WOZKOEBW.mjs} +7 -11
- package/dist/lib/node-esm/intent-resolver-WOZKOEBW.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-PCH6NTVB.mjs → react-surface-7MXUUTAL.mjs} +11 -9
- package/dist/lib/node-esm/react-surface-7MXUUTAL.mjs.map +7 -0
- package/dist/lib/node-esm/transcriber-5WSI6DYK.mjs +57 -0
- package/dist/lib/node-esm/transcriber-5WSI6DYK.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +4 -8
- package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +8 -10
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +2 -183
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/transcriber.d.ts +2 -1
- package/dist/types/src/capabilities/transcriber.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/Transcript.d.ts +14 -4
- package/dist/types/src/components/Transcript/Transcript.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts +19 -4
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts +27 -0
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts.map +1 -0
- package/dist/types/src/components/Transcript/transcript-extension.d.ts +19 -0
- package/dist/types/src/components/Transcript/transcript-extension.d.ts.map +1 -0
- package/dist/types/src/components/TranscriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts +17 -0
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +1 -0
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts +10 -0
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts.map +1 -0
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts +19 -0
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +1 -0
- package/dist/types/src/components/stories/TranscriptionStory.d.ts +11 -0
- package/dist/types/src/components/stories/TranscriptionStory.d.ts.map +1 -0
- package/dist/types/src/components/stories/useIsSpeaking.d.ts +3 -0
- package/dist/types/src/components/stories/useIsSpeaking.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useAudioFile.d.ts +1 -1
- package/dist/types/src/hooks/useAudioFile.d.ts.map +1 -1
- package/dist/types/src/hooks/useAudioTrack.d.ts +1 -1
- package/dist/types/src/hooks/useAudioTrack.d.ts.map +1 -1
- package/dist/types/src/hooks/useQueueModelAdapter.d.ts +7 -0
- package/dist/types/src/hooks/useQueueModelAdapter.d.ts.map +1 -0
- 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/model/index.d.ts +2 -0
- package/dist/types/src/model/index.d.ts.map +1 -0
- package/dist/types/src/model/model.d.ts +68 -0
- package/dist/types/src/model/model.d.ts.map +1 -0
- package/dist/types/src/model/model.test.d.ts +2 -0
- package/dist/types/src/model/model.test.d.ts.map +1 -0
- package/dist/types/src/segments-normalization/index.d.ts +4 -0
- package/dist/types/src/segments-normalization/index.d.ts.map +1 -0
- package/dist/types/src/segments-normalization/message-normalizer.d.ts +26 -0
- package/dist/types/src/segments-normalization/message-normalizer.d.ts.map +1 -0
- package/dist/types/src/segments-normalization/normalization.d.ts +520 -0
- package/dist/types/src/segments-normalization/normalization.d.ts.map +1 -0
- package/dist/types/src/segments-normalization/normalization.test.d.ts +2 -0
- package/dist/types/src/segments-normalization/normalization.test.d.ts.map +1 -0
- package/dist/types/src/segments-normalization/utils.d.ts +3 -0
- package/dist/types/src/segments-normalization/utils.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +40 -0
- package/dist/types/src/testing/testing.d.ts.map +1 -0
- package/dist/types/src/transcriber/media-stream-recorder.d.ts +8 -5
- package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.browser.test.d.ts +2 -0
- package/dist/types/src/transcriber/transcriber.browser.test.d.ts.map +1 -0
- package/dist/types/src/transcriber/transcriber.d.ts +6 -2
- package/dist/types/src/transcriber/transcriber.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcription-manager.d.ts +19 -15
- package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -20
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +23 -40
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +15 -8
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util/array.d.ts.map +1 -1
- package/dist/types/src/util/get-time-str.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +0 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/monitor-audio-level.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +62 -41
- package/src/TranscriptionPlugin.tsx +13 -18
- package/src/capabilities/capabilities.ts +15 -8
- package/src/capabilities/index.ts +0 -2
- package/src/capabilities/intent-resolver.ts +7 -8
- package/src/capabilities/react-surface.tsx +5 -4
- package/src/capabilities/transcriber.ts +34 -6
- package/src/components/Transcript/Transcript.stories.tsx +201 -43
- package/src/components/Transcript/Transcript.tsx +83 -208
- package/src/components/Transcript/deprecated/OldTranscript.tsx +260 -0
- package/src/components/Transcript/transcript-extension.ts +236 -0
- package/src/components/TranscriptContainer.tsx +11 -6
- package/src/components/stories/FileTranscription.stories.tsx +240 -0
- package/src/components/stories/KeyWordRecognition.stories.tsx +128 -0
- package/src/components/stories/MicrophoneTranscription.stories.tsx +274 -0
- package/src/components/stories/TranscriptionStory.tsx +41 -0
- package/src/components/stories/useIsSpeaking.tsx +40 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useAudioFile.ts +39 -9
- package/src/hooks/useAudioTrack.ts +2 -2
- package/src/hooks/useQueueModelAdapter.ts +65 -0
- package/src/hooks/useTranscriber.ts +4 -2
- package/src/meta.ts +2 -2
- package/src/model/index.ts +5 -0
- package/src/model/model.test.ts +169 -0
- package/src/model/model.ts +229 -0
- package/src/segments-normalization/index.ts +7 -0
- package/src/segments-normalization/message-normalizer.ts +108 -0
- package/src/segments-normalization/normalization.test.ts +142 -0
- package/src/segments-normalization/normalization.ts +103 -0
- package/src/segments-normalization/utils.ts +9 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/testing.ts +216 -0
- package/src/transcriber/media-stream-recorder.ts +14 -7
- package/src/transcriber/{transcriber.test.ts → transcriber.browser.test.ts} +7 -7
- package/src/transcriber/transcriber.ts +33 -20
- package/src/transcriber/transcription-manager.ts +87 -71
- package/src/translations.ts +2 -3
- package/src/types/schema.ts +11 -33
- package/src/types/types.ts +8 -12
- package/src/util/index.ts +0 -1
- package/dist/lib/browser/TranscriptContainer-JQ3HFHLQ.mjs +0 -10
- package/dist/lib/browser/app-graph-builder-VDQOVX7P.mjs +0 -191
- package/dist/lib/browser/app-graph-builder-VDQOVX7P.mjs.map +0 -7
- package/dist/lib/browser/chunk-G4B6CPC2.mjs +0 -253
- package/dist/lib/browser/chunk-G4B6CPC2.mjs.map +0 -7
- package/dist/lib/browser/chunk-GU2BNYKZ.mjs +0 -35
- package/dist/lib/browser/chunk-GU2BNYKZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-OGNXNGJB.mjs +0 -73
- package/dist/lib/browser/chunk-OGNXNGJB.mjs.map +0 -7
- package/dist/lib/browser/chunk-YCZISX63.mjs.map +0 -7
- package/dist/lib/browser/chunk-YEPT334A.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-4R66ZCKT.mjs.map +0 -7
- package/dist/lib/browser/meeting-transcription-state-DLFHQK72.mjs +0 -18
- package/dist/lib/browser/meeting-transcription-state-DLFHQK72.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FQUHU5G7.mjs.map +0 -7
- package/dist/lib/browser/transcriber-LGMIWDYI.mjs +0 -36
- package/dist/lib/browser/transcriber-LGMIWDYI.mjs.map +0 -7
- package/dist/lib/node/TranscriptContainer-QEYTTT2V.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-IFSIVNUR.cjs +0 -200
- package/dist/lib/node/app-graph-builder-IFSIVNUR.cjs.map +0 -7
- package/dist/lib/node/chunk-3KHUSQNW.cjs +0 -55
- package/dist/lib/node/chunk-3KHUSQNW.cjs.map +0 -7
- package/dist/lib/node/chunk-CZMLKKWT.cjs.map +0 -7
- package/dist/lib/node/chunk-FCCJALOT.cjs.map +0 -7
- package/dist/lib/node/chunk-P4VVD6ZO.cjs +0 -95
- package/dist/lib/node/chunk-P4VVD6ZO.cjs.map +0 -7
- package/dist/lib/node/chunk-UOFHT4GZ.cjs +0 -280
- package/dist/lib/node/chunk-UOFHT4GZ.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-WMMCOUEH.cjs.map +0 -7
- package/dist/lib/node/meeting-transcription-state-URIYILEQ.cjs +0 -34
- package/dist/lib/node/meeting-transcription-state-URIYILEQ.cjs.map +0 -7
- package/dist/lib/node/react-surface-WI2MGWCC.cjs.map +0 -7
- package/dist/lib/node/transcriber-QG5WPKX4.cjs +0 -49
- package/dist/lib/node/transcriber-QG5WPKX4.cjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-UL6XLIZY.mjs +0 -192
- package/dist/lib/node-esm/app-graph-builder-UL6XLIZY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6X7X2UZF.mjs +0 -254
- package/dist/lib/node-esm/chunk-6X7X2UZF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GIO6J6FE.mjs +0 -74
- package/dist/lib/node-esm/chunk-GIO6J6FE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HKATMD34.mjs +0 -37
- package/dist/lib/node-esm/chunk-HKATMD34.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PTZHDZ36.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YQYBLFNI.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-QN2LO5TX.mjs.map +0 -7
- package/dist/lib/node-esm/meeting-transcription-state-ZYVRAW6Y.mjs +0 -19
- package/dist/lib/node-esm/meeting-transcription-state-ZYVRAW6Y.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-PCH6NTVB.mjs.map +0 -7
- package/dist/lib/node-esm/transcriber-TMPYZ5L4.mjs +0 -37
- package/dist/lib/node-esm/transcriber-TMPYZ5L4.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -181
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/meeting-transcription-state.d.ts +0 -6
- package/dist/types/src/capabilities/meeting-transcription-state.d.ts.map +0 -1
- package/dist/types/src/components/transcription.stories.d.ts +0 -15
- package/dist/types/src/components/transcription.stories.d.ts.map +0 -1
- package/dist/types/src/transcriber/transcriber.test.d.ts +0 -2
- package/dist/types/src/transcriber/transcriber.test.d.ts.map +0 -1
- package/dist/types/src/util/random-queue-dxn.d.ts +0 -3
- package/dist/types/src/util/random-queue-dxn.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -152
- package/src/capabilities/meeting-transcription-state.ts +0 -16
- package/src/components/transcription.stories.tsx +0 -196
- package/src/util/random-queue-dxn.ts +0 -9
- /package/dist/lib/browser/{TranscriptContainer-JQ3HFHLQ.mjs.map → TranscriptContainer-PFKLKRPQ.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-K7FOYAXO.mjs.map → chunk-IGEKO7ZU.mjs.map} +0 -0
- /package/dist/lib/node/{chunk-LP4FG423.cjs.map → chunk-5J3FBCON.cjs.map} +0 -0
- /package/dist/lib/node-esm/{TranscriptContainer-ZXUCOWGY.mjs.map → TranscriptContainer-DLNRFVTA.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-J4D2RBBH.mjs.map → chunk-KUWWHMOA.mjs.map} +0 -0
|
@@ -0,0 +1,764 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TranscriptionCapabilities
|
|
3
|
+
} from "./chunk-W2KNYJD6.mjs";
|
|
4
|
+
|
|
5
|
+
// packages/plugins/plugin-transcription/src/components/TranscriptContainer.tsx
|
|
6
|
+
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
7
|
+
import React2 from "react";
|
|
8
|
+
import { fullyQualifiedId, getSpace } from "@dxos/client/echo";
|
|
9
|
+
import { useMembers, useQueue } from "@dxos/react-client/echo";
|
|
10
|
+
import { StackItem } from "@dxos/react-ui-stack";
|
|
11
|
+
|
|
12
|
+
// packages/plugins/plugin-transcription/src/components/Transcript/Transcript.tsx
|
|
13
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
14
|
+
import React from "react";
|
|
15
|
+
import { IconButton, useThemeContext } from "@dxos/react-ui";
|
|
16
|
+
import { createBasicExtensions, createMarkdownExtensions, createRenderer, createThemeExtensions, decorateMarkdown, editorWidth, preview, useTextEditor } from "@dxos/react-ui-editor";
|
|
17
|
+
import { mx } from "@dxos/react-ui-theme";
|
|
18
|
+
import { isNotFalsy } from "@dxos/util";
|
|
19
|
+
|
|
20
|
+
// packages/plugins/plugin-transcription/src/components/Transcript/transcript-extension.ts
|
|
21
|
+
import { RangeSetBuilder } from "@codemirror/state";
|
|
22
|
+
import { EditorView, GutterMarker, ViewPlugin, gutter } from "@codemirror/view";
|
|
23
|
+
import { format } from "date-fns/format";
|
|
24
|
+
import { intervalToDuration } from "date-fns/intervalToDuration";
|
|
25
|
+
import { addEventListener, combine } from "@dxos/async";
|
|
26
|
+
|
|
27
|
+
// packages/plugins/plugin-transcription/src/model/model.ts
|
|
28
|
+
import { Text } from "@codemirror/state";
|
|
29
|
+
import { Event } from "@dxos/async";
|
|
30
|
+
import { invariant } from "@dxos/invariant";
|
|
31
|
+
import { log } from "@dxos/log";
|
|
32
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-transcription/src/model/model.ts";
|
|
33
|
+
var DocumentAdapter = class {
|
|
34
|
+
constructor(_view) {
|
|
35
|
+
this._view = _view;
|
|
36
|
+
}
|
|
37
|
+
/** The document must always have at least one line. */
|
|
38
|
+
lineCount() {
|
|
39
|
+
return this._view.state.doc.lines - 1;
|
|
40
|
+
}
|
|
41
|
+
replaceLines(from, remove, insert) {
|
|
42
|
+
log("replaceLines", {
|
|
43
|
+
count: this._view.state.doc.lines,
|
|
44
|
+
from,
|
|
45
|
+
remove,
|
|
46
|
+
insert
|
|
47
|
+
}, {
|
|
48
|
+
F: __dxlog_file,
|
|
49
|
+
L: 39,
|
|
50
|
+
S: this,
|
|
51
|
+
C: (f, a) => f(...a)
|
|
52
|
+
});
|
|
53
|
+
const numLines = this._view.state.doc.lines;
|
|
54
|
+
const posFrom = this._view.state.doc.line(from).from;
|
|
55
|
+
const posTo = remove === 0 ? posFrom : this._view.state.doc.line(Math.min(numLines, from + remove)).from;
|
|
56
|
+
let text = insert.join("\n");
|
|
57
|
+
if (posTo === this._view.state.doc.length) {
|
|
58
|
+
text += "\n";
|
|
59
|
+
}
|
|
60
|
+
this._view.dispatch({
|
|
61
|
+
changes: {
|
|
62
|
+
from: posFrom,
|
|
63
|
+
to: posTo,
|
|
64
|
+
insert: text
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var SerializationModel = class {
|
|
70
|
+
constructor(_renderer, initialChunks = []) {
|
|
71
|
+
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
|
+
initialChunks.forEach((chunk) => {
|
|
78
|
+
this.appendChunk(chunk);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
toJSON() {
|
|
82
|
+
return {
|
|
83
|
+
chunks: this._chunks.length,
|
|
84
|
+
changes: this._changes.length
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
get doc() {
|
|
88
|
+
return Text.of([
|
|
89
|
+
...this._chunks.flatMap((chunk, index) => this._renderer(chunk, index)),
|
|
90
|
+
""
|
|
91
|
+
]);
|
|
92
|
+
}
|
|
93
|
+
get chunks() {
|
|
94
|
+
return this._chunks;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get the block ID at the given line number.
|
|
98
|
+
*/
|
|
99
|
+
getChunkAtLine(line) {
|
|
100
|
+
return this._lineToChunk.get(line);
|
|
101
|
+
}
|
|
102
|
+
reset() {
|
|
103
|
+
this._chunks.length = 0;
|
|
104
|
+
this._chunkLineCounts.clear();
|
|
105
|
+
this._lineToChunk.clear();
|
|
106
|
+
this.update.emit();
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
appendChunk(chunk) {
|
|
110
|
+
const index = this._chunks.length;
|
|
111
|
+
this._chunks.push(chunk);
|
|
112
|
+
this._changes.push({
|
|
113
|
+
type: "append",
|
|
114
|
+
index,
|
|
115
|
+
chunk
|
|
116
|
+
});
|
|
117
|
+
this.update.emit();
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
updateChunk(chunk) {
|
|
121
|
+
const index = this._chunks.findIndex((c) => c.id === chunk.id);
|
|
122
|
+
invariant(index !== -1, void 0, {
|
|
123
|
+
F: __dxlog_file,
|
|
124
|
+
L: 147,
|
|
125
|
+
S: this,
|
|
126
|
+
A: [
|
|
127
|
+
"index !== -1",
|
|
128
|
+
""
|
|
129
|
+
]
|
|
130
|
+
});
|
|
131
|
+
this._chunks[index] = chunk;
|
|
132
|
+
this._changes.push({
|
|
133
|
+
type: "update",
|
|
134
|
+
index,
|
|
135
|
+
chunk
|
|
136
|
+
});
|
|
137
|
+
this.update.emit();
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
deleteBlock(id) {
|
|
141
|
+
const index = this._chunks.findIndex((c) => c.id === id);
|
|
142
|
+
invariant(index !== -1, void 0, {
|
|
143
|
+
F: __dxlog_file,
|
|
144
|
+
L: 156,
|
|
145
|
+
S: this,
|
|
146
|
+
A: [
|
|
147
|
+
"index !== -1",
|
|
148
|
+
""
|
|
149
|
+
]
|
|
150
|
+
});
|
|
151
|
+
this._chunks.splice(index, 1);
|
|
152
|
+
this._changes.push({
|
|
153
|
+
type: "delete",
|
|
154
|
+
index,
|
|
155
|
+
id
|
|
156
|
+
});
|
|
157
|
+
this.update.emit();
|
|
158
|
+
return this;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Syncs the tracked changes with the ChunkDocument.
|
|
162
|
+
*/
|
|
163
|
+
sync(document2) {
|
|
164
|
+
log("sync", {
|
|
165
|
+
changes: this._changes
|
|
166
|
+
}, {
|
|
167
|
+
F: __dxlog_file,
|
|
168
|
+
L: 167,
|
|
169
|
+
S: this,
|
|
170
|
+
C: (f, a) => f(...a)
|
|
171
|
+
});
|
|
172
|
+
for (const change of this._changes) {
|
|
173
|
+
switch (change.type) {
|
|
174
|
+
case "append": {
|
|
175
|
+
const lines = this._renderer(change.chunk, change.index);
|
|
176
|
+
const lastLine = document2.lineCount();
|
|
177
|
+
document2.replaceLines(lastLine + 1, 0, lines);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
case "update": {
|
|
181
|
+
let lineStart = 1;
|
|
182
|
+
for (let i = 0; i < change.index; i++) {
|
|
183
|
+
lineStart += this._chunkLineCounts.get(this._chunks[i].id);
|
|
184
|
+
}
|
|
185
|
+
const previousLineCount = this._chunkLineCounts.get(change.chunk.id);
|
|
186
|
+
const newLines = this._renderer(change.chunk, change.index);
|
|
187
|
+
document2.replaceLines(lineStart, previousLineCount, newLines);
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
case "delete": {
|
|
191
|
+
let lineStart = 1;
|
|
192
|
+
for (let i = 0; i < change.index; i++) {
|
|
193
|
+
lineStart += this._chunkLineCounts.get(this._chunks[i].id);
|
|
194
|
+
}
|
|
195
|
+
const previousLineCount = this._chunkLineCounts.get(change.id);
|
|
196
|
+
document2.replaceLines(lineStart, previousLineCount, []);
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
this._lineToChunk.clear();
|
|
202
|
+
let currentLine = 1;
|
|
203
|
+
for (const [index, chunk] of this._chunks.entries()) {
|
|
204
|
+
const lineCount = this._renderer(chunk, index).length;
|
|
205
|
+
this._chunkLineCounts.set(chunk.id, lineCount);
|
|
206
|
+
this._lineToChunk.set(currentLine, chunk);
|
|
207
|
+
currentLine += lineCount;
|
|
208
|
+
}
|
|
209
|
+
const chunkIds = new Set(this._chunks.map((chunk) => chunk.id));
|
|
210
|
+
for (const id of this._chunkLineCounts.keys()) {
|
|
211
|
+
if (!chunkIds.has(id)) {
|
|
212
|
+
this._chunkLineCounts.delete(id);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
this._changes.length = 0;
|
|
216
|
+
return this;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// packages/plugins/plugin-transcription/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?.type === "transcription" && 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]?.type === "transcription" && 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
|
+
// packages/plugins/plugin-transcription/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.type === "transcription")?.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.type === "transcription");
|
|
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
|
+
// packages/plugins/plugin-transcription/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 = "/home/runner/work/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
|
+
// packages/plugins/plugin-transcription/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
|
+
// packages/plugins/plugin-transcription/src/hooks/useQueueModelAdapter.ts
|
|
574
|
+
import { useMemo, useEffect as useEffect3, useState as useState3 } from "react";
|
|
575
|
+
var useQueueModelAdapter = (renderer, queue, initialChunks = []) => {
|
|
576
|
+
const model = useMemo(() => new SerializationModel(renderer, initialChunks), [
|
|
577
|
+
queue
|
|
578
|
+
]);
|
|
579
|
+
const [loaded, setLoaded] = useState3(false);
|
|
580
|
+
useEffect3(() => {
|
|
581
|
+
if (!queue) {
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
const update = () => {
|
|
585
|
+
for (const block of queue?.objects ?? []) {
|
|
586
|
+
model.appendChunk(block);
|
|
587
|
+
}
|
|
588
|
+
setLoaded(true);
|
|
589
|
+
};
|
|
590
|
+
let i;
|
|
591
|
+
if (queue.isLoading) {
|
|
592
|
+
i = setInterval(() => {
|
|
593
|
+
if (!queue?.isLoading) {
|
|
594
|
+
clearInterval(i);
|
|
595
|
+
update();
|
|
596
|
+
}
|
|
597
|
+
}, 1e3);
|
|
598
|
+
} else {
|
|
599
|
+
update();
|
|
600
|
+
}
|
|
601
|
+
return () => clearTimeout(i);
|
|
602
|
+
}, [
|
|
603
|
+
model,
|
|
604
|
+
queue
|
|
605
|
+
]);
|
|
606
|
+
useEffect3(() => {
|
|
607
|
+
if (!loaded || !queue || model.chunks.length === queue.objects.length) {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
const chunk = queue.objects.at(-1);
|
|
611
|
+
if (chunk) {
|
|
612
|
+
model.appendChunk(chunk);
|
|
613
|
+
}
|
|
614
|
+
}, [
|
|
615
|
+
model,
|
|
616
|
+
loaded,
|
|
617
|
+
queue?.objects.length
|
|
618
|
+
]);
|
|
619
|
+
return model;
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
// packages/plugins/plugin-transcription/src/hooks/useTranscriber.ts
|
|
623
|
+
import { useEffect as useEffect4, useMemo as useMemo2 } from "react";
|
|
624
|
+
import { useCapabilities } from "@dxos/app-framework";
|
|
625
|
+
|
|
626
|
+
// packages/plugins/plugin-transcription/src/capabilities/index.ts
|
|
627
|
+
import { lazy } from "@dxos/app-framework";
|
|
628
|
+
var IntentResolver = lazy(() => import("./intent-resolver-I2LJSQDR.mjs"));
|
|
629
|
+
var ReactSurface = lazy(() => import("./react-surface-ID2MLJHZ.mjs"));
|
|
630
|
+
var Transcriber = lazy(() => import("./transcriber-NA7CIFIT.mjs"));
|
|
631
|
+
|
|
632
|
+
// packages/plugins/plugin-transcription/src/hooks/useTranscriber.ts
|
|
633
|
+
var useTranscriber = ({ audioStreamTrack, onSegments, transcriberConfig, recorderConfig }) => {
|
|
634
|
+
const [getTranscriber] = useCapabilities(TranscriptionCapabilities.Transcriber);
|
|
635
|
+
const transcriber = useMemo2(() => {
|
|
636
|
+
if (!onSegments || !audioStreamTrack || !getTranscriber) {
|
|
637
|
+
return void 0;
|
|
638
|
+
}
|
|
639
|
+
return getTranscriber({
|
|
640
|
+
audioStreamTrack,
|
|
641
|
+
onSegments,
|
|
642
|
+
transcriberConfig,
|
|
643
|
+
recorderConfig
|
|
644
|
+
});
|
|
645
|
+
}, [
|
|
646
|
+
audioStreamTrack,
|
|
647
|
+
onSegments,
|
|
648
|
+
getTranscriber,
|
|
649
|
+
transcriberConfig,
|
|
650
|
+
recorderConfig
|
|
651
|
+
]);
|
|
652
|
+
useEffect4(() => {
|
|
653
|
+
return () => {
|
|
654
|
+
void transcriber?.close();
|
|
655
|
+
};
|
|
656
|
+
}, [
|
|
657
|
+
transcriber
|
|
658
|
+
]);
|
|
659
|
+
return transcriber;
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
// packages/plugins/plugin-transcription/src/hooks/useVoiceInput.ts
|
|
663
|
+
import { useState as useState4, useEffect as useEffect5, useCallback } from "react";
|
|
664
|
+
import { scheduleMicroTask } from "@dxos/async";
|
|
665
|
+
import { Context as Context2 } from "@dxos/context";
|
|
666
|
+
import { log as log3 } from "@dxos/log";
|
|
667
|
+
import { useSoundEffect } from "@dxos/react-ui-sfx";
|
|
668
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-transcription/src/hooks/useVoiceInput.ts";
|
|
669
|
+
var useVoiceInput = ({ active, onUpdate }) => {
|
|
670
|
+
const soundStart = useSoundEffect("StartRecording");
|
|
671
|
+
const soundStop = useSoundEffect("StopRecording");
|
|
672
|
+
const handleSegments = useCallback(async (segments) => {
|
|
673
|
+
const text = segments.map((str) => str.text.trim().replace(/[^\w\s]/g, "")).join(" ");
|
|
674
|
+
onUpdate(text);
|
|
675
|
+
}, []);
|
|
676
|
+
const [recording, setRecording] = useState4(false);
|
|
677
|
+
const track = useAudioTrack(active);
|
|
678
|
+
const transcriber = useTranscriber({
|
|
679
|
+
audioStreamTrack: track,
|
|
680
|
+
onSegments: handleSegments
|
|
681
|
+
});
|
|
682
|
+
useEffect5(() => {
|
|
683
|
+
const ctx = new Context2(void 0, {
|
|
684
|
+
F: __dxlog_file3,
|
|
685
|
+
L: 43
|
|
686
|
+
});
|
|
687
|
+
scheduleMicroTask(ctx, async () => {
|
|
688
|
+
if (active && transcriber) {
|
|
689
|
+
await transcriber.open();
|
|
690
|
+
log3.info("starting...", void 0, {
|
|
691
|
+
F: __dxlog_file3,
|
|
692
|
+
L: 47,
|
|
693
|
+
S: void 0,
|
|
694
|
+
C: (f, a) => f(...a)
|
|
695
|
+
});
|
|
696
|
+
setRecording(true);
|
|
697
|
+
void soundStart.play();
|
|
698
|
+
transcriber.startChunksRecording();
|
|
699
|
+
} else if (!active && transcriber?.isOpen) {
|
|
700
|
+
transcriber?.stopChunksRecording();
|
|
701
|
+
await transcriber?.close();
|
|
702
|
+
log3.info("stopped", void 0, {
|
|
703
|
+
F: __dxlog_file3,
|
|
704
|
+
L: 54,
|
|
705
|
+
S: void 0,
|
|
706
|
+
C: (f, a) => f(...a)
|
|
707
|
+
});
|
|
708
|
+
setRecording(false);
|
|
709
|
+
void soundStop.play();
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
return () => {
|
|
713
|
+
void ctx.dispose();
|
|
714
|
+
};
|
|
715
|
+
}, [
|
|
716
|
+
active,
|
|
717
|
+
transcriber
|
|
718
|
+
]);
|
|
719
|
+
return {
|
|
720
|
+
recording
|
|
721
|
+
};
|
|
722
|
+
};
|
|
723
|
+
|
|
724
|
+
// packages/plugins/plugin-transcription/src/components/TranscriptContainer.tsx
|
|
725
|
+
var TranscriptionContainer = ({ role, transcript: transcript2 }) => {
|
|
726
|
+
var _effect = _useSignals2();
|
|
727
|
+
try {
|
|
728
|
+
const attendableId = fullyQualifiedId(transcript2);
|
|
729
|
+
const space = getSpace(transcript2);
|
|
730
|
+
const members = useMembers(space?.key).map((member) => member.identity);
|
|
731
|
+
const queue = useQueue(transcript2.queue.dxn, {
|
|
732
|
+
pollInterval: 1e3
|
|
733
|
+
});
|
|
734
|
+
const model = useQueueModelAdapter(renderMarkdown(members), queue);
|
|
735
|
+
return /* @__PURE__ */ React2.createElement(StackItem.Content, {
|
|
736
|
+
role,
|
|
737
|
+
classNames: "container-max-width pli-2"
|
|
738
|
+
}, /* @__PURE__ */ React2.createElement(Transcript, {
|
|
739
|
+
attendableId,
|
|
740
|
+
space,
|
|
741
|
+
model,
|
|
742
|
+
transcript: transcript2
|
|
743
|
+
}));
|
|
744
|
+
} finally {
|
|
745
|
+
_effect.f();
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
var TranscriptContainer_default = TranscriptionContainer;
|
|
749
|
+
|
|
750
|
+
export {
|
|
751
|
+
renderMarkdown,
|
|
752
|
+
Transcript,
|
|
753
|
+
useAudioFile,
|
|
754
|
+
useAudioTrack,
|
|
755
|
+
useQueueModelAdapter,
|
|
756
|
+
useTranscriber,
|
|
757
|
+
useVoiceInput,
|
|
758
|
+
TranscriptionContainer,
|
|
759
|
+
TranscriptContainer_default,
|
|
760
|
+
IntentResolver,
|
|
761
|
+
ReactSurface,
|
|
762
|
+
Transcriber
|
|
763
|
+
};
|
|
764
|
+
//# sourceMappingURL=chunk-TJPJBE45.mjs.map
|