@dxos/plugin-transcription 0.8.1-main.ba2dec9 → 0.8.1-staging.31c3ee1
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-N4KQHMY4.mjs → TranscriptContainer-JQ3HFHLQ.mjs} +3 -3
- package/dist/lib/browser/app-graph-builder-VDQOVX7P.mjs +191 -0
- package/dist/lib/browser/app-graph-builder-VDQOVX7P.mjs.map +7 -0
- package/dist/lib/browser/chunk-6ZR5MDK3.mjs +19 -0
- package/dist/lib/browser/chunk-6ZR5MDK3.mjs.map +7 -0
- package/dist/lib/browser/chunk-G4B6CPC2.mjs +253 -0
- package/dist/lib/browser/chunk-G4B6CPC2.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GHTRJTEB.mjs → chunk-GU2BNYKZ.mjs} +6 -6
- package/dist/lib/browser/chunk-GU2BNYKZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-K7FOYAXO.mjs +8 -0
- package/dist/lib/browser/{chunk-QIHUPVQD.mjs → chunk-OGNXNGJB.mjs} +21 -28
- package/dist/lib/browser/chunk-OGNXNGJB.mjs.map +7 -0
- package/dist/lib/browser/chunk-YCZISX63.mjs +464 -0
- package/dist/lib/browser/chunk-YCZISX63.mjs.map +7 -0
- package/dist/lib/browser/chunk-YEPT334A.mjs +16 -0
- package/dist/lib/browser/chunk-YEPT334A.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +69 -512
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{intent-resolver-RW6DEJC2.mjs → intent-resolver-4R66ZCKT.mjs} +8 -7
- package/dist/lib/browser/intent-resolver-4R66ZCKT.mjs.map +7 -0
- package/dist/lib/browser/meeting-transcription-state-DLFHQK72.mjs +18 -0
- package/dist/lib/browser/meeting-transcription-state-DLFHQK72.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-UPTZBHVB.mjs → react-surface-FQUHU5G7.mjs} +15 -9
- package/dist/lib/{node-esm/react-surface-2WJQ67LB.mjs.map → browser/react-surface-FQUHU5G7.mjs.map} +2 -2
- package/dist/lib/browser/transcriber-LGMIWDYI.mjs +36 -0
- package/dist/lib/browser/transcriber-LGMIWDYI.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -1
- package/dist/lib/node/{TranscriptContainer-4BWXOVML.cjs → TranscriptContainer-QEYTTT2V.cjs} +8 -8
- package/dist/lib/node/{TranscriptContainer-4BWXOVML.cjs.map → TranscriptContainer-QEYTTT2V.cjs.map} +2 -2
- package/dist/lib/node/app-graph-builder-IFSIVNUR.cjs +200 -0
- package/dist/lib/node/app-graph-builder-IFSIVNUR.cjs.map +7 -0
- package/dist/lib/node/{chunk-HDRXDMK2.cjs → chunk-3KHUSQNW.cjs} +6 -6
- package/dist/lib/node/chunk-3KHUSQNW.cjs.map +7 -0
- package/dist/lib/node/chunk-CZMLKKWT.cjs +35 -0
- package/dist/lib/node/chunk-CZMLKKWT.cjs.map +7 -0
- package/dist/lib/node/chunk-FCCJALOT.cjs +488 -0
- package/dist/lib/node/chunk-FCCJALOT.cjs.map +7 -0
- package/dist/lib/node/{chunk-I35KHI2G.cjs → chunk-LP4FG423.cjs} +5 -5
- package/dist/lib/node/chunk-NVZWGFJL.cjs +42 -0
- package/dist/lib/node/chunk-NVZWGFJL.cjs.map +7 -0
- package/dist/lib/node/{chunk-UIHEGU6Q.cjs → chunk-P4VVD6ZO.cjs} +21 -29
- package/dist/lib/node/chunk-P4VVD6ZO.cjs.map +7 -0
- package/dist/lib/node/chunk-UOFHT4GZ.cjs +280 -0
- package/dist/lib/node/chunk-UOFHT4GZ.cjs.map +7 -0
- package/dist/lib/node/index.cjs +75 -513
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/{intent-resolver-KLBZ25XJ.cjs → intent-resolver-WMMCOUEH.cjs} +12 -11
- package/dist/lib/node/intent-resolver-WMMCOUEH.cjs.map +7 -0
- package/dist/lib/node/{app-graph-builder-YFBX3OTP.cjs → meeting-transcription-state-URIYILEQ.cjs} +14 -6
- package/dist/lib/node/meeting-transcription-state-URIYILEQ.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-NCKXB7EQ.cjs → react-surface-WI2MGWCC.cjs} +17 -12
- package/dist/lib/node/{react-surface-NCKXB7EQ.cjs.map → react-surface-WI2MGWCC.cjs.map} +2 -2
- package/dist/lib/node/transcriber-QG5WPKX4.cjs +49 -0
- package/dist/lib/node/transcriber-QG5WPKX4.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +8 -7
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/{TranscriptContainer-6IKRASR6.mjs → TranscriptContainer-ZXUCOWGY.mjs} +3 -3
- package/dist/lib/node-esm/app-graph-builder-UL6XLIZY.mjs +192 -0
- package/dist/lib/node-esm/app-graph-builder-UL6XLIZY.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-6X7X2UZF.mjs +254 -0
- package/dist/lib/node-esm/chunk-6X7X2UZF.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-KEG3ME4O.mjs → chunk-GIO6J6FE.mjs} +20 -28
- package/dist/lib/node-esm/chunk-GIO6J6FE.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-LORUIVS4.mjs → chunk-HKATMD34.mjs} +6 -6
- package/dist/lib/node-esm/chunk-HKATMD34.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-2CPKXRN6.mjs → chunk-J4D2RBBH.mjs} +3 -3
- package/dist/lib/node-esm/chunk-PTZHDZ36.mjs +17 -0
- package/dist/lib/node-esm/chunk-PTZHDZ36.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-X4DDJIVL.mjs +21 -0
- package/dist/lib/node-esm/chunk-X4DDJIVL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YQYBLFNI.mjs +465 -0
- package/dist/lib/node-esm/chunk-YQYBLFNI.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +69 -512
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/{intent-resolver-4FMISUPW.mjs → intent-resolver-QN2LO5TX.mjs} +8 -7
- package/dist/lib/node-esm/intent-resolver-QN2LO5TX.mjs.map +7 -0
- package/dist/lib/node-esm/meeting-transcription-state-ZYVRAW6Y.mjs +19 -0
- package/dist/lib/node-esm/meeting-transcription-state-ZYVRAW6Y.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-2WJQ67LB.mjs → react-surface-PCH6NTVB.mjs} +15 -9
- package/dist/lib/{browser/react-surface-UPTZBHVB.mjs.map → node-esm/react-surface-PCH6NTVB.mjs.map} +2 -2
- package/dist/lib/node-esm/transcriber-TMPYZ5L4.mjs +37 -0
- package/dist/lib/node-esm/transcriber-TMPYZ5L4.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +2 -1
- package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +16 -1
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +5 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/meeting-transcription-state.d.ts +6 -0
- package/dist/types/src/capabilities/meeting-transcription-state.d.ts.map +1 -0
- package/dist/types/src/capabilities/transcriber.d.ts +7 -0
- package/dist/types/src/capabilities/transcriber.d.ts.map +1 -0
- package/dist/types/src/components/Transcript/Transcript.d.ts +5 -2
- package/dist/types/src/components/Transcript/Transcript.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts.map +1 -1
- package/dist/types/src/components/TranscriptContainer.d.ts +1 -0
- package/dist/types/src/components/TranscriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/transcription.stories.d.ts +1 -1
- package/dist/types/src/components/transcription.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/useTranscriber.d.ts +3 -6
- package/dist/types/src/hooks/useTranscriber.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -9
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/transcriber/index.d.ts +1 -0
- package/dist/types/src/transcriber/index.d.ts.map +1 -1
- package/dist/types/src/{transcription-manager.d.ts → transcriber/transcription-manager.d.ts} +5 -2
- package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +14 -18
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +13 -19
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +2 -6
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util/random-queue-dxn.d.ts +2 -2
- package/dist/types/src/util/random-queue-dxn.d.ts.map +1 -1
- package/package.json +40 -36
- package/src/TranscriptionPlugin.tsx +24 -7
- package/src/capabilities/app-graph-builder.ts +147 -2
- package/src/capabilities/capabilities.ts +16 -2
- package/src/capabilities/index.ts +2 -0
- package/src/capabilities/intent-resolver.ts +4 -3
- package/src/capabilities/meeting-transcription-state.ts +16 -0
- package/src/capabilities/react-surface.tsx +3 -3
- package/src/capabilities/transcriber.ts +48 -0
- package/src/components/Transcript/Transcript.stories.tsx +46 -27
- package/src/components/Transcript/Transcript.tsx +206 -50
- package/src/components/TranscriptContainer.tsx +9 -147
- package/src/components/transcription.stories.tsx +11 -13
- package/src/hooks/useTranscriber.ts +12 -37
- package/src/index.ts +2 -2
- package/src/meta.ts +2 -2
- package/src/transcriber/index.ts +1 -0
- package/src/{transcription-manager.ts → transcriber/transcription-manager.ts} +16 -5
- package/src/translations.ts +6 -6
- package/src/types/schema.ts +7 -5
- package/src/types/types.ts +4 -2
- package/src/util/random-queue-dxn.ts +2 -2
- package/dist/lib/browser/app-graph-builder-ZSSJIFY7.mjs +0 -7
- package/dist/lib/browser/app-graph-builder-ZSSJIFY7.mjs.map +0 -7
- package/dist/lib/browser/chunk-BDVUIRBP.mjs +0 -8
- package/dist/lib/browser/chunk-GHTRJTEB.mjs.map +0 -7
- package/dist/lib/browser/chunk-QIHUPVQD.mjs.map +0 -7
- package/dist/lib/browser/chunk-YX447BJ4.mjs +0 -241
- package/dist/lib/browser/chunk-YX447BJ4.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-RW6DEJC2.mjs.map +0 -7
- package/dist/lib/node/app-graph-builder-YFBX3OTP.cjs.map +0 -7
- package/dist/lib/node/chunk-ANSWGFMS.cjs +0 -267
- package/dist/lib/node/chunk-ANSWGFMS.cjs.map +0 -7
- package/dist/lib/node/chunk-HDRXDMK2.cjs.map +0 -7
- package/dist/lib/node/chunk-UIHEGU6Q.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-KLBZ25XJ.cjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-77GQG6UF.mjs +0 -9
- package/dist/lib/node-esm/app-graph-builder-77GQG6UF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KEG3ME4O.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LORUIVS4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZMK2QLW2.mjs +0 -242
- package/dist/lib/node-esm/chunk-ZMK2QLW2.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-4FMISUPW.mjs.map +0 -7
- package/dist/types/src/transcription-manager.d.ts.map +0 -1
- /package/dist/lib/browser/{TranscriptContainer-N4KQHMY4.mjs.map → TranscriptContainer-JQ3HFHLQ.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-BDVUIRBP.mjs.map → chunk-K7FOYAXO.mjs.map} +0 -0
- /package/dist/lib/node/{chunk-I35KHI2G.cjs.map → chunk-LP4FG423.cjs.map} +0 -0
- /package/dist/lib/node-esm/{TranscriptContainer-6IKRASR6.mjs.map → TranscriptContainer-ZXUCOWGY.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-2CPKXRN6.mjs.map → chunk-J4D2RBBH.mjs.map} +0 -0
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';
|
|
6
|
+
import { QueueImpl } from '@dxos/echo-db';
|
|
7
|
+
import { isInstanceOf } from '@dxos/echo-schema';
|
|
6
8
|
import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
|
|
7
9
|
|
|
8
|
-
import { AppGraphBuilder, IntentResolver, ReactSurface,
|
|
9
|
-
import { meta
|
|
10
|
+
import { AppGraphBuilder, IntentResolver, MeetingTranscriptionState, ReactSurface, Transcriber } from './capabilities';
|
|
11
|
+
import { meta } from './meta';
|
|
10
12
|
import translations from './translations';
|
|
11
|
-
import { TranscriptType } from './types';
|
|
13
|
+
import { TranscriptBlock, TranscriptType } from './types';
|
|
12
14
|
|
|
13
15
|
export const TranscriptionPlugin = () =>
|
|
14
16
|
definePlugin(meta, [
|
|
@@ -19,18 +21,33 @@ export const TranscriptionPlugin = () =>
|
|
|
19
21
|
}),
|
|
20
22
|
defineModule({
|
|
21
23
|
id: `${meta.id}/module/transcription`,
|
|
22
|
-
activatesOn: Events.
|
|
23
|
-
activate:
|
|
24
|
+
activatesOn: Events.SetupAppGraph,
|
|
25
|
+
activate: Transcriber,
|
|
26
|
+
}),
|
|
27
|
+
defineModule({
|
|
28
|
+
id: `${meta.id}/module/meeting-transcription-state`,
|
|
29
|
+
activatesOn: Events.SetupAppGraph,
|
|
30
|
+
activate: MeetingTranscriptionState,
|
|
24
31
|
}),
|
|
25
32
|
defineModule({
|
|
26
33
|
id: `${meta.id}/module/metadata`,
|
|
27
34
|
activatesOn: Events.SetupMetadata,
|
|
28
|
-
activate: () =>
|
|
35
|
+
activate: (context) =>
|
|
29
36
|
contributes(Capabilities.Metadata, {
|
|
30
37
|
id: TranscriptType.typename,
|
|
31
38
|
metadata: {
|
|
32
|
-
placeholder: ['transcript title placeholder', { ns: TRANSCRIPTION_PLUGIN }],
|
|
33
39
|
icon: 'ph--subtitles--regular',
|
|
40
|
+
// TODO(wittjosiah): Factor out. Artifact? Separate capability?
|
|
41
|
+
getTextContent: async (transcript: TranscriptType) => {
|
|
42
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
43
|
+
const queue = new QueueImpl(client.edge, transcript.queue.dxn);
|
|
44
|
+
await queue.refresh();
|
|
45
|
+
const content = queue.items
|
|
46
|
+
.filter((block) => isInstanceOf(TranscriptBlock, block))
|
|
47
|
+
.map((block) => `${block.authorName}: ${block.segments.map((segment) => segment.text).join('\n')}`)
|
|
48
|
+
.join('\n\n');
|
|
49
|
+
return content;
|
|
50
|
+
},
|
|
34
51
|
},
|
|
35
52
|
}),
|
|
36
53
|
}),
|
|
@@ -2,6 +2,151 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Capabilities, contributes, type PluginsContext } from '@dxos/app-framework';
|
|
5
|
+
import { Capabilities, contributes, createIntent, type PluginsContext } from '@dxos/app-framework';
|
|
6
|
+
import { fullyQualifiedId, getSpace, makeRef, type Space } from '@dxos/client/echo';
|
|
7
|
+
import { generateName } from '@dxos/display-name';
|
|
8
|
+
import { getSchemaTypename, isInstanceOf } from '@dxos/echo-schema';
|
|
9
|
+
import { invariant } from '@dxos/invariant';
|
|
10
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
11
|
+
import { PLANK_COMPANION_TYPE, ATTENDABLE_PATH_SEPARATOR } from '@dxos/plugin-deck/types';
|
|
12
|
+
import { createExtension, type Node } from '@dxos/plugin-graph';
|
|
13
|
+
import { MeetingCapabilities, type CallState, type MediaState } from '@dxos/plugin-meeting';
|
|
14
|
+
import { MeetingType } from '@dxos/plugin-meeting/types';
|
|
15
|
+
import { buf } from '@dxos/protocols/buf';
|
|
16
|
+
import {
|
|
17
|
+
TranscriptionPayloadSchema,
|
|
18
|
+
type TranscriptionPayload as TranscriptionPayloadProto,
|
|
19
|
+
} from '@dxos/protocols/buf/dxos/edge/calls_pb';
|
|
20
|
+
import { keyToFallback } from '@dxos/util';
|
|
6
21
|
|
|
7
|
-
|
|
22
|
+
import { TranscriptionCapabilities } from './capabilities';
|
|
23
|
+
import { TRANSCRIPTION_PLUGIN } from '../meta';
|
|
24
|
+
import { TranscriptionManager } from '../transcriber';
|
|
25
|
+
import { TranscriptionAction, TranscriptType } from '../types';
|
|
26
|
+
|
|
27
|
+
// TODO(wittjosiah): Factor out.
|
|
28
|
+
// TODO(wittjosiah): Can we stop using protobuf for this?
|
|
29
|
+
type TranscriptionPayload = buf.MessageInitShape<typeof TranscriptionPayloadSchema>;
|
|
30
|
+
const codec = {
|
|
31
|
+
encode: (message: TranscriptionPayload): Uint8Array => {
|
|
32
|
+
return buf.toBinary(TranscriptionPayloadSchema, buf.create(TranscriptionPayloadSchema, message));
|
|
33
|
+
},
|
|
34
|
+
decode: (message: Uint8Array): TranscriptionPayloadProto => {
|
|
35
|
+
return buf.fromBinary(TranscriptionPayloadSchema, message);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const getMeetingTranscript = async (
|
|
40
|
+
context: PluginsContext,
|
|
41
|
+
meeting: MeetingType,
|
|
42
|
+
): Promise<TranscriptType | undefined> => {
|
|
43
|
+
const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
|
|
44
|
+
|
|
45
|
+
const typename = getSchemaTypename(TranscriptType)!;
|
|
46
|
+
const existing = await meeting.artifacts[typename]?.load();
|
|
47
|
+
if (existing instanceof TranscriptType) {
|
|
48
|
+
return existing;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const space = getSpace(meeting);
|
|
52
|
+
invariant(space);
|
|
53
|
+
const { data } = await dispatch(createIntent(TranscriptionAction.Create, { spaceId: space.id }));
|
|
54
|
+
meeting.artifacts[typename] = makeRef(data!.object);
|
|
55
|
+
return data?.object;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// TODO(wittjosiah): Introduce a sound that plays when transcription is activated/deactivated.
|
|
59
|
+
export default (context: PluginsContext) =>
|
|
60
|
+
contributes(Capabilities.AppGraphBuilder, [
|
|
61
|
+
createExtension({
|
|
62
|
+
id: `${TRANSCRIPTION_PLUGIN}/meeting-transcript`,
|
|
63
|
+
filter: (node): node is Node<MeetingType> =>
|
|
64
|
+
isInstanceOf(MeetingType, node.data) && node.type !== PLANK_COMPANION_TYPE,
|
|
65
|
+
actions: ({ node }) => {
|
|
66
|
+
const meeting = node.data;
|
|
67
|
+
const state = context.requestCapability(TranscriptionCapabilities.MeetingTranscriptionState);
|
|
68
|
+
return [
|
|
69
|
+
{
|
|
70
|
+
id: `${fullyQualifiedId(meeting)}/action/start-stop-transcription`,
|
|
71
|
+
data: async () => {
|
|
72
|
+
const call = context.requestCapability(MeetingCapabilities.CallManager);
|
|
73
|
+
invariant(state.transcriptionManager);
|
|
74
|
+
state.enabled = !state.enabled;
|
|
75
|
+
void state.transcriptionManager.setEnabled(state.enabled);
|
|
76
|
+
const transcript = await getMeetingTranscript(context, meeting);
|
|
77
|
+
invariant(transcript, 'Failed to create transcript');
|
|
78
|
+
call.setActivity(getSchemaTypename(TranscriptType)!, {
|
|
79
|
+
value: codec.encode({
|
|
80
|
+
enabled: state.enabled,
|
|
81
|
+
queueDxn: transcript.queue.dxn.toString(),
|
|
82
|
+
}),
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
properties: {
|
|
86
|
+
label: state.enabled
|
|
87
|
+
? ['stop transcription label', { ns: TRANSCRIPTION_PLUGIN }]
|
|
88
|
+
: ['start transcription label', { ns: TRANSCRIPTION_PLUGIN }],
|
|
89
|
+
icon: 'ph--record--regular',
|
|
90
|
+
disposition: 'toolbar',
|
|
91
|
+
classNames: state.enabled ? 'text-activeInCall' : '',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
];
|
|
95
|
+
},
|
|
96
|
+
connector: ({ node }) => {
|
|
97
|
+
const meeting = node.data;
|
|
98
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
99
|
+
const state = context.requestCapability(TranscriptionCapabilities.MeetingTranscriptionState);
|
|
100
|
+
|
|
101
|
+
return [
|
|
102
|
+
{
|
|
103
|
+
id: `${fullyQualifiedId(meeting)}${ATTENDABLE_PATH_SEPARATOR}${getSchemaTypename(TranscriptType)}`,
|
|
104
|
+
type: PLANK_COMPANION_TYPE,
|
|
105
|
+
data: meeting.artifacts[getSchemaTypename(TranscriptType)!]?.target,
|
|
106
|
+
properties: {
|
|
107
|
+
label: ['transcript companion label', { ns: TRANSCRIPTION_PLUGIN }],
|
|
108
|
+
icon: 'ph--subtitles--regular',
|
|
109
|
+
disposition: 'hidden',
|
|
110
|
+
schema: TranscriptType,
|
|
111
|
+
getIntent: ({ space }: { space: Space }) =>
|
|
112
|
+
createIntent(TranscriptionAction.Create, { spaceId: space.id }),
|
|
113
|
+
onJoin: () => {
|
|
114
|
+
const transcriptionManager = new TranscriptionManager(client.edge);
|
|
115
|
+
const identity = client.halo.identity.get();
|
|
116
|
+
invariant(identity);
|
|
117
|
+
transcriptionManager.setName(
|
|
118
|
+
identity.profile?.displayName ?? generateName(identity.identityKey.toHex()),
|
|
119
|
+
);
|
|
120
|
+
const fallbackValue = keyToFallback(identity!.identityKey);
|
|
121
|
+
const userHue = identity!.profile?.data?.hue || fallbackValue.hue;
|
|
122
|
+
transcriptionManager.setHue(userHue);
|
|
123
|
+
void transcriptionManager.open();
|
|
124
|
+
state.transcriptionManager = transcriptionManager;
|
|
125
|
+
},
|
|
126
|
+
onLeave: () => {
|
|
127
|
+
void state.transcriptionManager?.close();
|
|
128
|
+
state.transcriptionManager = undefined;
|
|
129
|
+
state.enabled = false;
|
|
130
|
+
},
|
|
131
|
+
onCallStateUpdated: (callState: CallState) => {
|
|
132
|
+
const typename = getSchemaTypename(TranscriptType);
|
|
133
|
+
const transcription = typename ? callState.activities?.[typename] : undefined;
|
|
134
|
+
if (!transcription?.payload?.value) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const payload = codec.decode(transcription.payload.value);
|
|
139
|
+
state.enabled = payload.enabled;
|
|
140
|
+
void state.transcriptionManager?.setEnabled(payload.enabled);
|
|
141
|
+
void state.transcriptionManager?.setQueue(payload.queueDxn);
|
|
142
|
+
},
|
|
143
|
+
onMediaStateUpdated: ([mediaState, isSpeaking]: [MediaState, boolean]) => {
|
|
144
|
+
void state.transcriptionManager?.setAudioTrack(mediaState.audioTrack);
|
|
145
|
+
void state.transcriptionManager?.setRecording(isSpeaking);
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
];
|
|
150
|
+
},
|
|
151
|
+
}),
|
|
152
|
+
]);
|
|
@@ -3,10 +3,24 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { defineCapability } from '@dxos/app-framework';
|
|
6
|
+
import { type ReactiveObject } from '@dxos/live-object';
|
|
6
7
|
|
|
7
8
|
import { TRANSCRIPTION_PLUGIN } from '../meta';
|
|
9
|
+
import { type TranscriberParams, type Transcriber, type TranscriptionManager } from '../transcriber';
|
|
8
10
|
|
|
9
11
|
export namespace TranscriptionCapabilities {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
export type GetTranscriberProps = {
|
|
13
|
+
audioStreamTrack: MediaStreamTrack;
|
|
14
|
+
onSegments: TranscriberParams['onSegments'];
|
|
15
|
+
};
|
|
16
|
+
export type GetTranscriber = (props: GetTranscriberProps) => Transcriber;
|
|
17
|
+
export const Transcriber = defineCapability<GetTranscriber>(`${TRANSCRIPTION_PLUGIN}/capability/transcriber`);
|
|
18
|
+
|
|
19
|
+
export type MeetingTranscriptionState = ReactiveObject<{
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
transcriptionManager?: TranscriptionManager;
|
|
22
|
+
}>;
|
|
23
|
+
export const MeetingTranscriptionState = defineCapability<MeetingTranscriptionState>(
|
|
24
|
+
`${TRANSCRIPTION_PLUGIN}/capability/meeting-transcription-state`,
|
|
25
|
+
);
|
|
12
26
|
}
|
|
@@ -6,6 +6,8 @@ import { lazy } from '@dxos/app-framework';
|
|
|
6
6
|
|
|
7
7
|
export const AppGraphBuilder = lazy(() => import('./app-graph-builder'));
|
|
8
8
|
export const IntentResolver = lazy(() => import('./intent-resolver'));
|
|
9
|
+
export const MeetingTranscriptionState = lazy(() => import('./meeting-transcription-state'));
|
|
9
10
|
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
11
|
+
export const Transcriber = lazy(() => import('./transcriber'));
|
|
10
12
|
|
|
11
13
|
export * from './capabilities';
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Capabilities, contributes, createResolver, type PluginsContext } from '@dxos/app-framework';
|
|
6
|
-
import { create } from '@dxos/live-object';
|
|
6
|
+
import { create, refFromDXN } from '@dxos/live-object';
|
|
7
|
+
import { type SpaceId } from '@dxos/react-client/echo';
|
|
7
8
|
|
|
8
9
|
import { TranscriptionAction, TranscriptType } from '../types';
|
|
9
10
|
import { getTimeStr, randomQueueDxn } from '../util';
|
|
@@ -12,9 +13,9 @@ export default (context: PluginsContext) =>
|
|
|
12
13
|
contributes(Capabilities.IntentResolver, [
|
|
13
14
|
createResolver({
|
|
14
15
|
intent: TranscriptionAction.Create,
|
|
15
|
-
resolve: ({ name }) => {
|
|
16
|
+
resolve: ({ name, spaceId }) => {
|
|
16
17
|
const transcript = create(TranscriptType, {
|
|
17
|
-
queue: randomQueueDxn()
|
|
18
|
+
queue: refFromDXN(randomQueueDxn(spaceId as SpaceId)),
|
|
18
19
|
name: name ?? `Transcript ${getTimeStr(Date.now())}`,
|
|
19
20
|
});
|
|
20
21
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { contributes } from '@dxos/app-framework';
|
|
6
|
+
import { create } from '@dxos/live-object';
|
|
7
|
+
|
|
8
|
+
import { TranscriptionCapabilities } from './capabilities';
|
|
9
|
+
|
|
10
|
+
export default () => {
|
|
11
|
+
const state = create<TranscriptionCapabilities.MeetingTranscriptionState>({
|
|
12
|
+
enabled: false,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return contributes(TranscriptionCapabilities.MeetingTranscriptionState, state);
|
|
16
|
+
};
|
|
@@ -13,9 +13,9 @@ import { isTranscript, type TranscriptType } from '../types';
|
|
|
13
13
|
export default () =>
|
|
14
14
|
contributes(Capabilities.ReactSurface, [
|
|
15
15
|
createSurface({
|
|
16
|
-
id: TRANSCRIPTION_PLUGIN
|
|
17
|
-
role: 'article',
|
|
16
|
+
id: `${TRANSCRIPTION_PLUGIN}/article/transcript`,
|
|
17
|
+
role: ['article', 'section'],
|
|
18
18
|
filter: (data): data is { subject: TranscriptType } => isTranscript(data.subject),
|
|
19
|
-
component: ({ data, role }) => <TranscriptionContainer transcript={data.subject} />,
|
|
19
|
+
component: ({ data, role }) => <TranscriptionContainer transcript={data.subject} role={role} />,
|
|
20
20
|
}),
|
|
21
21
|
]);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { contributes } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { TranscriptionCapabilities } from './capabilities';
|
|
8
|
+
import { MediaStreamRecorder, Transcriber } from '../transcriber';
|
|
9
|
+
|
|
10
|
+
// TODO(burdon): Move to config?
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Length of the chunk in ms.
|
|
14
|
+
*/
|
|
15
|
+
const RECORD_INTERVAL = 200;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Number of chunks to save before the user starts speaking.
|
|
19
|
+
*/
|
|
20
|
+
const PREFIXED_CHUNKS_AMOUNT = 10;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Number of chunks to transcribe automatically after.
|
|
24
|
+
* Combined should be mess than 25MB or whisper would fail.
|
|
25
|
+
*/
|
|
26
|
+
const TRANSCRIBE_AFTER_CHUNKS_AMOUNT = 50;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Records audio while user is speaking and transcribes it after user is done speaking.
|
|
30
|
+
*/
|
|
31
|
+
export default () => {
|
|
32
|
+
const getTranscriber: TranscriptionCapabilities.GetTranscriber = ({ audioStreamTrack, onSegments }) => {
|
|
33
|
+
// Initialize audio transcription.
|
|
34
|
+
return new Transcriber({
|
|
35
|
+
config: {
|
|
36
|
+
transcribeAfterChunksAmount: TRANSCRIBE_AFTER_CHUNKS_AMOUNT,
|
|
37
|
+
prefixBufferChunksAmount: PREFIXED_CHUNKS_AMOUNT,
|
|
38
|
+
},
|
|
39
|
+
recorder: new MediaStreamRecorder({
|
|
40
|
+
mediaStreamTrack: audioStreamTrack,
|
|
41
|
+
interval: RECORD_INTERVAL,
|
|
42
|
+
}),
|
|
43
|
+
onSegments,
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return contributes(TranscriptionCapabilities.Transcriber, getTranscriber);
|
|
48
|
+
};
|
|
@@ -5,31 +5,58 @@
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
7
|
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
|
-
import React from 'react';
|
|
8
|
+
import React, { useEffect, useState } from 'react';
|
|
9
9
|
|
|
10
10
|
import { faker } from '@dxos/random';
|
|
11
|
-
import {
|
|
11
|
+
import { hues } from '@dxos/react-ui-theme';
|
|
12
12
|
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
13
13
|
|
|
14
14
|
import { Transcript } from './Transcript';
|
|
15
15
|
import translations from '../../translations';
|
|
16
16
|
|
|
17
|
+
let start = new Date(Date.now() - 24 * 60 * 60 * 10_000);
|
|
18
|
+
const next = () => {
|
|
19
|
+
start = new Date(start.getTime() + Math.random() * 10_000);
|
|
20
|
+
return start;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const users = Array.from({ length: 5 }, () => ({
|
|
24
|
+
authorName: faker.person.fullName(),
|
|
25
|
+
authorHue: faker.helpers.arrayElement(hues),
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
const createBlock = () => {
|
|
29
|
+
const author = faker.helpers.arrayElement(users);
|
|
30
|
+
return {
|
|
31
|
+
id: faker.string.uuid(),
|
|
32
|
+
...author,
|
|
33
|
+
segments: Array.from({ length: 1 + Math.floor(Math.random() * 2) }, () => ({
|
|
34
|
+
started: next(),
|
|
35
|
+
text: faker.lorem.paragraph(),
|
|
36
|
+
})),
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
17
40
|
const meta: Meta<typeof Transcript> = {
|
|
18
41
|
title: 'plugins/plugin-transcription/Transcript',
|
|
19
42
|
component: Transcript,
|
|
20
|
-
render: (args) =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
43
|
+
render: ({ blocks: initialBlocks = [], ...args }) => {
|
|
44
|
+
const [blocks, setBlocks] = useState(initialBlocks);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const i = setInterval(() => {
|
|
47
|
+
setBlocks((blocks) => [...blocks, createBlock()]);
|
|
48
|
+
}, 1_000);
|
|
49
|
+
|
|
50
|
+
return () => clearInterval(i);
|
|
51
|
+
}, []);
|
|
52
|
+
|
|
53
|
+
return <Transcript {...args} blocks={blocks} />;
|
|
54
|
+
},
|
|
27
55
|
decorators: [
|
|
28
56
|
withTheme,
|
|
29
57
|
withLayout({
|
|
30
58
|
tooltips: true,
|
|
31
59
|
fullscreen: true,
|
|
32
|
-
classNames: 'justify-center',
|
|
33
60
|
}),
|
|
34
61
|
],
|
|
35
62
|
parameters: {
|
|
@@ -41,25 +68,17 @@ export default meta;
|
|
|
41
68
|
|
|
42
69
|
type Story = StoryObj<typeof Transcript>;
|
|
43
70
|
|
|
44
|
-
let start = new Date();
|
|
45
|
-
const next = () => {
|
|
46
|
-
start = new Date(start.getTime() - Math.random() * 30_000);
|
|
47
|
-
return start;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const names = Array.from({ length: 3 }, () => faker.person.fullName());
|
|
51
|
-
|
|
52
71
|
export const Default: Story = {
|
|
53
72
|
args: {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
segments: Array.from({ length: 1 + Math.floor(Math.random() * 3) }, () => ({
|
|
58
|
-
started: next(),
|
|
59
|
-
text: faker.lorem.paragraph(),
|
|
60
|
-
})),
|
|
61
|
-
})).reverse(),
|
|
73
|
+
ignoreAttention: true,
|
|
74
|
+
attendableId: 'story',
|
|
75
|
+
blocks: Array.from({ length: 10 }, createBlock),
|
|
62
76
|
},
|
|
63
77
|
};
|
|
64
78
|
|
|
65
|
-
export const Empty: Story = {
|
|
79
|
+
export const Empty: Story = {
|
|
80
|
+
args: {
|
|
81
|
+
ignoreAttention: true,
|
|
82
|
+
attendableId: 'story',
|
|
83
|
+
},
|
|
84
|
+
};
|