@dxos/plugin-transcription 0.8.4-main.28f8d3d → 0.8.4-main.2c6827d
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-OQFBAGSP.mjs +11 -0
- package/dist/lib/browser/blueprint-definition-GZ7NOODS.mjs +147 -0
- package/dist/lib/browser/blueprint-definition-GZ7NOODS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SREIAQSP.mjs → chunk-3MKZ2MNQ.mjs} +5 -5
- package/dist/lib/browser/chunk-3MKZ2MNQ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-KJIQQHJB.mjs → chunk-7GNN7E3U.mjs} +18 -58
- package/dist/lib/browser/chunk-7GNN7E3U.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BJWYA2BU.mjs → chunk-C5YV3JZF.mjs} +91 -135
- package/dist/lib/browser/chunk-C5YV3JZF.mjs.map +7 -0
- package/dist/lib/browser/{chunk-UKUSJTQW.mjs → chunk-O33THH53.mjs} +2 -2
- package/dist/lib/browser/chunk-QOSZIUE2.mjs +32 -0
- package/dist/lib/browser/chunk-QOSZIUE2.mjs.map +7 -0
- package/dist/lib/browser/chunk-VBUIO677.mjs +29 -0
- package/dist/lib/browser/chunk-VBUIO677.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +23 -20
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-5CGCLOXB.mjs +25 -0
- package/dist/lib/browser/intent-resolver-5CGCLOXB.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-4MEJMKYQ.mjs → react-surface-OK55WK7J.mjs} +9 -11
- package/dist/lib/browser/react-surface-OK55WK7J.mjs.map +7 -0
- package/dist/lib/browser/{transcriber-V77CN7XX.mjs → transcriber-6YDM5ZDT.mjs} +7 -7
- package/dist/lib/browser/{transcriber-V77CN7XX.mjs.map → transcriber-6YDM5ZDT.mjs.map} +1 -1
- package/dist/lib/browser/types/index.mjs +4 -8
- package/dist/lib/node-esm/{TranscriptContainer-GEUOOYHX.mjs → TranscriptContainer-GM47P6WH.mjs} +4 -4
- package/dist/lib/node-esm/blueprint-definition-GAHQBYTF.mjs +148 -0
- package/dist/lib/node-esm/blueprint-definition-GAHQBYTF.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-A33GNR44.mjs → chunk-5JN2MHYA.mjs} +18 -58
- package/dist/lib/node-esm/chunk-5JN2MHYA.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-Y7PCJ34K.mjs → chunk-IKGUNN3Z.mjs} +91 -135
- package/dist/lib/node-esm/chunk-IKGUNN3Z.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-PHP7MCAY.mjs → chunk-SSYFSLB7.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-TM2ASOZA.mjs → chunk-SWUVPFKR.mjs} +5 -5
- package/dist/lib/node-esm/chunk-SWUVPFKR.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-U4YPUD2F.mjs +33 -0
- package/dist/lib/node-esm/chunk-U4YPUD2F.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YVNQN2J6.mjs +30 -0
- package/dist/lib/node-esm/chunk-YVNQN2J6.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +23 -20
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-4H4CXIAL.mjs +26 -0
- package/dist/lib/node-esm/intent-resolver-4H4CXIAL.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-EZUPNHUC.mjs → react-surface-EK6K2MMD.mjs} +9 -11
- package/dist/lib/node-esm/react-surface-EK6K2MMD.mjs.map +7 -0
- package/dist/lib/node-esm/{transcriber-3SX3DNLV.mjs → transcriber-CPD3FZ7M.mjs} +7 -7
- package/dist/lib/node-esm/{transcriber-3SX3DNLV.mjs.map → transcriber-CPD3FZ7M.mjs.map} +1 -1
- package/dist/lib/node-esm/types/index.mjs +4 -8
- package/dist/types/src/TranscriptionPlugin.d.ts +1 -1
- package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +3 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/transcriber.d.ts +1 -1
- package/dist/types/src/components/Transcript/Transcript.d.ts +6 -7
- package/dist/types/src/components/Transcript/Transcript.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts +33 -18
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts +3 -3
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/transcript-extension.d.ts +3 -7
- package/dist/types/src/components/Transcript/transcript-extension.d.ts.map +1 -1
- package/dist/types/src/components/TranscriptContainer.d.ts +2 -2
- package/dist/types/src/components/TranscriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts +5 -4
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts +10 -6
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts +7 -6
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/TranscriptionStory.d.ts +4 -3
- package/dist/types/src/components/stories/TranscriptionStory.d.ts.map +1 -1
- package/dist/types/src/functions/index.d.ts +3 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/open.d.ts +7 -0
- package/dist/types/src/functions/open.d.ts.map +1 -0
- package/dist/types/src/functions/summarize.d.ts +11 -0
- package/dist/types/src/functions/summarize.d.ts.map +1 -0
- package/dist/types/src/hooks/useAudioFile.d.ts.map +1 -1
- package/dist/types/src/hooks/useTranscriber.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/message-normalizer.d.ts +3 -3
- package/dist/types/src/segments-normalization/message-normalizer.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/normalization.d.ts +389 -335
- 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 +6 -6
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.d.ts +2 -2
- package/dist/types/src/transcriber/transcriber.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcription-manager.d.ts +6 -10
- package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
- package/dist/types/src/types/TranscriptAction.d.ts +23 -0
- package/dist/types/src/types/TranscriptAction.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +0 -26
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +64 -63
- package/src/TranscriptionPlugin.tsx +58 -54
- package/src/capabilities/blueprint-definition.ts +31 -0
- package/src/capabilities/capabilities.ts +3 -3
- package/src/capabilities/index.ts +1 -0
- package/src/capabilities/intent-resolver.ts +5 -10
- package/src/capabilities/react-surface.tsx +2 -2
- package/src/components/Transcript/Transcript.stories.tsx +35 -33
- package/src/components/Transcript/Transcript.tsx +21 -29
- package/src/components/Transcript/deprecated/OldTranscript.tsx +7 -7
- package/src/components/Transcript/transcript-extension.ts +11 -44
- package/src/components/TranscriptContainer.tsx +10 -10
- package/src/components/stories/FileTranscription.stories.tsx +48 -37
- package/src/components/stories/KeyWordRecognition.stories.tsx +15 -11
- package/src/components/stories/MicrophoneTranscription.stories.tsx +43 -40
- package/src/components/stories/TranscriptionStory.tsx +14 -11
- package/src/functions/index.ts +6 -0
- package/src/functions/open.ts +38 -0
- package/src/functions/summarize.ts +103 -0
- package/src/hooks/useAudioFile.ts +49 -53
- package/src/hooks/useTranscriber.ts +7 -2
- package/src/meta.ts +7 -4
- package/src/model/model.test.ts +11 -11
- package/src/segments-normalization/message-normalizer.ts +6 -6
- package/src/segments-normalization/normalization.test.ts +6 -6
- package/src/segments-normalization/normalization.ts +7 -7
- package/src/segments-normalization/utils.ts +2 -2
- package/src/testing/testing.ts +25 -20
- package/src/transcriber/transcriber.browser.test.ts +3 -3
- package/src/transcriber/transcriber.ts +3 -3
- package/src/transcriber/transcription-manager.ts +23 -44
- package/src/types/TranscriptAction.ts +23 -0
- package/src/types/index.ts +1 -1
- package/src/types/types.ts +0 -24
- package/dist/lib/browser/TranscriptContainer-FH7VAWYA.mjs +0 -11
- package/dist/lib/browser/chunk-5WH45KBY.mjs +0 -19
- package/dist/lib/browser/chunk-5WH45KBY.mjs.map +0 -7
- package/dist/lib/browser/chunk-BJWYA2BU.mjs.map +0 -7
- package/dist/lib/browser/chunk-KJIQQHJB.mjs.map +0 -7
- package/dist/lib/browser/chunk-KWOOVS5G.mjs +0 -55
- package/dist/lib/browser/chunk-KWOOVS5G.mjs.map +0 -7
- package/dist/lib/browser/chunk-SREIAQSP.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-AOVQ7JI4.mjs +0 -30
- package/dist/lib/browser/intent-resolver-AOVQ7JI4.mjs.map +0 -7
- package/dist/lib/browser/react-surface-4MEJMKYQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-A33GNR44.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IKQMDRY6.mjs +0 -56
- package/dist/lib/node-esm/chunk-IKQMDRY6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TM2ASOZA.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/chunk-Y7PCJ34K.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-P4XPIKQF.mjs +0 -31
- package/dist/lib/node-esm/intent-resolver-P4XPIKQF.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-EZUPNHUC.mjs.map +0 -7
- package/dist/types/src/types/schema.d.ts +0 -41
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/types/schema.ts +0 -41
- /package/dist/lib/browser/{TranscriptContainer-FH7VAWYA.mjs.map → TranscriptContainer-OQFBAGSP.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-UKUSJTQW.mjs.map → chunk-O33THH53.mjs.map} +0 -0
- /package/dist/lib/node-esm/{TranscriptContainer-GEUOOYHX.mjs.map → TranscriptContainer-GM47P6WH.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-PHP7MCAY.mjs.map → chunk-SSYFSLB7.mjs.map} +0 -0
|
@@ -6,29 +6,29 @@ import React from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { type Space } from '@dxos/react-client/echo';
|
|
8
8
|
import { type Identity } from '@dxos/react-client/halo';
|
|
9
|
-
import {
|
|
9
|
+
import { type ThemedClassName, useThemeContext } from '@dxos/react-ui';
|
|
10
10
|
import {
|
|
11
|
+
autoScroll,
|
|
11
12
|
createBasicExtensions,
|
|
12
13
|
createMarkdownExtensions,
|
|
13
|
-
createRenderer,
|
|
14
14
|
createThemeExtensions,
|
|
15
15
|
decorateMarkdown,
|
|
16
|
-
|
|
16
|
+
editorSlots,
|
|
17
17
|
preview,
|
|
18
18
|
useTextEditor,
|
|
19
19
|
} from '@dxos/react-ui-editor';
|
|
20
20
|
import { mx } from '@dxos/react-ui-theme';
|
|
21
|
-
import { type
|
|
22
|
-
import {
|
|
21
|
+
import { type Message, type Transcript } from '@dxos/types';
|
|
22
|
+
import { isTruthy } from '@dxos/util';
|
|
23
23
|
|
|
24
24
|
import { type SerializationModel } from '../../model';
|
|
25
|
-
import { type TranscriptType } from '../../types';
|
|
26
25
|
|
|
27
26
|
import { transcript } from './transcript-extension';
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
// TODO(thure): Move this?
|
|
29
|
+
export const renderByline =
|
|
30
30
|
(identities: Identity[]) =>
|
|
31
|
-
(message:
|
|
31
|
+
(message: Message.Message, index: number, debug = false): string[] => {
|
|
32
32
|
if (message.sender.role === 'assistant') {
|
|
33
33
|
// Start/stop block.
|
|
34
34
|
return [message.blocks.find((block) => block._tag === 'transcript')?.text ?? '', ''];
|
|
@@ -45,17 +45,18 @@ export const renderMarkdown =
|
|
|
45
45
|
message.sender.identityDid;
|
|
46
46
|
const blocks = message.blocks.filter((block) => block._tag === 'transcript');
|
|
47
47
|
return [
|
|
48
|
+
// TODO(thure): Use an XML tag with the bits needed here.
|
|
48
49
|
`###### ${name}` + (debug ? ` [${index}]:${message.id}` : ''),
|
|
49
50
|
blocks.map((block) => block.text.trim()).join(' '),
|
|
50
51
|
'',
|
|
51
52
|
];
|
|
52
53
|
};
|
|
53
54
|
|
|
54
|
-
export type
|
|
55
|
-
transcript?: TranscriptType;
|
|
55
|
+
export type TranscriptViewProps = ThemedClassName<{
|
|
56
56
|
space?: Space;
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
transcript?: Transcript.Transcript;
|
|
58
|
+
model: SerializationModel<Message.Message>;
|
|
59
|
+
// TODO(burdon): Are these still in use?
|
|
59
60
|
attendableId?: string;
|
|
60
61
|
ignoreAttention?: boolean;
|
|
61
62
|
}>;
|
|
@@ -63,39 +64,30 @@ export type TranscriptProps = ThemedClassName<{
|
|
|
63
64
|
/**
|
|
64
65
|
* Transcript component implemented using the editor.
|
|
65
66
|
*/
|
|
66
|
-
export const
|
|
67
|
-
classNames,
|
|
68
|
-
transcript: object,
|
|
69
|
-
space,
|
|
70
|
-
model,
|
|
71
|
-
attendableId,
|
|
72
|
-
ignoreAttention,
|
|
73
|
-
}: TranscriptProps) => {
|
|
67
|
+
export const TranscriptView = ({ classNames, space, transcript: object, model }: TranscriptViewProps) => {
|
|
74
68
|
const { themeMode } = useThemeContext();
|
|
75
69
|
const { parentRef } = useTextEditor(() => {
|
|
76
70
|
return {
|
|
77
71
|
extensions: [
|
|
78
72
|
createBasicExtensions({ readOnly: true, lineWrapping: true, search: true }),
|
|
79
|
-
createMarkdownExtensions(
|
|
80
|
-
createThemeExtensions({ themeMode }),
|
|
73
|
+
createMarkdownExtensions(),
|
|
74
|
+
createThemeExtensions({ themeMode, slots: editorSlots }),
|
|
81
75
|
decorateMarkdown(),
|
|
82
|
-
|
|
76
|
+
preview(),
|
|
83
77
|
transcript({
|
|
84
78
|
model,
|
|
85
79
|
started: object?.started ? new Date(object.started) : undefined,
|
|
86
|
-
renderButton: createRenderer(({ onClick }) => (
|
|
87
|
-
<IconButton icon='ph--arrow-line-down--regular' iconOnly label='Scroll to bottom' onClick={onClick} />
|
|
88
|
-
)),
|
|
89
80
|
}),
|
|
90
|
-
|
|
81
|
+
autoScroll(),
|
|
82
|
+
].filter(isTruthy),
|
|
91
83
|
};
|
|
92
84
|
}, [space, model]);
|
|
93
85
|
|
|
94
86
|
return (
|
|
95
87
|
<div
|
|
96
88
|
ref={parentRef}
|
|
97
|
-
className={mx('flex grow overflow-hidden',
|
|
98
|
-
data-popover-collision-boundary={true}
|
|
89
|
+
className={mx('flex grow overflow-hidden container-max-width', classNames)}
|
|
90
|
+
data-popover-collision-boundary={true /* TODO(thure): Make this a constant and document it. */}
|
|
99
91
|
/>
|
|
100
92
|
);
|
|
101
93
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { intervalToDuration } from 'date-fns/intervalToDuration';
|
|
6
|
-
import
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
7
7
|
import { yieldOrContinue } from 'main-thread-scheduling';
|
|
8
8
|
import React, { type FC, type WheelEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
9
9
|
import { type OnResizeCallback, useResizeDetector } from 'react-resize-detector';
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from '@dxos/react-ui-grid';
|
|
22
22
|
import { mx } from '@dxos/react-ui-theme';
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import { meta } from '../../../meta';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Transcription fragment.
|
|
@@ -115,7 +115,7 @@ const measureRows = async (
|
|
|
115
115
|
return result;
|
|
116
116
|
};
|
|
117
117
|
|
|
118
|
-
export type
|
|
118
|
+
export type TranscriptViewProps = ThemedClassName<{
|
|
119
119
|
blocks?: TranscriptBlock[];
|
|
120
120
|
attendableId?: string;
|
|
121
121
|
ignoreAttention?: boolean;
|
|
@@ -124,8 +124,8 @@ export type TranscriptProps = ThemedClassName<{
|
|
|
124
124
|
/**
|
|
125
125
|
* @@deprecated
|
|
126
126
|
*/
|
|
127
|
-
export const Transcript: FC<
|
|
128
|
-
const { t } = useTranslation(
|
|
127
|
+
export const Transcript: FC<TranscriptViewProps> = ({ classNames, blocks, attendableId, ignoreAttention }) => {
|
|
128
|
+
const { t } = useTranslation(meta.id);
|
|
129
129
|
const [dxGrid, setDxGrid] = useState<DxGridElement | null>(null);
|
|
130
130
|
const [rows, setRows] = useState<DxGridAxisMeta | undefined>(undefined);
|
|
131
131
|
const [columns, setColumns] = useState<DxGridAxisMeta | undefined>(undefined);
|
|
@@ -144,7 +144,7 @@ export const Transcript: FC<TranscriptProps> = ({ classNames, blocks, attendable
|
|
|
144
144
|
[hasAttention, ignoreAttention],
|
|
145
145
|
);
|
|
146
146
|
|
|
147
|
-
const abortControllerRef = useRef<AbortController>();
|
|
147
|
+
const abortControllerRef = useRef<AbortController>(null);
|
|
148
148
|
|
|
149
149
|
const handleResize = useCallback(
|
|
150
150
|
async ({ entry }: { entry: { target: HTMLDivElement } | null }) => {
|
|
@@ -242,7 +242,7 @@ export const Transcript: FC<TranscriptProps> = ({ classNames, blocks, attendable
|
|
|
242
242
|
ref={setDxGrid}
|
|
243
243
|
/>
|
|
244
244
|
</Grid.Root>
|
|
245
|
-
<div role='none' {...{ inert:
|
|
245
|
+
<div role='none' {...{ inert: true }} aria-hidden className={measureClasses} ref={measureRef} />
|
|
246
246
|
<IconButton
|
|
247
247
|
icon='ph--arrow-line-down--regular'
|
|
248
248
|
iconOnly
|
|
@@ -8,8 +8,7 @@ import { format } from 'date-fns/format';
|
|
|
8
8
|
import { intervalToDuration } from 'date-fns/intervalToDuration';
|
|
9
9
|
|
|
10
10
|
import { type CleanupFn, addEventListener, combine } from '@dxos/async';
|
|
11
|
-
import { type
|
|
12
|
-
import { type DataType } from '@dxos/schema';
|
|
11
|
+
import { type Message } from '@dxos/types';
|
|
13
12
|
|
|
14
13
|
import { DocumentAdapter, type SerializationModel } from '../../model';
|
|
15
14
|
|
|
@@ -17,15 +16,14 @@ import { DocumentAdapter, type SerializationModel } from '../../model';
|
|
|
17
16
|
* Data structure that maps Chunks queue to lines with transcript state.
|
|
18
17
|
*/
|
|
19
18
|
export type TranscriptOptions = {
|
|
20
|
-
model: SerializationModel<
|
|
19
|
+
model: SerializationModel<Message.Message>;
|
|
21
20
|
started?: Date;
|
|
22
|
-
renderButton?: RenderCallback<{ onClick: () => void }>;
|
|
23
21
|
};
|
|
24
22
|
|
|
25
23
|
/**
|
|
26
24
|
* Scrolling transcript with timestamps.
|
|
27
25
|
*/
|
|
28
|
-
export const transcript = ({ model, started
|
|
26
|
+
export const transcript = ({ model, started }: TranscriptOptions): Extension => {
|
|
29
27
|
return [
|
|
30
28
|
// Show timestamps in the gutter.
|
|
31
29
|
gutter({
|
|
@@ -90,22 +88,6 @@ export const transcript = ({ model, started, renderButton }: TranscriptOptions):
|
|
|
90
88
|
});
|
|
91
89
|
};
|
|
92
90
|
|
|
93
|
-
// Scroll button.
|
|
94
|
-
if (renderButton) {
|
|
95
|
-
this._controls = document.createElement('div');
|
|
96
|
-
this._controls.classList.add('cm-controls', 'transition-opacity', 'duration-300', 'opacity-0');
|
|
97
|
-
view.dom.appendChild(this._controls);
|
|
98
|
-
renderButton(
|
|
99
|
-
this._controls,
|
|
100
|
-
{
|
|
101
|
-
onClick: () => {
|
|
102
|
-
scrollToBottom(false);
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
view,
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
91
|
// Event listeners.
|
|
110
92
|
this._cleanup = combine(
|
|
111
93
|
addEventListener(view.scrollDOM, 'scroll', () => {
|
|
@@ -131,7 +113,7 @@ export const transcript = ({ model, started, renderButton }: TranscriptOptions):
|
|
|
131
113
|
);
|
|
132
114
|
}
|
|
133
115
|
|
|
134
|
-
update(
|
|
116
|
+
update(_update: ViewUpdate) {
|
|
135
117
|
// Initial sync.
|
|
136
118
|
if (!this._initialized) {
|
|
137
119
|
this._initialized = true;
|
|
@@ -149,27 +131,12 @@ export const transcript = ({ model, started, renderButton }: TranscriptOptions):
|
|
|
149
131
|
),
|
|
150
132
|
|
|
151
133
|
EditorView.theme({
|
|
152
|
-
'.cm-
|
|
153
|
-
|
|
154
|
-
},
|
|
155
|
-
'.cm-hide-scrollbar': {
|
|
156
|
-
scrollbarWidth: 'none',
|
|
157
|
-
'-ms-overflow-style': 'none',
|
|
158
|
-
},
|
|
159
|
-
'.cm-hide-scrollbar::-webkit-scrollbar': {
|
|
160
|
-
display: 'none',
|
|
161
|
-
},
|
|
162
|
-
'.cm-controls': {
|
|
163
|
-
position: 'absolute',
|
|
164
|
-
bottom: '0.5rem',
|
|
165
|
-
right: '0.5rem',
|
|
166
|
-
zIndex: 1000,
|
|
167
|
-
},
|
|
168
|
-
'.cm-line': {
|
|
169
|
-
paddingRight: '1rem',
|
|
134
|
+
'.cm-gutters': {
|
|
135
|
+
backgroundColor: 'var(--dx-baseSurface)',
|
|
170
136
|
},
|
|
171
137
|
'.cm-timestamp-gutter': {
|
|
172
138
|
width: '6rem',
|
|
139
|
+
paddingLeft: '0.5rem',
|
|
173
140
|
paddingRight: '1rem',
|
|
174
141
|
},
|
|
175
142
|
'.cm-timestamp-gutter > .cm-gutterElement > div': {
|
|
@@ -193,11 +160,11 @@ class TimestampMarker extends GutterMarker {
|
|
|
193
160
|
super();
|
|
194
161
|
}
|
|
195
162
|
|
|
196
|
-
override eq(other: this)
|
|
197
|
-
return
|
|
163
|
+
override eq(other: this) {
|
|
164
|
+
return this._timestamp === other._timestamp;
|
|
198
165
|
}
|
|
199
166
|
|
|
200
|
-
override toDOM(view: EditorView)
|
|
167
|
+
override toDOM(view: EditorView) {
|
|
201
168
|
const el = document.createElement('div');
|
|
202
169
|
el.className = 'text-sm text-subdued hover:bg-hoverSurface cursor-pointer';
|
|
203
170
|
el.textContent = formatTimestamp(this._timestamp, this._started);
|
|
@@ -213,7 +180,7 @@ class TimestampMarker extends GutterMarker {
|
|
|
213
180
|
}
|
|
214
181
|
}
|
|
215
182
|
|
|
216
|
-
const getStartTime = (started?: Date, message?:
|
|
183
|
+
const getStartTime = (started?: Date, message?: Message.Message): Date | undefined => {
|
|
217
184
|
if (started) {
|
|
218
185
|
return started;
|
|
219
186
|
}
|
|
@@ -4,31 +4,31 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { getSpace } from '@dxos/client/echo';
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
8
9
|
import { useMembers, useQueue } from '@dxos/react-client/echo';
|
|
9
10
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
10
|
-
import { type
|
|
11
|
+
import { type Message, type Transcript } from '@dxos/types';
|
|
11
12
|
|
|
12
13
|
import { useQueueModelAdapter } from '../hooks';
|
|
13
|
-
import { type TranscriptType } from '../types';
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { TranscriptView, renderByline } from './Transcript';
|
|
16
16
|
|
|
17
17
|
export type TranscriptionContainerProps = {
|
|
18
18
|
role: string;
|
|
19
|
-
transcript:
|
|
19
|
+
transcript: Transcript.Transcript;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export const TranscriptionContainer = ({ transcript }: TranscriptionContainerProps) => {
|
|
23
|
-
const attendableId =
|
|
23
|
+
const attendableId = Obj.getDXN(transcript).toString();
|
|
24
24
|
const space = getSpace(transcript);
|
|
25
25
|
const members = useMembers(space?.key).map((member) => member.identity);
|
|
26
|
-
const queue = useQueue<
|
|
27
|
-
const model = useQueueModelAdapter(
|
|
26
|
+
const queue = useQueue<Message.Message>(transcript.queue.dxn, { pollInterval: 1_000 });
|
|
27
|
+
const model = useQueueModelAdapter(renderByline(members), queue);
|
|
28
28
|
|
|
29
29
|
return (
|
|
30
|
-
<StackItem.Content
|
|
31
|
-
<
|
|
30
|
+
<StackItem.Content>
|
|
31
|
+
<TranscriptView attendableId={attendableId} space={space} model={model} transcript={transcript} />
|
|
32
32
|
</StackItem.Content>
|
|
33
33
|
);
|
|
34
34
|
};
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
9
7
|
|
|
@@ -12,26 +10,27 @@ import { withPluginManager } from '@dxos/app-framework/testing';
|
|
|
12
10
|
import { scheduleTask } from '@dxos/async';
|
|
13
11
|
import { Context } from '@dxos/context';
|
|
14
12
|
import { Obj } from '@dxos/echo';
|
|
13
|
+
import { createQueueDXN } from '@dxos/echo/internal';
|
|
15
14
|
import { MemoryQueue } from '@dxos/echo-db';
|
|
16
|
-
import {
|
|
17
|
-
import { FunctionExecutor, ServiceContainer } from '@dxos/functions';
|
|
15
|
+
import { FunctionExecutor, ServiceContainer } from '@dxos/functions-runtime';
|
|
18
16
|
import { log } from '@dxos/log';
|
|
19
17
|
import { ClientPlugin } from '@dxos/plugin-client';
|
|
20
18
|
import { PreviewPlugin } from '@dxos/plugin-preview';
|
|
21
19
|
import { SpacePlugin } from '@dxos/plugin-space';
|
|
22
20
|
import { StorybookLayoutPlugin } from '@dxos/plugin-storybook-layout';
|
|
23
21
|
import { ThemePlugin } from '@dxos/plugin-theme';
|
|
22
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
24
23
|
import { defaultTx } from '@dxos/react-ui-theme';
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
24
|
+
import { Testing } from '@dxos/schema/testing';
|
|
25
|
+
import { type Actor, Message, Organization, Person } from '@dxos/types';
|
|
26
|
+
import { seedTestData } from '@dxos/types/testing';
|
|
28
27
|
|
|
29
28
|
import { useAudioFile, useQueueModelAdapter, useTranscriber } from '../../hooks';
|
|
30
29
|
import { MessageNormalizer, getActorId } from '../../segments-normalization';
|
|
31
30
|
import { TestItem } from '../../testing';
|
|
32
31
|
import { type MediaStreamRecorderParams, type TranscriberParams } from '../../transcriber';
|
|
33
32
|
import { TranscriptionPlugin } from '../../TranscriptionPlugin';
|
|
34
|
-
import {
|
|
33
|
+
import { renderByline } from '../Transcript';
|
|
35
34
|
|
|
36
35
|
import { TranscriptionStory } from './TranscriptionStory';
|
|
37
36
|
import { useIsSpeaking } from './useIsSpeaking';
|
|
@@ -52,7 +51,7 @@ const AudioFile = ({
|
|
|
52
51
|
audioConstraints?: MediaTrackConstraints;
|
|
53
52
|
}) => {
|
|
54
53
|
const [running, setRunning] = useState(false);
|
|
55
|
-
const actor:
|
|
54
|
+
const actor: Actor.Actor = useMemo(() => ({ name: 'You' }), []);
|
|
56
55
|
|
|
57
56
|
// Audio.
|
|
58
57
|
const { audio, track, stream } = useAudioFile(audioUrl, audioConstraints);
|
|
@@ -68,7 +67,6 @@ const AudioFile = ({
|
|
|
68
67
|
|
|
69
68
|
useEffect(() => {
|
|
70
69
|
if (!audio) {
|
|
71
|
-
log.warn('no audio');
|
|
72
70
|
return;
|
|
73
71
|
}
|
|
74
72
|
|
|
@@ -82,13 +80,13 @@ const AudioFile = ({
|
|
|
82
80
|
// Transcriber.
|
|
83
81
|
// TODO(dmaretskyi): Use space.queues.create() instead.
|
|
84
82
|
const queueDxn = useMemo(() => createQueueDXN(), []);
|
|
85
|
-
const queue = useMemo(() => new MemoryQueue<
|
|
83
|
+
const queue = useMemo(() => new MemoryQueue<Message.Message>(queueDxn), [queueDxn]);
|
|
86
84
|
|
|
87
|
-
const model = useQueueModelAdapter(
|
|
85
|
+
const model = useQueueModelAdapter(renderByline([]), queue);
|
|
88
86
|
const handleSegments = useCallback<TranscriberParams['onSegments']>(
|
|
89
87
|
async (blocks) => {
|
|
90
88
|
void queue?.append([
|
|
91
|
-
Obj.make(
|
|
89
|
+
Obj.make(Message.Message, {
|
|
92
90
|
created: new Date().toISOString(),
|
|
93
91
|
sender: actor,
|
|
94
92
|
blocks,
|
|
@@ -147,10 +145,10 @@ const AudioFile = ({
|
|
|
147
145
|
}, [normalizer]);
|
|
148
146
|
|
|
149
147
|
const manageChunkRecording = () => {
|
|
150
|
-
if (running && isSpeaking) {
|
|
148
|
+
if (running && isSpeaking && transcriber) {
|
|
151
149
|
log.info('starting transcription');
|
|
152
150
|
transcriber?.startChunksRecording();
|
|
153
|
-
} else if (!isSpeaking || !running) {
|
|
151
|
+
} else if ((!isSpeaking || !running) && transcriber) {
|
|
154
152
|
log.info('stopping transcription');
|
|
155
153
|
transcriber?.stopChunksRecording();
|
|
156
154
|
}
|
|
@@ -176,18 +174,26 @@ const AudioFile = ({
|
|
|
176
174
|
manageChunkRecording();
|
|
177
175
|
}, [isSpeaking, stream]);
|
|
178
176
|
|
|
179
|
-
return
|
|
177
|
+
return (
|
|
178
|
+
<TranscriptionStory
|
|
179
|
+
disabled={!stream}
|
|
180
|
+
model={model}
|
|
181
|
+
running={running}
|
|
182
|
+
onRunningChange={setRunning}
|
|
183
|
+
audioRef={ref}
|
|
184
|
+
/>
|
|
185
|
+
);
|
|
180
186
|
};
|
|
181
187
|
|
|
182
|
-
const meta
|
|
188
|
+
const meta = {
|
|
183
189
|
title: 'plugins/plugin-transcription/FileTranscription',
|
|
184
190
|
decorators: [
|
|
191
|
+
withTheme,
|
|
192
|
+
withLayout({ container: 'column' }),
|
|
185
193
|
withPluginManager({
|
|
186
194
|
plugins: [
|
|
187
|
-
ThemePlugin({ tx: defaultTx }),
|
|
188
|
-
StorybookLayoutPlugin(),
|
|
189
195
|
ClientPlugin({
|
|
190
|
-
types: [TestItem,
|
|
196
|
+
types: [TestItem, Person.Person, Organization.Organization, Testing.DocumentType],
|
|
191
197
|
onClientInitialized: async ({ client }) => {
|
|
192
198
|
await client.halo.createIdentity();
|
|
193
199
|
await client.spaces.waitUntilReady();
|
|
@@ -195,21 +201,25 @@ const meta: Meta<typeof AudioFile> = {
|
|
|
195
201
|
await seedTestData(client.spaces.default);
|
|
196
202
|
},
|
|
197
203
|
}),
|
|
198
|
-
SpacePlugin(),
|
|
204
|
+
SpacePlugin({}),
|
|
205
|
+
IntentPlugin(),
|
|
206
|
+
|
|
207
|
+
// UI
|
|
208
|
+
ThemePlugin({ tx: defaultTx }),
|
|
199
209
|
SettingsPlugin(),
|
|
200
210
|
PreviewPlugin(),
|
|
201
|
-
IntentPlugin(),
|
|
202
211
|
TranscriptionPlugin(),
|
|
212
|
+
StorybookLayoutPlugin({}),
|
|
203
213
|
],
|
|
204
214
|
fireEvents: [Events.SetupAppGraph],
|
|
205
215
|
}),
|
|
206
|
-
withTheme,
|
|
207
|
-
withLayout({ fullscreen: true, classNames: 'justify-center' }),
|
|
208
216
|
],
|
|
209
|
-
};
|
|
217
|
+
} satisfies Meta;
|
|
210
218
|
|
|
211
219
|
export default meta;
|
|
212
220
|
|
|
221
|
+
type Story = StoryObj<typeof meta>;
|
|
222
|
+
|
|
213
223
|
const TRANSCRIBER_CONFIG = {
|
|
214
224
|
transcribeAfterChunksAmount: 100,
|
|
215
225
|
prefixBufferChunksAmount: 50,
|
|
@@ -232,15 +242,16 @@ export const Default: StoryObj<typeof AudioFile> = {
|
|
|
232
242
|
},
|
|
233
243
|
};
|
|
234
244
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
245
|
+
// TODO(mykola): Fix sentence normalization.
|
|
246
|
+
// export const WithSentenceNormalization: StoryObj<typeof AudioFile> = {
|
|
247
|
+
// render: AudioFile,
|
|
248
|
+
// args: {
|
|
249
|
+
// detectSpeaking: true,
|
|
250
|
+
// normalizeSentences: true,
|
|
251
|
+
// // https://learnenglish.britishcouncil.org/general-english/audio-zone/living-london
|
|
252
|
+
// audioUrl: 'https://dxos.network/audio-london.m4a',
|
|
253
|
+
// // textUrl: 'https://dxos.network/audio-london.txt',
|
|
254
|
+
// transcriberConfig: TRANSCRIBER_CONFIG,
|
|
255
|
+
// recorderConfig: RECORDER_CONFIG,
|
|
256
|
+
// },
|
|
257
|
+
// };
|
|
@@ -2,22 +2,24 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { log } from '@dxos/log';
|
|
11
9
|
import { Toolbar } from '@dxos/react-ui';
|
|
10
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
11
|
import { mx } from '@dxos/react-ui-theme';
|
|
13
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
14
12
|
|
|
15
13
|
type Word = {
|
|
16
14
|
text: string;
|
|
17
15
|
matched: boolean;
|
|
18
16
|
};
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
type StoryProps = {
|
|
19
|
+
keywords: string[];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const DefaultStory = ({ keywords }: StoryProps) => {
|
|
21
23
|
const [running, setRunning] = useState(false);
|
|
22
24
|
const [matchingWords, setMatchingWords] = useState<Word[]>(keywords.map((word) => ({ text: word, matched: false })));
|
|
23
25
|
|
|
@@ -84,7 +86,7 @@ const SpeechRecognition = ({ keywords }: { keywords: string[] }) => {
|
|
|
84
86
|
}, [running, recognition]);
|
|
85
87
|
|
|
86
88
|
return (
|
|
87
|
-
<div className={mx('flex flex-col gap-2
|
|
89
|
+
<div className={mx('flex flex-col gap-2 is-[30rem]')}>
|
|
88
90
|
<Toolbar.Root>
|
|
89
91
|
<Toolbar.IconButton
|
|
90
92
|
iconOnly
|
|
@@ -99,7 +101,7 @@ const SpeechRecognition = ({ keywords }: { keywords: string[] }) => {
|
|
|
99
101
|
<span
|
|
100
102
|
key={index}
|
|
101
103
|
className={mx(
|
|
102
|
-
'
|
|
104
|
+
'pli-3 plb-1 m-2 rounded border',
|
|
103
105
|
word.matched ? 'bg-red-200 text-red-800 border-red-300' : 'bg-gray-200 text-gray-600 border-gray-300',
|
|
104
106
|
)}
|
|
105
107
|
>
|
|
@@ -113,15 +115,17 @@ const SpeechRecognition = ({ keywords }: { keywords: string[] }) => {
|
|
|
113
115
|
);
|
|
114
116
|
};
|
|
115
117
|
|
|
116
|
-
const meta
|
|
118
|
+
const meta = {
|
|
117
119
|
title: 'plugins/plugin-transcription/KeyWordDetection',
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
+
render: DefaultStory,
|
|
121
|
+
decorators: [withTheme, withLayout({ container: 'column' })],
|
|
122
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
120
123
|
|
|
121
124
|
export default meta;
|
|
122
125
|
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
type Story = StoryObj<typeof meta>;
|
|
127
|
+
|
|
128
|
+
export const SpeechRecognitionAPI: Story = {
|
|
125
129
|
args: {
|
|
126
130
|
keywords: ['kai', 'computer', 'hello'],
|
|
127
131
|
},
|