@dxos/plugin-transcription 0.8.4-main.c1de068 → 0.8.4-main.c85a9c8dae
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/TranscriptionContainer-RBFHP2AV.mjs +41 -0
- package/dist/lib/browser/TranscriptionContainer-RBFHP2AV.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-C6XA2SVZ.mjs +18 -0
- package/dist/lib/browser/blueprint-definition-C6XA2SVZ.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +9 -0
- package/dist/lib/browser/chunk-2B74LZZD.mjs +22 -0
- package/dist/lib/browser/chunk-2B74LZZD.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FFEPEPCU.mjs → chunk-EV5ZYKET.mjs} +64 -99
- package/dist/lib/browser/chunk-EV5ZYKET.mjs.map +7 -0
- package/dist/lib/browser/chunk-GH4IIQ6C.mjs +54 -0
- package/dist/lib/browser/chunk-GH4IIQ6C.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-O7ILGNBZ.mjs +148 -0
- package/dist/lib/browser/chunk-O7ILGNBZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5KPYIC3N.mjs → chunk-XLMRCOQN.mjs} +126 -221
- package/dist/lib/browser/chunk-XLMRCOQN.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +62 -73
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-5BLRH4XE.mjs +23 -0
- package/dist/lib/browser/operation-resolver-5BLRH4XE.mjs.map +7 -0
- package/dist/lib/browser/react-surface-U2SI74JK.mjs +36 -0
- package/dist/lib/browser/react-surface-U2SI74JK.mjs.map +7 -0
- package/dist/lib/browser/{transcriber-PXT4QBFY.mjs → transcriber-WCPHHJYY.mjs} +19 -14
- package/dist/lib/browser/transcriber-WCPHHJYY.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +9 -8
- package/dist/lib/node-esm/TranscriptionContainer-3OOID5KH.mjs +42 -0
- package/dist/lib/node-esm/TranscriptionContainer-3OOID5KH.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-TLXDUXIQ.mjs +19 -0
- package/dist/lib/node-esm/blueprint-definition-TLXDUXIQ.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +10 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-6GW5NZYG.mjs +55 -0
- package/dist/lib/node-esm/chunk-6GW5NZYG.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HT3W7LDP.mjs → chunk-7UE7G6DE.mjs} +64 -99
- package/dist/lib/node-esm/chunk-7UE7G6DE.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-TJKAO7VR.mjs → chunk-DYUGYQCB.mjs} +126 -221
- package/dist/lib/node-esm/chunk-DYUGYQCB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-F47HK7GT.mjs +24 -0
- package/dist/lib/node-esm/chunk-F47HK7GT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-H3MXHMQL.mjs +149 -0
- package/dist/lib/node-esm/chunk-H3MXHMQL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NVM2QUMX.mjs +37 -0
- package/dist/lib/node-esm/chunk-NVM2QUMX.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +62 -73
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-CVZB7BF4.mjs +24 -0
- package/dist/lib/node-esm/operation-resolver-CVZB7BF4.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-2ICJPBPX.mjs +37 -0
- package/dist/lib/node-esm/react-surface-2ICJPBPX.mjs.map +7 -0
- package/dist/lib/node-esm/{transcriber-YUTEVANE.mjs → transcriber-2RIHUEX4.mjs} +19 -14
- package/dist/lib/node-esm/transcriber-2RIHUEX4.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +9 -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/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +4 -4
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-handler/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts +5 -0
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/transcriber/index.d.ts +3 -0
- package/dist/types/src/capabilities/transcriber/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/transcriber/transcriber.d.ts +9 -0
- package/dist/types/src/capabilities/transcriber/transcriber.d.ts.map +1 -0
- package/dist/types/src/components/Transcription/Transcription.d.ts +17 -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 +10 -9
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/TranscriptionStory.d.ts +4 -3
- package/dist/types/src/components/stories/TranscriptionStory.d.ts.map +1 -1
- package/dist/types/src/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 +3 -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/functions/index.d.ts +18 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/open.d.ts +11 -0
- package/dist/types/src/functions/open.d.ts.map +1 -0
- package/dist/types/src/functions/summarize.d.ts +11 -0
- package/dist/types/src/functions/summarize.d.ts.map +1 -0
- package/dist/types/src/hooks/useAudioFile.d.ts.map +1 -1
- package/dist/types/src/hooks/useQueueModelAdapter.d.ts +1 -1
- package/dist/types/src/hooks/useQueueModelAdapter.d.ts.map +1 -1
- package/dist/types/src/hooks/useTranscriber.d.ts +1 -1
- package/dist/types/src/hooks/useTranscriber.d.ts.map +1 -1
- package/dist/types/src/hooks/useVoiceInput.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/message-normalizer.d.ts +5 -5
- package/dist/types/src/segments-normalization/message-normalizer.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/normalization.d.ts +516 -398
- package/dist/types/src/segments-normalization/normalization.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/utils.d.ts +2 -2
- package/dist/types/src/segments-normalization/utils.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +11 -11
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/transcriber/media-stream-recorder.d.ts +3 -3
- package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.d.ts +4 -4
- package/dist/types/src/transcriber/transcriber.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcription-manager.d.ts +12 -13
- package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
- package/dist/types/src/types/TranscriptAction.d.ts +25 -0
- package/dist/types/src/types/TranscriptAction.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +18 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +0 -26
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +1 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/render-byline.d.ts +4 -0
- package/dist/types/src/util/render-byline.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +88 -72
- package/src/TranscriptionPlugin.tsx +39 -57
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/transcription-blueprint.ts +33 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +17 -0
- package/src/capabilities/blueprint-definition/index.ts +7 -0
- package/src/capabilities/index.ts +4 -7
- package/src/capabilities/operation-handler/index.ts +7 -0
- package/src/capabilities/operation-handler/operation-handler.ts +25 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +25 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +28 -0
- package/src/capabilities/transcriber/index.ts +7 -0
- package/src/capabilities/transcriber/transcriber.ts +85 -0
- package/src/components/{Transcript/Transcript.stories.tsx → Transcription/Transcription.stories.tsx} +60 -56
- package/src/components/Transcription/Transcription.tsx +63 -0
- package/src/components/{Transcript → Transcription}/index.ts +1 -1
- package/src/components/{Transcript/transcript-extension.ts → Transcription/transcription-extension.ts} +13 -46
- package/src/components/index.ts +1 -6
- package/src/components/stories/FileTranscription.stories.tsx +66 -59
- package/src/components/stories/KeyWordRecognition.stories.tsx +17 -13
- package/src/components/stories/MicrophoneTranscription.stories.tsx +80 -80
- package/src/components/stories/TranscriptionStory.tsx +13 -13
- package/src/containers/TranscriptionContainer/TranscriptionContainer.tsx +33 -0
- package/src/containers/TranscriptionContainer/index.ts +7 -0
- package/src/containers/index.ts +7 -0
- package/src/functions/index.ts +11 -0
- package/src/functions/open.ts +37 -0
- package/src/functions/summarize.ts +103 -0
- package/src/hooks/useAudioFile.ts +49 -53
- package/src/hooks/useQueueModelAdapter.ts +1 -1
- package/src/hooks/useTranscriber.ts +8 -3
- package/src/hooks/useVoiceInput.ts +4 -3
- package/src/index.ts +1 -1
- package/src/meta.ts +9 -6
- package/src/model/model.test.ts +21 -15
- package/src/segments-normalization/message-normalizer.ts +19 -14
- package/src/segments-normalization/normalization.test.ts +11 -16
- package/src/segments-normalization/normalization.ts +43 -42
- package/src/segments-normalization/utils.ts +2 -2
- package/src/testing/testing.ts +35 -25
- package/src/transcriber/media-stream-recorder.ts +4 -4
- package/src/transcriber/transcriber.browser.test.ts +6 -5
- package/src/transcriber/transcriber.ts +8 -7
- package/src/transcriber/transcription-manager.ts +37 -52
- package/src/types/TranscriptAction.ts +32 -0
- package/src/types/capabilities.ts +33 -0
- package/src/types/index.ts +3 -1
- package/src/types/types.ts +0 -23
- package/src/util/index.ts +1 -0
- package/src/util/render-byline.ts +33 -0
- package/dist/lib/browser/TranscriptContainer-6WCKCXQ6.mjs +0 -11
- package/dist/lib/browser/chunk-4FJIYH7T.mjs +0 -8
- package/dist/lib/browser/chunk-4FJIYH7T.mjs.map +0 -7
- package/dist/lib/browser/chunk-5KPYIC3N.mjs.map +0 -7
- package/dist/lib/browser/chunk-5WH45KBY.mjs +0 -19
- package/dist/lib/browser/chunk-5WH45KBY.mjs.map +0 -7
- package/dist/lib/browser/chunk-FFEPEPCU.mjs.map +0 -7
- package/dist/lib/browser/chunk-R7INNNUQ.mjs +0 -55
- package/dist/lib/browser/chunk-R7INNNUQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-U6QBOGTN.mjs +0 -16
- package/dist/lib/browser/chunk-U6QBOGTN.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-3O33MMP5.mjs +0 -30
- package/dist/lib/browser/intent-resolver-3O33MMP5.mjs.map +0 -7
- package/dist/lib/browser/react-surface-E5D5AE3F.mjs +0 -34
- package/dist/lib/browser/react-surface-E5D5AE3F.mjs.map +0 -7
- package/dist/lib/browser/transcriber-PXT4QBFY.mjs.map +0 -7
- package/dist/lib/node-esm/TranscriptContainer-VBAOM5DG.mjs +0 -12
- package/dist/lib/node-esm/chunk-HT3W7LDP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RHF2ALML.mjs +0 -17
- package/dist/lib/node-esm/chunk-RHF2ALML.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TJKAO7VR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-U65ZWK3L.mjs +0 -56
- package/dist/lib/node-esm/chunk-U65ZWK3L.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XMUCZBP3.mjs +0 -21
- package/dist/lib/node-esm/chunk-XMUCZBP3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y2B4HWSS.mjs +0 -10
- package/dist/lib/node-esm/chunk-Y2B4HWSS.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-YMN5SXNC.mjs +0 -31
- package/dist/lib/node-esm/intent-resolver-YMN5SXNC.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-QRDJOHN5.mjs +0 -35
- package/dist/lib/node-esm/react-surface-QRDJOHN5.mjs.map +0 -7
- package/dist/lib/node-esm/transcriber-YUTEVANE.mjs.map +0 -7
- package/dist/types/src/capabilities/capabilities.d.ts +0 -17
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/transcriber.d.ts +0 -8
- package/dist/types/src/capabilities/transcriber.d.ts.map +0 -1
- package/dist/types/src/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/capabilities/react-surface.tsx +0 -22
- package/src/capabilities/transcriber.ts +0 -76
- 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-6WCKCXQ6.mjs.map → blueprints/index.mjs.map} +0 -0
- /package/dist/lib/{node-esm/TranscriptContainer-VBAOM5DG.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
package/src/testing/testing.ts
CHANGED
|
@@ -2,22 +2,23 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import { useEffect, useMemo, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { extractionAnthropicFunction, processTranscriptMessage } from '@dxos/assistant/extraction';
|
|
9
9
|
import { scheduleTaskInterval } from '@dxos/async';
|
|
10
10
|
import { Filter, type Queue } from '@dxos/client/echo';
|
|
11
11
|
import { Context } from '@dxos/context';
|
|
12
|
-
import { Obj, Ref, Type
|
|
13
|
-
import { createQueueDXN } from '@dxos/echo
|
|
14
|
-
import { FunctionExecutor, ServiceContainer } from '@dxos/functions';
|
|
12
|
+
import { type Key, Obj, Ref, Type } from '@dxos/echo';
|
|
13
|
+
import { createQueueDXN } from '@dxos/echo/internal';
|
|
14
|
+
import { FunctionExecutor, ServiceContainer } from '@dxos/functions-runtime';
|
|
15
15
|
import { IdentityDid } from '@dxos/keys';
|
|
16
16
|
import { log } from '@dxos/log';
|
|
17
17
|
import { faker } from '@dxos/random';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
18
|
+
import { type Space, useQueue } from '@dxos/react-client/echo';
|
|
19
|
+
import { TestSchema } from '@dxos/schema/testing';
|
|
20
|
+
import { type ContentBlock, Message, Organization, Person } from '@dxos/types';
|
|
21
|
+
import { seedTestData } from '@dxos/types/testing';
|
|
21
22
|
|
|
22
23
|
// TODO(burdon): Reconcile with plugin-markdown. Move to @dxos/schema/testing.
|
|
23
24
|
export const TestItem = Schema.Struct({
|
|
@@ -30,7 +31,7 @@ export const TestItem = Schema.Struct({
|
|
|
30
31
|
description: 'Product description',
|
|
31
32
|
}),
|
|
32
33
|
}).pipe(
|
|
33
|
-
Type.
|
|
34
|
+
Type.object({
|
|
34
35
|
typename: 'dxos.org/type/Test',
|
|
35
36
|
version: '0.1.0',
|
|
36
37
|
}),
|
|
@@ -38,7 +39,7 @@ export const TestItem = Schema.Struct({
|
|
|
38
39
|
|
|
39
40
|
// TODO(wittjosiah): Make builder generic and reuse for all message types.
|
|
40
41
|
abstract class AbstractMessageBuilder {
|
|
41
|
-
abstract createMessage(numSegments?: number): Promise<
|
|
42
|
+
abstract createMessage(numSegments?: number): Promise<Message.Message>;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
/**
|
|
@@ -59,22 +60,27 @@ export class MessageBuilder extends AbstractMessageBuilder {
|
|
|
59
60
|
super();
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
override async createMessage(numSegments = 1): Promise<
|
|
63
|
-
return Obj.make(
|
|
63
|
+
override async createMessage(numSegments = 1): Promise<Message.Message> {
|
|
64
|
+
return Obj.make(Message.Message, {
|
|
64
65
|
created: this.next().toISOString(),
|
|
65
66
|
sender: faker.helpers.arrayElement(this.users),
|
|
66
67
|
blocks: Array.from({ length: numSegments }).map(() => this.createBlock()),
|
|
67
68
|
});
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
createBlock():
|
|
71
|
+
createBlock(): ContentBlock.Transcript {
|
|
71
72
|
let text = faker.lorem.paragraph();
|
|
72
73
|
if (this._space) {
|
|
73
74
|
const label = faker.commerce.productName();
|
|
74
|
-
const obj = this._space.db.add(
|
|
75
|
+
const obj = this._space.db.add(
|
|
76
|
+
Obj.make(TestItem, {
|
|
77
|
+
title: label,
|
|
78
|
+
description: faker.lorem.paragraph(),
|
|
79
|
+
}),
|
|
80
|
+
);
|
|
75
81
|
const dxn = Ref.make(obj).dxn.toString();
|
|
76
82
|
const words = text.split(' ');
|
|
77
|
-
words.splice(Math.floor(Math.random() * words.length), 0, `[${label}]
|
|
83
|
+
words.splice(Math.floor(Math.random() * words.length), 0, `[${label}](${dxn})`);
|
|
78
84
|
text = words.join(' ');
|
|
79
85
|
}
|
|
80
86
|
|
|
@@ -103,7 +109,7 @@ class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
|
|
|
103
109
|
|
|
104
110
|
space: Space | undefined;
|
|
105
111
|
currentMessage: number = 0;
|
|
106
|
-
transcriptMessages:
|
|
112
|
+
transcriptMessages: Message.Message[] = [];
|
|
107
113
|
|
|
108
114
|
async connect(space: Space): Promise<void> {
|
|
109
115
|
this.space = space;
|
|
@@ -111,14 +117,18 @@ class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
|
|
|
111
117
|
this.transcriptMessages = transcriptMessages;
|
|
112
118
|
}
|
|
113
119
|
|
|
114
|
-
override async createMessage(): Promise<
|
|
120
|
+
override async createMessage(): Promise<Message.Message> {
|
|
115
121
|
if (!this.space) {
|
|
116
122
|
throw new Error('Space not connected');
|
|
117
123
|
}
|
|
118
124
|
|
|
119
|
-
const
|
|
125
|
+
const objects = await this.space.db
|
|
120
126
|
.query(
|
|
121
|
-
Filter.or(
|
|
127
|
+
Filter.or(
|
|
128
|
+
Filter.type(Person.Person),
|
|
129
|
+
Filter.type(Organization.Organization),
|
|
130
|
+
Filter.type(TestSchema.DocumentType),
|
|
131
|
+
),
|
|
122
132
|
)
|
|
123
133
|
.run();
|
|
124
134
|
|
|
@@ -130,7 +140,7 @@ class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
|
|
|
130
140
|
const { message: enhancedMessage } = await processTranscriptMessage({
|
|
131
141
|
input: { message },
|
|
132
142
|
executor: this.executor,
|
|
133
|
-
function:
|
|
143
|
+
function: extractionAnthropicFunction,
|
|
134
144
|
});
|
|
135
145
|
|
|
136
146
|
return enhancedMessage;
|
|
@@ -142,7 +152,7 @@ type UseTestTranscriptionQueue = (
|
|
|
142
152
|
queueId?: Key.ObjectId,
|
|
143
153
|
running?: boolean,
|
|
144
154
|
interval?: number,
|
|
145
|
-
) => Queue<
|
|
155
|
+
) => Queue<Message.Message> | undefined;
|
|
146
156
|
|
|
147
157
|
/**
|
|
148
158
|
* Test transcriptionqueue.
|
|
@@ -155,7 +165,7 @@ export const useTestTranscriptionQueue: UseTestTranscriptionQueue = (
|
|
|
155
165
|
) => {
|
|
156
166
|
// TODO(dmaretskyi): Use space.queues.create() instead.
|
|
157
167
|
const queueDxn = useMemo(() => (space ? createQueueDXN(space.id, queueId) : undefined), [space, queueId]);
|
|
158
|
-
const queue = useQueue<
|
|
168
|
+
const queue = useQueue<Message.Message>(queueDxn);
|
|
159
169
|
const builder = useMemo(() => new MessageBuilder(space), [space]);
|
|
160
170
|
|
|
161
171
|
useEffect(() => {
|
|
@@ -165,7 +175,7 @@ export const useTestTranscriptionQueue: UseTestTranscriptionQueue = (
|
|
|
165
175
|
|
|
166
176
|
const i = setInterval(() => {
|
|
167
177
|
void builder.createMessage(Math.ceil(Math.random() * 3)).then(async (message) => {
|
|
168
|
-
await queue.append([Obj.make(
|
|
178
|
+
await queue.append([Obj.make(Message.Message, message)]);
|
|
169
179
|
});
|
|
170
180
|
}, interval);
|
|
171
181
|
return () => clearInterval(i);
|
|
@@ -186,7 +196,7 @@ export const useTestTranscriptionQueueWithEntityExtraction: UseTestTranscription
|
|
|
186
196
|
) => {
|
|
187
197
|
// TODO(dmaretskyi): Use space.queues.create() instead.
|
|
188
198
|
const queueDxn = useMemo(() => (space ? createQueueDXN(space.id, queueId) : undefined), [space, queueId]);
|
|
189
|
-
const queue = useQueue<
|
|
199
|
+
const queue = useQueue<Message.Message>(queueDxn);
|
|
190
200
|
const [builder] = useState(() => new EntityExtractionMessageBuilder());
|
|
191
201
|
|
|
192
202
|
useEffect(() => {
|
|
@@ -203,7 +213,7 @@ export const useTestTranscriptionQueueWithEntityExtraction: UseTestTranscription
|
|
|
203
213
|
ctx,
|
|
204
214
|
async () => {
|
|
205
215
|
const message = await builder.createMessage();
|
|
206
|
-
void queue.append([Obj.make(
|
|
216
|
+
void queue.append([Obj.make(Message.Message, message)]);
|
|
207
217
|
},
|
|
208
218
|
interval,
|
|
209
219
|
);
|
|
@@ -10,7 +10,7 @@ import { invariant } from '@dxos/invariant';
|
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
11
|
import { trace } from '@dxos/tracing';
|
|
12
12
|
|
|
13
|
-
import { type
|
|
13
|
+
import { type AudioChunk, type AudioRecorder, type WavConfig } from './audio-recorder';
|
|
14
14
|
|
|
15
15
|
let initializingPromise: Promise<void> | undefined;
|
|
16
16
|
|
|
@@ -19,7 +19,7 @@ const initializeExtendableMediaRecorder = async () => {
|
|
|
19
19
|
await register(await connect());
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export type
|
|
22
|
+
export type MediaStreamRecorderProps = {
|
|
23
23
|
mediaStreamTrack: MediaStreamTrack;
|
|
24
24
|
config: {
|
|
25
25
|
interval: number;
|
|
@@ -37,12 +37,12 @@ export class MediaStreamRecorder implements AudioRecorder {
|
|
|
37
37
|
/**
|
|
38
38
|
* Default MediaRecorder implementation do not support wav encoding.
|
|
39
39
|
*/
|
|
40
|
-
private readonly _config:
|
|
40
|
+
private readonly _config: MediaStreamRecorderProps['config'];
|
|
41
41
|
private _mediaRecorder?: IMediaRecorder = undefined;
|
|
42
42
|
private _header?: Uint8Array = undefined;
|
|
43
43
|
private _onChunk?: (chunk: AudioChunk) => void;
|
|
44
44
|
|
|
45
|
-
constructor({ mediaStreamTrack, config }:
|
|
45
|
+
constructor({ mediaStreamTrack, config }: MediaStreamRecorderProps) {
|
|
46
46
|
this._mediaStreamTrack = mediaStreamTrack;
|
|
47
47
|
this._config = config;
|
|
48
48
|
}
|
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
|
+
|
|
7
8
|
import { describe, expect, test } from 'vitest';
|
|
8
9
|
import { WaveFile } from 'wavefile';
|
|
9
10
|
|
|
10
11
|
import { Trigger } from '@dxos/async';
|
|
11
12
|
import { log } from '@dxos/log';
|
|
12
|
-
import { type DataType } from '@dxos/schema';
|
|
13
13
|
import { openAndClose } from '@dxos/test-utils';
|
|
14
|
-
import {
|
|
14
|
+
import { TRACE_PROCESSOR, trace } from '@dxos/tracing';
|
|
15
|
+
import { type ContentBlock } from '@dxos/types';
|
|
15
16
|
|
|
16
17
|
import { type AudioChunk, type AudioRecorder, Transcriber } from '../transcriber';
|
|
17
18
|
import { mergeFloat64Arrays } from '../util';
|
|
@@ -93,7 +94,7 @@ describe.skip('Transcriber', () => {
|
|
|
93
94
|
});
|
|
94
95
|
|
|
95
96
|
test.skip('transcription of audio recording', { timeout: 10_000 }, async () => {
|
|
96
|
-
const trigger = new Trigger<
|
|
97
|
+
const trigger = new Trigger<ContentBlock.Transcript[]>({ autoReset: true });
|
|
97
98
|
const recorder = new MockAudioRecorder({
|
|
98
99
|
buffer: await readFile('test.wav'),
|
|
99
100
|
chunkDuration: 3_000,
|
|
@@ -127,7 +128,7 @@ describe.skip('Transcriber', () => {
|
|
|
127
128
|
});
|
|
128
129
|
|
|
129
130
|
test.skip('transcription of audio recording with overlapping chunks', { timeout: 20_000 }, async () => {
|
|
130
|
-
const trigger = new Trigger<
|
|
131
|
+
const trigger = new Trigger<ContentBlock.Transcript[]>({ autoReset: true });
|
|
131
132
|
const recorder = new MockAudioRecorder({
|
|
132
133
|
buffer: await readFile('test.wav'),
|
|
133
134
|
chunkDuration: 3_000,
|
|
@@ -212,7 +213,7 @@ class MockAudioRecorder implements AudioRecorder {
|
|
|
212
213
|
|
|
213
214
|
@trace.span()
|
|
214
215
|
async start(): Promise<void> {
|
|
215
|
-
log.info('start mock audio recorder', {
|
|
216
|
+
log.info('start mock audio recorder', { wavProps: this.wav.fmt });
|
|
216
217
|
const now = Date.now();
|
|
217
218
|
const samples = this.wav.getSamples();
|
|
218
219
|
const sampleRate = this.wavConfig.sampleRate;
|
|
@@ -7,13 +7,14 @@ import { WaveFile } from 'wavefile';
|
|
|
7
7
|
import { DeferredTask, Trigger } from '@dxos/async';
|
|
8
8
|
import { type Context, LifecycleState, Resource } from '@dxos/context';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
|
-
import { type DataType } from '@dxos/schema';
|
|
11
10
|
import { trace } from '@dxos/tracing';
|
|
11
|
+
import { type ContentBlock } from '@dxos/types';
|
|
12
12
|
|
|
13
|
-
import { type AudioRecorder, type AudioChunk } from './audio-recorder';
|
|
14
13
|
import { TRANSCRIPTION_URL } from '../types';
|
|
15
14
|
import { mergeFloat64Arrays } from '../util';
|
|
16
15
|
|
|
16
|
+
import { type AudioChunk, type AudioRecorder } from './audio-recorder';
|
|
17
|
+
|
|
17
18
|
type WhisperWord = {
|
|
18
19
|
word: string;
|
|
19
20
|
|
|
@@ -62,14 +63,14 @@ export type TranscribeConfig = {
|
|
|
62
63
|
prefixBufferChunksAmount: number;
|
|
63
64
|
};
|
|
64
65
|
|
|
65
|
-
export type
|
|
66
|
+
export type TranscriberProps = {
|
|
66
67
|
config: TranscribeConfig;
|
|
67
68
|
recorder: AudioRecorder;
|
|
68
69
|
/**
|
|
69
70
|
* Callback to handle the transcribed segments, after all segment transformers are applied.
|
|
70
71
|
* @param segments - The transcribed segments.
|
|
71
72
|
*/
|
|
72
|
-
onSegments: (segments:
|
|
73
|
+
onSegments: (segments: ContentBlock.Transcript[]) => Promise<void>;
|
|
73
74
|
};
|
|
74
75
|
|
|
75
76
|
/**
|
|
@@ -85,12 +86,12 @@ export class Transcriber extends Resource {
|
|
|
85
86
|
|
|
86
87
|
private readonly _config: TranscribeConfig;
|
|
87
88
|
private readonly _recorder: AudioRecorder;
|
|
88
|
-
private readonly _onSegments:
|
|
89
|
+
private readonly _onSegments: TranscriberProps['onSegments'];
|
|
89
90
|
|
|
90
91
|
private _recording = false;
|
|
91
92
|
private _transcribeTask?: DeferredTask = undefined;
|
|
92
93
|
|
|
93
|
-
constructor({ config, recorder, onSegments }:
|
|
94
|
+
constructor({ config, recorder, onSegments }: TranscriberProps) {
|
|
94
95
|
super();
|
|
95
96
|
this._config = config;
|
|
96
97
|
this._recorder = recorder;
|
|
@@ -220,7 +221,7 @@ export class Transcriber extends Resource {
|
|
|
220
221
|
return segments;
|
|
221
222
|
}
|
|
222
223
|
|
|
223
|
-
private _alignSegments(segments: WhisperSegment[], originalChunks: AudioChunk[]):
|
|
224
|
+
private _alignSegments(segments: WhisperSegment[], originalChunks: AudioChunk[]): ContentBlock.Transcript[] {
|
|
224
225
|
// Absolute zero for all relative timestamps in the segments.
|
|
225
226
|
const zeroTimestamp = originalChunks.at(0)!.timestamp;
|
|
226
227
|
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Atom, type Registry } from '@effect-atom/atom-react';
|
|
6
6
|
|
|
7
7
|
import { synchronized } from '@dxos/async';
|
|
8
8
|
import { Resource } from '@dxos/context';
|
|
9
9
|
import { Obj } from '@dxos/echo';
|
|
10
10
|
import { type Queue } from '@dxos/echo-db';
|
|
11
11
|
import { type EdgeHttpClient } from '@dxos/react-edge-client';
|
|
12
|
-
import {
|
|
12
|
+
import { type ContentBlock, Message } from '@dxos/types';
|
|
13
13
|
|
|
14
14
|
import { MediaStreamRecorder } from './media-stream-recorder';
|
|
15
15
|
import { Transcriber } from './transcriber';
|
|
@@ -30,10 +30,11 @@ const PREFIXED_CHUNKS_AMOUNT = 10;
|
|
|
30
30
|
*/
|
|
31
31
|
const TRANSCRIBE_AFTER_CHUNKS_AMOUNT = 50;
|
|
32
32
|
|
|
33
|
-
export type TranscriptMessageEnricher = (message:
|
|
33
|
+
export type TranscriptMessageEnricher = (message: Message.Message) => Promise<Message.Message>;
|
|
34
34
|
|
|
35
35
|
export type TranscriptionManagerOptions = {
|
|
36
36
|
edgeClient: EdgeHttpClient;
|
|
37
|
+
registry: Registry.Registry;
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Enrich the message before it is written to the transcription queue.
|
|
@@ -47,25 +48,30 @@ export type TranscriptionManagerOptions = {
|
|
|
47
48
|
export class TranscriptionManager extends Resource {
|
|
48
49
|
private readonly _edgeClient: EdgeHttpClient;
|
|
49
50
|
private readonly _messageEnricher?: TranscriptMessageEnricher;
|
|
51
|
+
private readonly _registry: Registry.Registry;
|
|
50
52
|
private _audioStreamTrack?: MediaStreamTrack = undefined;
|
|
51
53
|
private _identityDid?: string = undefined;
|
|
52
54
|
private _mediaRecorder?: MediaStreamRecorder = undefined;
|
|
53
55
|
private _transcriber?: Transcriber = undefined;
|
|
54
|
-
private _queue?: Queue<
|
|
55
|
-
private
|
|
56
|
+
private _queue?: Queue<Message.Message> = undefined;
|
|
57
|
+
private _enabledAtom = Atom.make(false);
|
|
56
58
|
|
|
57
59
|
constructor(options: TranscriptionManagerOptions) {
|
|
58
60
|
super();
|
|
59
61
|
this._edgeClient = options.edgeClient;
|
|
60
62
|
this._messageEnricher = options.messageEnricher;
|
|
63
|
+
this._registry = options.registry;
|
|
61
64
|
}
|
|
62
65
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return this._enabled.value;
|
|
66
|
+
get enabled(): Atom.Atom<boolean> {
|
|
67
|
+
return this._enabledAtom;
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
|
|
70
|
+
getEnabled(): boolean {
|
|
71
|
+
return this._registry.get(this._enabledAtom);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
setQueue(queue: Queue<Message.Message>): this {
|
|
69
75
|
this._queue = queue;
|
|
70
76
|
return this;
|
|
71
77
|
}
|
|
@@ -78,7 +84,7 @@ export class TranscriptionManager extends Resource {
|
|
|
78
84
|
}
|
|
79
85
|
|
|
80
86
|
setRecording(recording?: boolean): this {
|
|
81
|
-
if (!this.isOpen || !this.
|
|
87
|
+
if (!this.isOpen || !this.getEnabled()) {
|
|
82
88
|
return this;
|
|
83
89
|
}
|
|
84
90
|
|
|
@@ -90,19 +96,17 @@ export class TranscriptionManager extends Resource {
|
|
|
90
96
|
return this;
|
|
91
97
|
}
|
|
92
98
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
* @param enabled - Whether to enable transcription.
|
|
96
|
-
*/
|
|
97
|
-
@synchronized
|
|
98
|
-
async setEnabled(enabled?: boolean): Promise<void> {
|
|
99
|
-
if (this._enabled.value === enabled) {
|
|
99
|
+
async setEnabled(enabled: boolean): Promise<void> {
|
|
100
|
+
if (this.getEnabled() === enabled) {
|
|
100
101
|
return;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
this.
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
this._registry.set(this._enabledAtom, enabled ?? false);
|
|
105
|
+
if (enabled) {
|
|
106
|
+
await this._maybeRestartTranscriber();
|
|
107
|
+
} else {
|
|
108
|
+
await this._stopTranscriber();
|
|
109
|
+
}
|
|
106
110
|
}
|
|
107
111
|
|
|
108
112
|
@synchronized
|
|
@@ -112,44 +116,19 @@ export class TranscriptionManager extends Resource {
|
|
|
112
116
|
}
|
|
113
117
|
|
|
114
118
|
this._audioStreamTrack = track;
|
|
115
|
-
|
|
119
|
+
await this._maybeRestartTranscriber();
|
|
116
120
|
}
|
|
117
121
|
|
|
118
122
|
protected override async _open(): Promise<void> {
|
|
119
|
-
await this.
|
|
123
|
+
await this._maybeRestartTranscriber();
|
|
120
124
|
}
|
|
121
125
|
|
|
122
126
|
protected override async _close(): Promise<void> {
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// TODO(burdon): Change this to setEnables (explicit), not toggle.
|
|
127
|
-
private async _toggleTranscriber(): Promise<void> {
|
|
128
|
-
await this._maybeReinitTranscriber();
|
|
129
|
-
|
|
130
|
-
// Open or close transcriber if transcription is enabled or disabled.
|
|
131
|
-
if (this._enabled.value) {
|
|
132
|
-
await this._transcriber?.open();
|
|
133
|
-
// TODO(burdon): Started and stopped blocks appear twice.
|
|
134
|
-
const block = Obj.make(DataType.Message, {
|
|
135
|
-
created: new Date().toISOString(),
|
|
136
|
-
blocks: [{ _tag: 'transcript', text: 'Started', started: new Date().toISOString() }],
|
|
137
|
-
sender: { role: 'assistant' },
|
|
138
|
-
});
|
|
139
|
-
await this._queue?.append([block]);
|
|
140
|
-
} else {
|
|
141
|
-
await this._transcriber?.close();
|
|
142
|
-
const block = Obj.make(DataType.Message, {
|
|
143
|
-
created: new Date().toISOString(),
|
|
144
|
-
blocks: [{ _tag: 'transcript', text: 'Stopped', started: new Date().toISOString() }],
|
|
145
|
-
sender: { role: 'assistant' },
|
|
146
|
-
});
|
|
147
|
-
await this._queue?.append([block]);
|
|
148
|
-
}
|
|
127
|
+
await this._stopTranscriber();
|
|
149
128
|
}
|
|
150
129
|
|
|
151
|
-
private async
|
|
152
|
-
if (!this._audioStreamTrack || !this.
|
|
130
|
+
private async _maybeRestartTranscriber(): Promise<void> {
|
|
131
|
+
if (!this._audioStreamTrack || !this.getEnabled() || !this.isOpen) {
|
|
153
132
|
return;
|
|
154
133
|
}
|
|
155
134
|
|
|
@@ -172,15 +151,21 @@ export class TranscriptionManager extends Resource {
|
|
|
172
151
|
recorder: this._mediaRecorder,
|
|
173
152
|
onSegments: (segments) => this._onSegments(segments),
|
|
174
153
|
});
|
|
154
|
+
|
|
155
|
+
await this._transcriber?.open();
|
|
175
156
|
}
|
|
176
157
|
}
|
|
177
158
|
|
|
178
|
-
private async
|
|
159
|
+
private async _stopTranscriber(): Promise<void> {
|
|
160
|
+
await this._transcriber?.close();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
private async _onSegments(segments: ContentBlock.Transcript[]): Promise<void> {
|
|
179
164
|
if (!this.isOpen || !this._queue) {
|
|
180
165
|
return;
|
|
181
166
|
}
|
|
182
167
|
|
|
183
|
-
let block = Obj.make(
|
|
168
|
+
let block = Obj.make(Message.Message, {
|
|
184
169
|
created: new Date().toISOString(),
|
|
185
170
|
blocks: segments,
|
|
186
171
|
sender: { identityDid: this._identityDid },
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { SpaceSchema } from '@dxos/client/echo';
|
|
8
|
+
import { Operation } from '@dxos/operation';
|
|
9
|
+
import { Transcript } from '@dxos/types';
|
|
10
|
+
|
|
11
|
+
import { meta } from '../meta';
|
|
12
|
+
|
|
13
|
+
//
|
|
14
|
+
// Operations
|
|
15
|
+
//
|
|
16
|
+
|
|
17
|
+
const TRANSCRIPT_OPERATION = `${meta.id}/operation`;
|
|
18
|
+
|
|
19
|
+
export namespace TranscriptOperation {
|
|
20
|
+
export const Create = Operation.make({
|
|
21
|
+
meta: { key: `${TRANSCRIPT_OPERATION}/create`, name: 'Create Transcript' },
|
|
22
|
+
schema: {
|
|
23
|
+
input: Schema.Struct({
|
|
24
|
+
name: Schema.optional(Schema.String),
|
|
25
|
+
space: SpaceSchema,
|
|
26
|
+
}),
|
|
27
|
+
output: Schema.Struct({
|
|
28
|
+
object: Transcript.Transcript,
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Capability } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from '../meta';
|
|
8
|
+
import {
|
|
9
|
+
type MediaStreamRecorderProps,
|
|
10
|
+
type Transcriber,
|
|
11
|
+
type TranscriberProps,
|
|
12
|
+
type TranscriptMessageEnricher,
|
|
13
|
+
type TranscriptionManager,
|
|
14
|
+
} from '../transcriber';
|
|
15
|
+
|
|
16
|
+
export namespace TranscriptionCapabilities {
|
|
17
|
+
export type GetTranscriberProps = {
|
|
18
|
+
audioStreamTrack: MediaStreamTrack;
|
|
19
|
+
recorderConfig?: Partial<MediaStreamRecorderProps['config']>;
|
|
20
|
+
transcriberConfig?: Partial<TranscriberProps['config']>;
|
|
21
|
+
onSegments: TranscriberProps['onSegments'];
|
|
22
|
+
};
|
|
23
|
+
export type GetTranscriber = (props: GetTranscriberProps) => Transcriber;
|
|
24
|
+
export const Transcriber = Capability.make<GetTranscriber>(`${meta.id}/capability/transcriber`);
|
|
25
|
+
|
|
26
|
+
export type GetTranscriptionManagerProps = {
|
|
27
|
+
messageEnricher?: TranscriptMessageEnricher;
|
|
28
|
+
};
|
|
29
|
+
export type GetTranscriptionManager = (props: GetTranscriptionManagerProps) => TranscriptionManager;
|
|
30
|
+
export const TranscriptionManager = Capability.make<GetTranscriptionManager>(
|
|
31
|
+
`${meta.id}/capability/transcription-manager`,
|
|
32
|
+
);
|
|
33
|
+
}
|
package/src/types/index.ts
CHANGED
package/src/types/types.ts
CHANGED
|
@@ -2,31 +2,8 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
6
|
-
|
|
7
|
-
import { SpaceId } from '@dxos/react-client/echo';
|
|
8
|
-
|
|
9
|
-
import { TranscriptType } from './schema';
|
|
10
|
-
import { TRANSCRIPTION_PLUGIN } from '../meta';
|
|
11
|
-
|
|
12
|
-
// TODO(burdon): Move to separate proto.
|
|
13
|
-
|
|
14
5
|
/**
|
|
15
6
|
* Endpoint to the calls service.
|
|
16
7
|
*/
|
|
17
8
|
// TODO(burdon): Reconfigure/move.
|
|
18
9
|
export const TRANSCRIPTION_URL = 'https://calls-service.dxos.workers.dev';
|
|
19
|
-
|
|
20
|
-
export namespace TranscriptionAction {
|
|
21
|
-
const TRANSCRIPTION_ACTION = `${TRANSCRIPTION_PLUGIN}/action`;
|
|
22
|
-
|
|
23
|
-
export class Create extends Schema.TaggedClass<Create>()(`${TRANSCRIPTION_ACTION}/create`, {
|
|
24
|
-
input: Schema.Struct({
|
|
25
|
-
name: Schema.optional(Schema.String),
|
|
26
|
-
spaceId: SpaceId,
|
|
27
|
-
}),
|
|
28
|
-
output: Schema.Struct({
|
|
29
|
-
object: TranscriptType,
|
|
30
|
-
}),
|
|
31
|
-
}) {}
|
|
32
|
-
}
|
package/src/util/index.ts
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Identity } from '@dxos/react-client/halo';
|
|
6
|
+
import { type Message } from '@dxos/types';
|
|
7
|
+
|
|
8
|
+
// TODO(thure): Move this?
|
|
9
|
+
export const renderByline =
|
|
10
|
+
(identities: Identity[]) =>
|
|
11
|
+
(message: Message.Message, index: number, debug = false): string[] => {
|
|
12
|
+
if (message.sender.role === 'assistant') {
|
|
13
|
+
// Start/stop block.
|
|
14
|
+
return [message.blocks.find((block) => block._tag === 'transcript')?.text ?? '', ''];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// TODO(burdon): Use link/reference markup for users (with popover).
|
|
18
|
+
// TODO(burdon): Color and avatar.
|
|
19
|
+
const identity = identities.find((identity) => identity.did === message.sender.identityDid);
|
|
20
|
+
const name =
|
|
21
|
+
identity?.profile?.displayName ??
|
|
22
|
+
message.sender.contact?.target?.fullName ??
|
|
23
|
+
message.sender.name ??
|
|
24
|
+
message.sender.email ??
|
|
25
|
+
message.sender.identityDid;
|
|
26
|
+
const blocks = message.blocks.filter((block) => block._tag === 'transcript');
|
|
27
|
+
return [
|
|
28
|
+
// TODO(thure): Use an XML tag with the bits needed here.
|
|
29
|
+
`###### ${name}` + (debug ? ` [${index}]:${message.id}` : ''),
|
|
30
|
+
blocks.map((block) => block.text.trim()).join(' '),
|
|
31
|
+
'',
|
|
32
|
+
];
|
|
33
|
+
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TranscriptContainer_default,
|
|
3
|
-
TranscriptionContainer
|
|
4
|
-
} from "./chunk-5KPYIC3N.mjs";
|
|
5
|
-
import "./chunk-U6QBOGTN.mjs";
|
|
6
|
-
import "./chunk-5WH45KBY.mjs";
|
|
7
|
-
export {
|
|
8
|
-
TranscriptionContainer,
|
|
9
|
-
TranscriptContainer_default as default
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=TranscriptContainer-6WCKCXQ6.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { lazy } from 'react';\n\nexport * from './Transcript';\nexport * from './TranscriptContainer';\n\nexport const TranscriptContainer = lazy(() => import('./TranscriptContainer'));\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,YAAY;AAKd,IAAMC,sBAAsBC,KAAK,MAAM,OAAO,oCAAA,CAAA;",
|
|
6
|
-
"names": ["lazy", "TranscriptContainer", "lazy"]
|
|
7
|
-
}
|