@dxos/plugin-transcription 0.8.4-main.f9ba587 → 0.8.4-main.fcfe5033a5
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/blueprints/index.mjs +31 -0
- package/dist/lib/browser/blueprints/index.mjs.map +7 -0
- package/dist/lib/browser/chunk-5LWSJZTZ.mjs +17 -0
- package/dist/lib/browser/chunk-5LWSJZTZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-HOOPZ7EM.mjs +35 -0
- package/dist/lib/browser/chunk-HOOPZ7EM.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-KOX4WNAR.mjs +111 -0
- package/dist/lib/browser/chunk-KOX4WNAR.mjs.map +7 -0
- package/dist/lib/browser/create-BTWYQ6IM.mjs +21 -0
- package/dist/lib/browser/create-BTWYQ6IM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1181 -93
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/open-CYRYIEZI.mjs +27 -0
- package/dist/lib/browser/open-CYRYIEZI.mjs.map +7 -0
- package/dist/lib/browser/operations/index.mjs +13 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/summarize-X2ZYTN7S.mjs +79 -0
- package/dist/lib/browser/summarize-X2ZYTN7S.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -8
- package/dist/lib/node-esm/blueprints/index.mjs +32 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-MT5I4NH5.mjs +112 -0
- package/dist/lib/node-esm/chunk-MT5I4NH5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NVM2QUMX.mjs +37 -0
- package/dist/lib/node-esm/chunk-NVM2QUMX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-X74WYCCE.mjs +19 -0
- package/dist/lib/node-esm/chunk-X74WYCCE.mjs.map +7 -0
- package/dist/lib/node-esm/create-MLUFPST2.mjs +22 -0
- package/dist/lib/node-esm/create-MLUFPST2.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1181 -93
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/open-5IOC2U4Z.mjs +28 -0
- package/dist/lib/node-esm/open-5IOC2U4Z.mjs.map +7 -0
- package/dist/lib/node-esm/operations/index.mjs +14 -0
- package/dist/lib/node-esm/operations/index.mjs.map +7 -0
- package/dist/lib/node-esm/summarize-IORITU7T.mjs +80 -0
- package/dist/lib/node-esm/summarize-IORITU7T.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +4 -8
- package/dist/types/src/TranscriptionPlugin.d.ts +2 -1
- package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/transcription-blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/transcription-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -4
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/transcriber.d.ts +4 -3
- package/dist/types/src/capabilities/transcriber.d.ts.map +1 -1
- package/dist/types/src/components/Transcription/Transcription.d.ts +18 -0
- package/dist/types/src/components/Transcription/Transcription.d.ts.map +1 -0
- package/dist/types/src/components/Transcription/Transcription.stories.d.ts +40 -0
- package/dist/types/src/components/Transcription/Transcription.stories.d.ts.map +1 -0
- package/dist/types/src/components/Transcription/index.d.ts +2 -0
- package/dist/types/src/components/Transcription/index.d.ts.map +1 -0
- package/dist/types/src/components/Transcription/transcription-extension.d.ts +15 -0
- package/dist/types/src/components/Transcription/transcription-extension.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts +8 -7
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts +10 -6
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts +11 -10
- 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/containers/TranscriptionContainer/TranscriptionContainer.d.ts +6 -0
- package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts.map +1 -0
- package/dist/types/src/containers/TranscriptionContainer/index.d.ts +2 -0
- package/dist/types/src/containers/TranscriptionContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useAudioFile.d.ts.map +1 -1
- package/dist/types/src/hooks/useQueueModelAdapter.d.ts +1 -1
- package/dist/types/src/hooks/useQueueModelAdapter.d.ts.map +1 -1
- package/dist/types/src/hooks/useTranscriber.d.ts +1 -1
- package/dist/types/src/hooks/useTranscriber.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/create.d.ts +5 -0
- package/dist/types/src/operations/create.d.ts.map +1 -0
- package/dist/types/src/operations/definitions.d.ts +917 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/open.d.ts +5 -0
- package/dist/types/src/operations/open.d.ts.map +1 -0
- package/dist/types/src/operations/summarize.d.ts +8 -0
- package/dist/types/src/operations/summarize.d.ts.map +1 -0
- package/dist/types/src/segments-normalization/message-normalizer.d.ts +5 -5
- package/dist/types/src/segments-normalization/message-normalizer.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/normalization.d.ts +363 -328
- 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 +10 -10
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/transcriber/index.d.ts +1 -1
- package/dist/types/src/transcriber/index.d.ts.map +1 -1
- package/dist/types/src/transcriber/media-stream-recorder.d.ts +3 -3
- package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.d.ts +4 -4
- package/dist/types/src/transcriber/transcriber.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcription-manager.d.ts +12 -13
- package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +7 -7
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +18 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +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/src/util/index.d.ts +1 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/render-byline.d.ts +4 -0
- package/dist/types/src/util/render-byline.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +109 -73
- package/src/TranscriptionPlugin.tsx +46 -59
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/transcription-blueprint.ts +30 -0
- package/src/capabilities/blueprint-definition.ts +17 -0
- package/src/capabilities/index.ts +9 -6
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +23 -14
- package/src/capabilities/transcriber.ts +52 -42
- package/src/components/{Transcript/Transcript.stories.tsx → Transcription/Transcription.stories.tsx} +73 -66
- package/src/components/Transcription/Transcription.tsx +64 -0
- package/src/components/{Transcript → Transcription}/index.ts +1 -1
- package/src/components/{Transcript/transcript-extension.ts → Transcription/transcription-extension.ts} +15 -48
- package/src/components/index.ts +1 -6
- package/src/components/stories/FileTranscription.stories.tsx +78 -70
- package/src/components/stories/KeyWordRecognition.stories.tsx +17 -13
- package/src/components/stories/MicrophoneTranscription.stories.tsx +84 -100
- package/src/components/stories/TranscriptionStory.tsx +15 -13
- package/src/containers/TranscriptionContainer/TranscriptionContainer.tsx +35 -0
- package/src/containers/TranscriptionContainer/index.ts +5 -0
- package/src/containers/index.ts +7 -0
- package/src/hooks/useAudioFile.ts +49 -53
- package/src/hooks/useQueueModelAdapter.ts +1 -1
- package/src/hooks/useTranscriber.ts +9 -3
- package/src/hooks/useVoiceInput.ts +3 -3
- package/src/index.ts +1 -1
- package/src/meta.ts +9 -6
- package/src/model/model.test.ts +27 -21
- package/src/operations/create.ts +24 -0
- package/src/operations/definitions.ts +101 -0
- package/src/operations/index.ts +13 -0
- package/src/operations/open.ts +28 -0
- package/src/operations/summarize.ts +102 -0
- package/src/segments-normalization/message-normalizer.ts +19 -14
- package/src/segments-normalization/normalization.test.ts +26 -33
- package/src/segments-normalization/normalization.ts +67 -96
- package/src/segments-normalization/utils.ts +2 -2
- package/src/testing/testing.ts +41 -41
- package/src/transcriber/index.ts +1 -1
- package/src/transcriber/media-stream-recorder.ts +4 -4
- package/src/transcriber/transcriber.browser.test.ts +5 -5
- package/src/transcriber/transcriber.ts +10 -12
- package/src/transcriber/transcription-manager.ts +37 -52
- package/src/translations.ts +7 -7
- package/src/types/capabilities.ts +34 -0
- package/src/types/index.ts +1 -1
- package/src/types/types.ts +0 -23
- package/src/util/index.ts +1 -0
- package/src/util/render-byline.ts +33 -0
- package/dist/lib/browser/TranscriptContainer-E5NBJPAY.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-EQBICGOD.mjs +0 -8
- package/dist/lib/browser/chunk-EQBICGOD.mjs.map +0 -7
- package/dist/lib/browser/chunk-F2WY3YTD.mjs +0 -764
- package/dist/lib/browser/chunk-F2WY3YTD.mjs.map +0 -7
- package/dist/lib/browser/chunk-R7INNNUQ.mjs +0 -55
- package/dist/lib/browser/chunk-R7INNNUQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-U6QBOGTN.mjs +0 -16
- package/dist/lib/browser/chunk-U6QBOGTN.mjs.map +0 -7
- package/dist/lib/browser/chunk-VDKDOZRR.mjs +0 -495
- package/dist/lib/browser/chunk-VDKDOZRR.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-3O33MMP5.mjs +0 -30
- package/dist/lib/browser/intent-resolver-3O33MMP5.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FJTMNF3K.mjs +0 -34
- package/dist/lib/browser/react-surface-FJTMNF3K.mjs.map +0 -7
- package/dist/lib/browser/transcriber-YVOTUBKQ.mjs +0 -56
- package/dist/lib/browser/transcriber-YVOTUBKQ.mjs.map +0 -7
- package/dist/lib/node-esm/TranscriptContainer-UOS7JG72.mjs +0 -12
- package/dist/lib/node-esm/chunk-DN522SAP.mjs +0 -10
- package/dist/lib/node-esm/chunk-DN522SAP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSCG4XPR.mjs +0 -496
- package/dist/lib/node-esm/chunk-HSCG4XPR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Q3JKLPTW.mjs +0 -765
- package/dist/lib/node-esm/chunk-Q3JKLPTW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RHF2ALML.mjs +0 -17
- package/dist/lib/node-esm/chunk-RHF2ALML.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-U65ZWK3L.mjs +0 -56
- package/dist/lib/node-esm/chunk-U65ZWK3L.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XMUCZBP3.mjs +0 -21
- package/dist/lib/node-esm/chunk-XMUCZBP3.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-YMN5SXNC.mjs +0 -31
- package/dist/lib/node-esm/intent-resolver-YMN5SXNC.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-57TSIDR2.mjs +0 -35
- package/dist/lib/node-esm/react-surface-57TSIDR2.mjs.map +0 -7
- package/dist/lib/node-esm/transcriber-GPBV52ZR.mjs +0 -57
- package/dist/lib/node-esm/transcriber-GPBV52ZR.mjs.map +0 -7
- package/dist/types/src/capabilities/capabilities.d.ts +0 -17
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/Transcript.d.ts +0 -20
- package/dist/types/src/components/Transcript/Transcript.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts +0 -24
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts +0 -28
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/index.d.ts +0 -2
- package/dist/types/src/components/Transcript/index.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/transcript-extension.d.ts +0 -19
- package/dist/types/src/components/Transcript/transcript-extension.d.ts.map +0 -1
- package/dist/types/src/components/TranscriptContainer.d.ts +0 -9
- package/dist/types/src/components/TranscriptContainer.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -41
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/capabilities.ts +0 -33
- package/src/capabilities/intent-resolver.ts +0 -24
- package/src/components/Transcript/Transcript.tsx +0 -100
- package/src/components/Transcript/deprecated/OldTranscript.tsx +0 -260
- package/src/components/TranscriptContainer.tsx +0 -35
- package/src/types/schema.ts +0 -41
- /package/dist/lib/browser/{TranscriptContainer-E5NBJPAY.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/node-esm/{TranscriptContainer-UOS7JG72.mjs.map → chunk-HSLMI22Q.mjs.map} +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { Feed, Obj } from '@dxos/echo';
|
|
9
|
+
import { useMembers, useQueue } from '@dxos/react-client/echo';
|
|
10
|
+
import { Panel } from '@dxos/react-ui';
|
|
11
|
+
import { type Message, type Transcript } from '@dxos/types';
|
|
12
|
+
|
|
13
|
+
import { Transcription } from '#components';
|
|
14
|
+
import { useQueueModelAdapter } from '#hooks';
|
|
15
|
+
|
|
16
|
+
import { renderByline } from '../../util';
|
|
17
|
+
|
|
18
|
+
export type TranscriptionContainerProps = AppSurface.ObjectArticleProps<Transcript.Transcript>;
|
|
19
|
+
|
|
20
|
+
export const TranscriptionContainer = ({ role, subject: transcript, attendableId }: TranscriptionContainerProps) => {
|
|
21
|
+
const db = Obj.getDatabase(transcript);
|
|
22
|
+
const members = useMembers(db?.spaceId).map((member) => member.identity);
|
|
23
|
+
const feed = transcript.feed.target;
|
|
24
|
+
const queueDxn = feed ? Feed.getQueueDxn(feed) : undefined;
|
|
25
|
+
const queue = useQueue<Message.Message>(queueDxn, { pollInterval: 1_000 });
|
|
26
|
+
const model = useQueueModelAdapter(renderByline(members), queue);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Panel.Root role={role}>
|
|
30
|
+
<Panel.Content asChild>
|
|
31
|
+
<Transcription attendableId={attendableId} model={model} transcript={transcript} />
|
|
32
|
+
</Panel.Content>
|
|
33
|
+
</Panel.Root>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
@@ -20,67 +20,63 @@ export const useAudioFile = (audioUrl: string, constraints?: MediaTrackConstrain
|
|
|
20
20
|
const ctx = new Context();
|
|
21
21
|
|
|
22
22
|
scheduleTask(ctx, async () => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
URL.
|
|
28
|
-
|
|
23
|
+
// TODO(wittjosiah): Fetch to external url fails in headless storybook test.
|
|
24
|
+
try {
|
|
25
|
+
const response = await fetch(audioUrl);
|
|
26
|
+
const blob = await response.blob();
|
|
27
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
28
|
+
ctx.onDispose(() => {
|
|
29
|
+
URL.revokeObjectURL(objectUrl);
|
|
30
|
+
});
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
const audio = new Audio();
|
|
33
|
+
audio.src = objectUrl;
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
log.info('starting...');
|
|
46
|
-
try {
|
|
47
|
-
// Try to play the audio
|
|
48
|
-
await audio.play();
|
|
35
|
+
await new Promise<void>((resolve, reject) => {
|
|
36
|
+
audio.addEventListener(
|
|
37
|
+
'error',
|
|
38
|
+
(err) => {
|
|
39
|
+
log.error('error', { err });
|
|
40
|
+
reject(err);
|
|
41
|
+
},
|
|
42
|
+
{ once: true },
|
|
43
|
+
);
|
|
44
|
+
audio.addEventListener(
|
|
45
|
+
'canplay',
|
|
46
|
+
async () => {
|
|
49
47
|
resolve();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
{ once: true },
|
|
57
|
-
);
|
|
58
|
-
audio.load();
|
|
59
|
-
});
|
|
48
|
+
},
|
|
49
|
+
{ once: true },
|
|
50
|
+
);
|
|
51
|
+
audio.load();
|
|
52
|
+
});
|
|
60
53
|
|
|
61
|
-
|
|
54
|
+
const audioCtx = new AudioContext();
|
|
62
55
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
// Resume AudioContext if it's suspended.
|
|
57
|
+
if (audioCtx.state === 'suspended') {
|
|
58
|
+
await audioCtx.resume();
|
|
59
|
+
}
|
|
67
60
|
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
const destination = audioCtx.createMediaStreamDestination();
|
|
62
|
+
destination.channelCount = 1;
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
64
|
+
const source = audioCtx.createMediaElementSource(audio);
|
|
65
|
+
source.connect(destination);
|
|
66
|
+
const track = destination.stream.getAudioTracks()[0];
|
|
67
|
+
if (constraints) {
|
|
68
|
+
await track.applyConstraints(constraints).catch((err) => log.catch(err));
|
|
69
|
+
}
|
|
77
70
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
// Also connect to speakers so audio is audible.
|
|
72
|
+
setStream({
|
|
73
|
+
audio,
|
|
74
|
+
stream: destination.stream,
|
|
75
|
+
track: destination.stream.getAudioTracks()[0],
|
|
76
|
+
});
|
|
77
|
+
} catch (err) {
|
|
78
|
+
log.catch(err);
|
|
79
|
+
}
|
|
84
80
|
});
|
|
85
81
|
|
|
86
82
|
return () => {
|
|
@@ -12,7 +12,7 @@ import { type ChunkRenderer, SerializationModel } from '../model';
|
|
|
12
12
|
/**
|
|
13
13
|
* Model adapter for a queue.
|
|
14
14
|
*/
|
|
15
|
-
export const useQueueModelAdapter = <T extends Obj.
|
|
15
|
+
export const useQueueModelAdapter = <T extends Obj.Unknown>(
|
|
16
16
|
renderer: ChunkRenderer<T>,
|
|
17
17
|
queue: Queue<T> | undefined,
|
|
18
18
|
initialChunks: T[] = [],
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { useCapabilities } from '@dxos/app-framework';
|
|
7
|
+
import { useCapabilities } from '@dxos/app-framework/ui';
|
|
8
|
+
|
|
9
|
+
import { TranscriptionCapabilities } from '#types';
|
|
8
10
|
|
|
9
|
-
import { TranscriptionCapabilities } from '../capabilities';
|
|
10
11
|
import { type Transcriber } from '../transcriber';
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -26,7 +27,12 @@ export const useTranscriber = ({
|
|
|
26
27
|
return undefined;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
return getTranscriber({
|
|
30
|
+
return getTranscriber({
|
|
31
|
+
audioStreamTrack,
|
|
32
|
+
recorderConfig,
|
|
33
|
+
transcriberConfig,
|
|
34
|
+
onSegments,
|
|
35
|
+
});
|
|
30
36
|
}, [getTranscriber, audioStreamTrack, recorderConfig, transcriberConfig, onSegments]);
|
|
31
37
|
|
|
32
38
|
useEffect(() => {
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { scheduleMicroTask } from '@dxos/async';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
10
|
import { useSoundEffect } from '@dxos/react-ui-sfx';
|
|
11
11
|
|
|
12
|
+
import { type TranscriberProps } from '../transcriber';
|
|
12
13
|
import { useAudioTrack } from './useAudioTrack';
|
|
13
14
|
import { useTranscriber } from './useTranscriber';
|
|
14
|
-
import { type TranscriberParams } from '../transcriber';
|
|
15
15
|
|
|
16
16
|
export type UseVoiceInputProps = {
|
|
17
17
|
active?: boolean;
|
|
@@ -25,7 +25,7 @@ export const useVoiceInput = ({ active, onUpdate }: UseVoiceInputProps) => {
|
|
|
25
25
|
const soundStart = useSoundEffect('StartRecording');
|
|
26
26
|
const soundStop = useSoundEffect('StopRecording');
|
|
27
27
|
|
|
28
|
-
const handleSegments = useCallback<
|
|
28
|
+
const handleSegments = useCallback<TranscriberProps['onSegments']>(async (segments) => {
|
|
29
29
|
const text = segments.map((str) => str.text.trim().replace(/[^\w\s]/g, '')).join(' ');
|
|
30
30
|
onUpdate(text);
|
|
31
31
|
}, []);
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
export const meta: PluginMeta = {
|
|
10
|
-
id: TRANSCRIPTION_PLUGIN,
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
|
+
id: 'org.dxos.plugin.transcription',
|
|
11
10
|
name: 'Transcription',
|
|
12
|
-
description:
|
|
11
|
+
description: trim`
|
|
12
|
+
Real-time voice-to-text transcription service for capturing spoken content.
|
|
13
|
+
Convert audio input into searchable text that integrates seamlessly with notes and documents.
|
|
14
|
+
`,
|
|
13
15
|
icon: 'ph--microphone--regular',
|
|
16
|
+
iconHue: 'sky',
|
|
14
17
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-transcription',
|
|
15
18
|
tags: ['labs'],
|
|
16
19
|
screenshots: [],
|
package/src/model/model.test.ts
CHANGED
|
@@ -7,18 +7,18 @@ import { describe, test } from 'vitest';
|
|
|
7
7
|
|
|
8
8
|
import { Obj } from '@dxos/echo';
|
|
9
9
|
import type { ObjectId } from '@dxos/keys';
|
|
10
|
-
import {
|
|
10
|
+
import { Message } from '@dxos/types';
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { type ChunkRenderer, DocumentAdapter, SerializationModel } from './model';
|
|
13
13
|
|
|
14
|
-
const blockToMarkdown: ChunkRenderer<
|
|
15
|
-
message:
|
|
14
|
+
const blockToMarkdown: ChunkRenderer<Message.Message> = (
|
|
15
|
+
message: Message.Message,
|
|
16
16
|
index: number,
|
|
17
17
|
debug = true,
|
|
18
18
|
): string[] => {
|
|
19
19
|
return [
|
|
20
20
|
`###### ${message.sender.name}`,
|
|
21
|
-
...message.blocks.filter((block) => block.
|
|
21
|
+
...message.blocks.filter((block) => block._tag === 'transcript').map((block) => block.text),
|
|
22
22
|
'',
|
|
23
23
|
];
|
|
24
24
|
};
|
|
@@ -27,17 +27,17 @@ const createDate = () => new Date().toISOString();
|
|
|
27
27
|
|
|
28
28
|
describe('SerializationModel', () => {
|
|
29
29
|
test('basic', ({ expect }) => {
|
|
30
|
-
const model = new SerializationModel<
|
|
30
|
+
const model = new SerializationModel<Message.Message>(blockToMarkdown);
|
|
31
31
|
expect(model.chunks.length).to.eq(0);
|
|
32
32
|
expect(model.doc.toString()).to.eq('');
|
|
33
33
|
|
|
34
34
|
// Create message.
|
|
35
|
-
const message = Obj.make(
|
|
35
|
+
const message = Obj.make(Message.Message, {
|
|
36
36
|
created: createDate(),
|
|
37
37
|
sender: { name: 'Alice' },
|
|
38
38
|
blocks: [
|
|
39
39
|
{
|
|
40
|
-
|
|
40
|
+
_tag: 'transcript',
|
|
41
41
|
started: createDate(),
|
|
42
42
|
text: 'Hello world!',
|
|
43
43
|
},
|
|
@@ -51,7 +51,9 @@ describe('SerializationModel', () => {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
// Update message.
|
|
54
|
-
|
|
54
|
+
Obj.change(message, (message) => {
|
|
55
|
+
message.blocks.push({ _tag: 'transcript', started: createDate(), text: 'Hello again!' });
|
|
56
|
+
});
|
|
55
57
|
model.updateChunk(message);
|
|
56
58
|
{
|
|
57
59
|
const text = model.doc.toString();
|
|
@@ -62,19 +64,19 @@ describe('SerializationModel', () => {
|
|
|
62
64
|
|
|
63
65
|
test('sync - append', ({ expect }) => {
|
|
64
66
|
const view = new EditorView({ extensions: [], doc: '' });
|
|
65
|
-
const model = new SerializationModel<
|
|
67
|
+
const model = new SerializationModel<Message.Message>(blockToMarkdown);
|
|
66
68
|
const adapter = new DocumentAdapter(view);
|
|
67
69
|
expect(adapter.lineCount()).to.eq(0);
|
|
68
70
|
expect(view.state.doc.toString()).to.eq('');
|
|
69
71
|
|
|
70
72
|
// Append message.
|
|
71
73
|
{
|
|
72
|
-
const message = Obj.make(
|
|
74
|
+
const message = Obj.make(Message.Message, {
|
|
73
75
|
created: createDate(),
|
|
74
76
|
sender: { name: 'Alice' },
|
|
75
77
|
blocks: [
|
|
76
78
|
{
|
|
77
|
-
|
|
79
|
+
_tag: 'transcript',
|
|
78
80
|
started: createDate(),
|
|
79
81
|
text: 'Hello world!',
|
|
80
82
|
},
|
|
@@ -87,12 +89,12 @@ describe('SerializationModel', () => {
|
|
|
87
89
|
|
|
88
90
|
// Append message.
|
|
89
91
|
{
|
|
90
|
-
const message = Obj.make(
|
|
92
|
+
const message = Obj.make(Message.Message, {
|
|
91
93
|
created: createDate(),
|
|
92
94
|
sender: { name: 'Bob' },
|
|
93
95
|
blocks: [
|
|
94
96
|
{
|
|
95
|
-
|
|
97
|
+
_tag: 'transcript',
|
|
96
98
|
started: createDate(),
|
|
97
99
|
text: 'Hello world!',
|
|
98
100
|
},
|
|
@@ -106,7 +108,7 @@ describe('SerializationModel', () => {
|
|
|
106
108
|
|
|
107
109
|
test('sync - append, update, delete', ({ expect }) => {
|
|
108
110
|
const view = new EditorView({ extensions: [], doc: '' });
|
|
109
|
-
const model = new SerializationModel<
|
|
111
|
+
const model = new SerializationModel<Message.Message>(blockToMarkdown);
|
|
110
112
|
const adapter = new DocumentAdapter(view);
|
|
111
113
|
expect(adapter.lineCount()).to.eq(0);
|
|
112
114
|
|
|
@@ -114,12 +116,12 @@ describe('SerializationModel', () => {
|
|
|
114
116
|
|
|
115
117
|
// Append message.
|
|
116
118
|
{
|
|
117
|
-
const message = Obj.make(
|
|
119
|
+
const message = Obj.make(Message.Message, {
|
|
118
120
|
created: createDate(),
|
|
119
121
|
sender: { name: 'Alice' },
|
|
120
122
|
blocks: [
|
|
121
123
|
{
|
|
122
|
-
|
|
124
|
+
_tag: 'transcript',
|
|
123
125
|
started: createDate(),
|
|
124
126
|
text: 'Hello world!',
|
|
125
127
|
},
|
|
@@ -131,13 +133,17 @@ describe('SerializationModel', () => {
|
|
|
131
133
|
expect(view.state.doc.toString()).to.eq('###### Alice\nHello world!\n\n');
|
|
132
134
|
|
|
133
135
|
// Update message (add block).
|
|
134
|
-
|
|
136
|
+
Obj.change(message, (message) => {
|
|
137
|
+
message.blocks.push({ _tag: 'transcript', started: createDate(), text: 'Hello again!' });
|
|
138
|
+
});
|
|
135
139
|
model.updateChunk(message);
|
|
136
140
|
model.sync(adapter);
|
|
137
141
|
expect(view.state.doc.toString()).to.eq('###### Alice\nHello world!\nHello again!\n\n');
|
|
138
142
|
|
|
139
143
|
// Update message (remove block).
|
|
140
|
-
|
|
144
|
+
Obj.change(message, (message) => {
|
|
145
|
+
message.blocks.splice(0, 1);
|
|
146
|
+
});
|
|
141
147
|
model.updateChunk(message);
|
|
142
148
|
model.sync(adapter);
|
|
143
149
|
expect(view.state.doc.toString()).to.eq('###### Alice\nHello again!\n\n');
|
|
@@ -147,10 +153,10 @@ describe('SerializationModel', () => {
|
|
|
147
153
|
|
|
148
154
|
// Append message.
|
|
149
155
|
{
|
|
150
|
-
const message = Obj.make(
|
|
156
|
+
const message = Obj.make(Message.Message, {
|
|
151
157
|
created: createDate(),
|
|
152
158
|
sender: { name: 'Bob' },
|
|
153
|
-
blocks: [{
|
|
159
|
+
blocks: [{ _tag: 'transcript', started: createDate(), text: 'Hello again!' }],
|
|
154
160
|
});
|
|
155
161
|
model.appendChunk(message);
|
|
156
162
|
model.sync(adapter);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Feed, Ref } from '@dxos/echo';
|
|
8
|
+
import { Operation } from '@dxos/operation';
|
|
9
|
+
import { Transcript } from '@dxos/types';
|
|
10
|
+
|
|
11
|
+
import { Create } from './definitions';
|
|
12
|
+
|
|
13
|
+
const handler: Operation.WithHandler<typeof Create> = Create.pipe(
|
|
14
|
+
Operation.withHandler(
|
|
15
|
+
Effect.fn(function* ({ space }) {
|
|
16
|
+
const feed = space.db.add(Feed.make());
|
|
17
|
+
return {
|
|
18
|
+
object: Transcript.make(Ref.make(feed)),
|
|
19
|
+
};
|
|
20
|
+
}),
|
|
21
|
+
),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export default handler;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { AiService } from '@dxos/ai';
|
|
8
|
+
import { SpaceSchema } from '@dxos/client/echo';
|
|
9
|
+
import { Database, Feed, Ref } from '@dxos/echo';
|
|
10
|
+
import { Operation } from '@dxos/operation';
|
|
11
|
+
import { Message, Transcript } from '@dxos/types';
|
|
12
|
+
|
|
13
|
+
import { meta } from '#meta';
|
|
14
|
+
|
|
15
|
+
const TRANSCRIPT_OPERATION = `${meta.id}.operation`;
|
|
16
|
+
|
|
17
|
+
export const Create = Operation.make({
|
|
18
|
+
meta: { key: `${TRANSCRIPT_OPERATION}.create`, name: 'Create Transcript' },
|
|
19
|
+
input: Schema.Struct({
|
|
20
|
+
name: Schema.optional(Schema.String),
|
|
21
|
+
space: SpaceSchema,
|
|
22
|
+
}),
|
|
23
|
+
output: Schema.Struct({
|
|
24
|
+
object: Transcript.Transcript,
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const MessageWithRangeId = Schema.extend(
|
|
29
|
+
Message.Message,
|
|
30
|
+
Schema.Struct({
|
|
31
|
+
rangeId: Schema.optional(Schema.Array(Schema.String)).annotations({
|
|
32
|
+
description: 'The IDs of the messages that contain the sentences.',
|
|
33
|
+
}),
|
|
34
|
+
}),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export type MessageWithRangeIdType = Schema.Schema.Type<typeof MessageWithRangeId>;
|
|
38
|
+
|
|
39
|
+
export const Open = Operation.make({
|
|
40
|
+
meta: {
|
|
41
|
+
key: 'org.dxos.function.transcription.open',
|
|
42
|
+
name: 'Open',
|
|
43
|
+
description: 'Opens and reads the contents of a transcription object.',
|
|
44
|
+
},
|
|
45
|
+
input: Schema.Struct({
|
|
46
|
+
transcript: Ref.Ref(Transcript.Transcript).annotations({
|
|
47
|
+
description: 'The ID of the transcription object.',
|
|
48
|
+
}),
|
|
49
|
+
}),
|
|
50
|
+
output: Schema.Struct({
|
|
51
|
+
content: Schema.String,
|
|
52
|
+
}),
|
|
53
|
+
services: [Database.Service, Feed.FeedService],
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export const Summarize = Operation.make({
|
|
57
|
+
meta: {
|
|
58
|
+
key: 'org.dxos.function.transcription.summarize',
|
|
59
|
+
name: 'Summarize',
|
|
60
|
+
description: 'Summarize a transcript of a meeting.',
|
|
61
|
+
},
|
|
62
|
+
input: Schema.Struct({
|
|
63
|
+
transcript: Schema.String.annotations({
|
|
64
|
+
description: 'The transcript of the meeting.',
|
|
65
|
+
}),
|
|
66
|
+
notes: Schema.optional(Schema.String).annotations({
|
|
67
|
+
description: 'Additional notes from the participants.',
|
|
68
|
+
}),
|
|
69
|
+
}),
|
|
70
|
+
output: Schema.Struct({
|
|
71
|
+
summary: Schema.String.annotations({
|
|
72
|
+
description: 'The summary of the transcript.',
|
|
73
|
+
}),
|
|
74
|
+
}),
|
|
75
|
+
services: [AiService.AiService],
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export const SentenceNormalizationInput = Schema.Struct({
|
|
79
|
+
messages: Schema.Array(MessageWithRangeId).annotations({
|
|
80
|
+
description: 'Messages to normalize into sentences.',
|
|
81
|
+
}),
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export type SentenceNormalizationInputType = Schema.Schema.Type<typeof SentenceNormalizationInput>;
|
|
85
|
+
|
|
86
|
+
export const SentenceNormalizationOutput = Schema.Struct({
|
|
87
|
+
sentences: Schema.Array(MessageWithRangeId.pipe(Schema.mutable)).pipe(Schema.mutable).annotations({
|
|
88
|
+
description: 'The sentences of the transcript.',
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
export const SentenceNormalization = Operation.make({
|
|
93
|
+
meta: {
|
|
94
|
+
key: 'org.dxos.function.transcription.sentence-normalization',
|
|
95
|
+
name: 'Sentence Normalization',
|
|
96
|
+
description: 'Post process of transcription for sentence normalization',
|
|
97
|
+
},
|
|
98
|
+
input: SentenceNormalizationInput,
|
|
99
|
+
output: SentenceNormalizationOutput,
|
|
100
|
+
services: [],
|
|
101
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { OperationHandlerSet } from '@dxos/operation';
|
|
6
|
+
|
|
7
|
+
export * as TranscriptOperation from './definitions';
|
|
8
|
+
|
|
9
|
+
export const TranscriptionOperationHandlerSet = OperationHandlerSet.lazy(
|
|
10
|
+
() => import('./create'),
|
|
11
|
+
() => import('./open'),
|
|
12
|
+
() => import('./summarize'),
|
|
13
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Database, Feed, Filter } from '@dxos/echo';
|
|
8
|
+
import { Operation } from '@dxos/operation';
|
|
9
|
+
import { Message } from '@dxos/types';
|
|
10
|
+
|
|
11
|
+
import { renderByline } from '../util';
|
|
12
|
+
import { Open } from './definitions';
|
|
13
|
+
|
|
14
|
+
const handler: Operation.WithHandler<typeof Open> = Open.pipe(
|
|
15
|
+
Operation.withHandler(
|
|
16
|
+
Effect.fn(function* ({ transcript }) {
|
|
17
|
+
const transcriptObj = yield* Database.load(transcript);
|
|
18
|
+
const feed = yield* Database.load(transcriptObj.feed);
|
|
19
|
+
const messages = yield* Feed.runQuery(feed, Filter.type(Message.Message));
|
|
20
|
+
const content = messages
|
|
21
|
+
.flatMap((message: Message.Message, index: number) => renderByline([])(message, index))
|
|
22
|
+
.join('\n\n');
|
|
23
|
+
return { content };
|
|
24
|
+
}),
|
|
25
|
+
),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export default handler;
|