@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
package/src/testing/testing.ts
CHANGED
|
@@ -2,24 +2,22 @@
|
|
|
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 {
|
|
9
|
-
import { AI_SERVICE_ENDPOINT } from '@dxos/ai/testing';
|
|
10
|
-
import { extractionAnthropicFn, processTranscriptMessage } from '@dxos/assistant';
|
|
8
|
+
import { extractionAnthropicFunction, processTranscriptMessage } from '@dxos/assistant/extraction';
|
|
11
9
|
import { scheduleTaskInterval } from '@dxos/async';
|
|
12
10
|
import { Filter, type Queue } from '@dxos/client/echo';
|
|
13
11
|
import { Context } from '@dxos/context';
|
|
14
12
|
import { type Key, Obj, Ref, Type } from '@dxos/echo';
|
|
15
|
-
import { createQueueDXN } from '@dxos/echo
|
|
16
|
-
import { FunctionExecutor, ServiceContainer } from '@dxos/functions';
|
|
13
|
+
import { createQueueDXN } from '@dxos/echo/internal';
|
|
17
14
|
import { IdentityDid } from '@dxos/keys';
|
|
18
15
|
import { log } from '@dxos/log';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
16
|
+
import { random } from '@dxos/random';
|
|
17
|
+
import { type Space, useQueue } from '@dxos/react-client/echo';
|
|
18
|
+
import { TestSchema } from '@dxos/schema/testing';
|
|
19
|
+
import { type ContentBlock, Message, Organization, Person } from '@dxos/types';
|
|
20
|
+
import { seedTestData } from '@dxos/types/testing';
|
|
23
21
|
|
|
24
22
|
// TODO(burdon): Reconcile with plugin-markdown. Move to @dxos/schema/testing.
|
|
25
23
|
export const TestItem = Schema.Struct({
|
|
@@ -32,15 +30,15 @@ export const TestItem = Schema.Struct({
|
|
|
32
30
|
description: 'Product description',
|
|
33
31
|
}),
|
|
34
32
|
}).pipe(
|
|
35
|
-
Type.
|
|
36
|
-
typename: 'dxos.
|
|
33
|
+
Type.object({
|
|
34
|
+
typename: 'org.dxos.type.test',
|
|
37
35
|
version: '0.1.0',
|
|
38
36
|
}),
|
|
39
37
|
);
|
|
40
38
|
|
|
41
39
|
// TODO(wittjosiah): Make builder generic and reuse for all message types.
|
|
42
40
|
abstract class AbstractMessageBuilder {
|
|
43
|
-
abstract createMessage(numSegments?: number): Promise<
|
|
41
|
+
abstract createMessage(numSegments?: number): Promise<Message.Message>;
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
/**
|
|
@@ -51,8 +49,8 @@ export class MessageBuilder extends AbstractMessageBuilder {
|
|
|
51
49
|
|
|
52
50
|
users = Array.from({ length: 5 }, () => ({
|
|
53
51
|
identityDid: IdentityDid.random().toString(),
|
|
54
|
-
name:
|
|
55
|
-
email:
|
|
52
|
+
name: random.person.fullName(),
|
|
53
|
+
email: random.internet.email(),
|
|
56
54
|
}));
|
|
57
55
|
|
|
58
56
|
start = new Date(Date.now() - 24 * 60 * 60 * 10_000);
|
|
@@ -61,27 +59,32 @@ export class MessageBuilder extends AbstractMessageBuilder {
|
|
|
61
59
|
super();
|
|
62
60
|
}
|
|
63
61
|
|
|
64
|
-
override async createMessage(numSegments = 1): Promise<
|
|
65
|
-
return Obj.make(
|
|
62
|
+
override async createMessage(numSegments = 1): Promise<Message.Message> {
|
|
63
|
+
return Obj.make(Message.Message, {
|
|
66
64
|
created: this.next().toISOString(),
|
|
67
|
-
sender:
|
|
65
|
+
sender: random.helpers.arrayElement(this.users),
|
|
68
66
|
blocks: Array.from({ length: numSegments }).map(() => this.createBlock()),
|
|
69
67
|
});
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
createBlock():
|
|
73
|
-
let text =
|
|
70
|
+
createBlock(): ContentBlock.Transcript {
|
|
71
|
+
let text = random.lorem.paragraph();
|
|
74
72
|
if (this._space) {
|
|
75
|
-
const label =
|
|
76
|
-
const obj = this._space.db.add(
|
|
73
|
+
const label = random.commerce.productName();
|
|
74
|
+
const obj = this._space.db.add(
|
|
75
|
+
Obj.make(TestItem, {
|
|
76
|
+
title: label,
|
|
77
|
+
description: random.lorem.paragraph(),
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
77
80
|
const dxn = Ref.make(obj).dxn.toString();
|
|
78
81
|
const words = text.split(' ');
|
|
79
|
-
words.splice(Math.floor(Math.random() * words.length), 0, `[${label}]
|
|
82
|
+
words.splice(Math.floor(Math.random() * words.length), 0, `[${label}](${dxn})`);
|
|
80
83
|
text = words.join(' ');
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
return {
|
|
84
|
-
|
|
87
|
+
_tag: 'transcript',
|
|
85
88
|
started: this.next().toISOString(),
|
|
86
89
|
text,
|
|
87
90
|
};
|
|
@@ -95,15 +98,9 @@ export class MessageBuilder extends AbstractMessageBuilder {
|
|
|
95
98
|
|
|
96
99
|
// TODO(burdon): Reconcile with BlockBuilder.
|
|
97
100
|
class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
|
|
98
|
-
AiService = new EdgeAiServiceClient({
|
|
99
|
-
endpoint: AI_SERVICE_ENDPOINT.REMOTE,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
executor = new FunctionExecutor(new ServiceContainer().setServices({ ai: { client: this.AiService } }));
|
|
103
|
-
|
|
104
101
|
space: Space | undefined;
|
|
105
102
|
currentMessage: number = 0;
|
|
106
|
-
transcriptMessages:
|
|
103
|
+
transcriptMessages: Message.Message[] = [];
|
|
107
104
|
|
|
108
105
|
async connect(space: Space): Promise<void> {
|
|
109
106
|
this.space = space;
|
|
@@ -111,14 +108,18 @@ class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
|
|
|
111
108
|
this.transcriptMessages = transcriptMessages;
|
|
112
109
|
}
|
|
113
110
|
|
|
114
|
-
override async createMessage(): Promise<
|
|
111
|
+
override async createMessage(): Promise<Message.Message> {
|
|
115
112
|
if (!this.space) {
|
|
116
113
|
throw new Error('Space not connected');
|
|
117
114
|
}
|
|
118
115
|
|
|
119
|
-
const
|
|
116
|
+
const objects = await this.space.db
|
|
120
117
|
.query(
|
|
121
|
-
Filter.or(
|
|
118
|
+
Filter.or(
|
|
119
|
+
Filter.type(Person.Person),
|
|
120
|
+
Filter.type(Organization.Organization),
|
|
121
|
+
Filter.type(TestSchema.DocumentType),
|
|
122
|
+
),
|
|
122
123
|
)
|
|
123
124
|
.run();
|
|
124
125
|
|
|
@@ -129,8 +130,7 @@ class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
|
|
|
129
130
|
|
|
130
131
|
const { message: enhancedMessage } = await processTranscriptMessage({
|
|
131
132
|
input: { message },
|
|
132
|
-
|
|
133
|
-
function: extractionAnthropicFn,
|
|
133
|
+
function: extractionAnthropicFunction,
|
|
134
134
|
});
|
|
135
135
|
|
|
136
136
|
return enhancedMessage;
|
|
@@ -142,7 +142,7 @@ type UseTestTranscriptionQueue = (
|
|
|
142
142
|
queueId?: Key.ObjectId,
|
|
143
143
|
running?: boolean,
|
|
144
144
|
interval?: number,
|
|
145
|
-
) => Queue<
|
|
145
|
+
) => Queue<Message.Message> | undefined;
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
* Test transcriptionqueue.
|
|
@@ -155,7 +155,7 @@ export const useTestTranscriptionQueue: UseTestTranscriptionQueue = (
|
|
|
155
155
|
) => {
|
|
156
156
|
// TODO(dmaretskyi): Use space.queues.create() instead.
|
|
157
157
|
const queueDxn = useMemo(() => (space ? createQueueDXN(space.id, queueId) : undefined), [space, queueId]);
|
|
158
|
-
const queue = useQueue<
|
|
158
|
+
const queue = useQueue<Message.Message>(queueDxn);
|
|
159
159
|
const builder = useMemo(() => new MessageBuilder(space), [space]);
|
|
160
160
|
|
|
161
161
|
useEffect(() => {
|
|
@@ -165,7 +165,7 @@ export const useTestTranscriptionQueue: UseTestTranscriptionQueue = (
|
|
|
165
165
|
|
|
166
166
|
const i = setInterval(() => {
|
|
167
167
|
void builder.createMessage(Math.ceil(Math.random() * 3)).then(async (message) => {
|
|
168
|
-
await queue.append([Obj.make(
|
|
168
|
+
await queue.append([Obj.make(Message.Message, message)]);
|
|
169
169
|
});
|
|
170
170
|
}, interval);
|
|
171
171
|
return () => clearInterval(i);
|
|
@@ -186,7 +186,7 @@ export const useTestTranscriptionQueueWithEntityExtraction: UseTestTranscription
|
|
|
186
186
|
) => {
|
|
187
187
|
// TODO(dmaretskyi): Use space.queues.create() instead.
|
|
188
188
|
const queueDxn = useMemo(() => (space ? createQueueDXN(space.id, queueId) : undefined), [space, queueId]);
|
|
189
|
-
const queue = useQueue<
|
|
189
|
+
const queue = useQueue<Message.Message>(queueDxn);
|
|
190
190
|
const [builder] = useState(() => new EntityExtractionMessageBuilder());
|
|
191
191
|
|
|
192
192
|
useEffect(() => {
|
|
@@ -203,7 +203,7 @@ export const useTestTranscriptionQueueWithEntityExtraction: UseTestTranscription
|
|
|
203
203
|
ctx,
|
|
204
204
|
async () => {
|
|
205
205
|
const message = await builder.createMessage();
|
|
206
|
-
void queue.append([Obj.make(
|
|
206
|
+
void queue.append([Obj.make(Message.Message, message)]);
|
|
207
207
|
},
|
|
208
208
|
interval,
|
|
209
209
|
);
|
package/src/transcriber/index.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -9,9 +9,9 @@ import { WaveFile } from 'wavefile';
|
|
|
9
9
|
|
|
10
10
|
import { Trigger } from '@dxos/async';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
|
-
import { type DataType } from '@dxos/schema';
|
|
13
12
|
import { openAndClose } from '@dxos/test-utils';
|
|
14
|
-
import {
|
|
13
|
+
import { TRACE_PROCESSOR, trace } from '@dxos/tracing';
|
|
14
|
+
import { type ContentBlock } from '@dxos/types';
|
|
15
15
|
|
|
16
16
|
import { type AudioChunk, type AudioRecorder, Transcriber } from '../transcriber';
|
|
17
17
|
import { mergeFloat64Arrays } from '../util';
|
|
@@ -93,7 +93,7 @@ describe.skip('Transcriber', () => {
|
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
test.skip('transcription of audio recording', { timeout: 10_000 }, async () => {
|
|
96
|
-
const trigger = new Trigger<
|
|
96
|
+
const trigger = new Trigger<ContentBlock.Transcript[]>({ autoReset: true });
|
|
97
97
|
const recorder = new MockAudioRecorder({
|
|
98
98
|
buffer: await readFile('test.wav'),
|
|
99
99
|
chunkDuration: 3_000,
|
|
@@ -127,7 +127,7 @@ describe.skip('Transcriber', () => {
|
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
test.skip('transcription of audio recording with overlapping chunks', { timeout: 20_000 }, async () => {
|
|
130
|
-
const trigger = new Trigger<
|
|
130
|
+
const trigger = new Trigger<ContentBlock.Transcript[]>({ autoReset: true });
|
|
131
131
|
const recorder = new MockAudioRecorder({
|
|
132
132
|
buffer: await readFile('test.wav'),
|
|
133
133
|
chunkDuration: 3_000,
|
|
@@ -212,7 +212,7 @@ class MockAudioRecorder implements AudioRecorder {
|
|
|
212
212
|
|
|
213
213
|
@trace.span()
|
|
214
214
|
async start(): Promise<void> {
|
|
215
|
-
log.info('start mock audio recorder', {
|
|
215
|
+
log.info('start mock audio recorder', { wavProps: this.wav.fmt });
|
|
216
216
|
const now = Date.now();
|
|
217
217
|
const samples = this.wav.getSamples();
|
|
218
218
|
const sampleRate = this.wavConfig.sampleRate;
|
|
@@ -7,12 +7,13 @@ 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
|
+
|
|
13
|
+
import { TRANSCRIPTION_URL } from '#types';
|
|
12
14
|
|
|
13
|
-
import { type AudioRecorder, type AudioChunk } from './audio-recorder';
|
|
14
|
-
import { TRANSCRIPTION_URL } from '../types';
|
|
15
15
|
import { mergeFloat64Arrays } from '../util';
|
|
16
|
+
import { type AudioChunk, type AudioRecorder } from './audio-recorder';
|
|
16
17
|
|
|
17
18
|
type WhisperWord = {
|
|
18
19
|
word: string;
|
|
@@ -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,10 +221,7 @@ export class Transcriber extends Resource {
|
|
|
220
221
|
return segments;
|
|
221
222
|
}
|
|
222
223
|
|
|
223
|
-
private _alignSegments(
|
|
224
|
-
segments: WhisperSegment[],
|
|
225
|
-
originalChunks: AudioChunk[],
|
|
226
|
-
): DataType.MessageBlock.Transcription[] {
|
|
224
|
+
private _alignSegments(segments: WhisperSegment[], originalChunks: AudioChunk[]): ContentBlock.Transcript[] {
|
|
227
225
|
// Absolute zero for all relative timestamps in the segments.
|
|
228
226
|
const zeroTimestamp = originalChunks.at(0)!.timestamp;
|
|
229
227
|
|
|
@@ -252,7 +250,7 @@ export class Transcriber extends Resource {
|
|
|
252
250
|
|
|
253
251
|
// Add absolute timestamp to each segment.
|
|
254
252
|
return filteredSegments.map((segment) => ({
|
|
255
|
-
|
|
253
|
+
_tag: 'transcript',
|
|
256
254
|
started: new Date(zeroTimestamp + segment.start * 1_000).toISOString(),
|
|
257
255
|
text: segment.text.trim(),
|
|
258
256
|
}));
|
|
@@ -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: [{ type: 'transcription', 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: [{ type: 'transcription', 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 },
|
package/src/translations.ts
CHANGED
|
@@ -4,20 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Resource } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
|
-
import { meta } from '
|
|
7
|
+
import { meta } from '#meta';
|
|
8
8
|
|
|
9
9
|
export const translations = [
|
|
10
10
|
{
|
|
11
11
|
'en-US': {
|
|
12
12
|
[meta.id]: {
|
|
13
|
-
'plugin
|
|
14
|
-
'transcript
|
|
13
|
+
'plugin.name': 'Transcription',
|
|
14
|
+
'transcript-companion.label': 'Transcript',
|
|
15
15
|
|
|
16
|
-
'delete
|
|
17
|
-
'bookmark
|
|
18
|
-
'scroll
|
|
16
|
+
'delete.button': 'Delete',
|
|
17
|
+
'bookmark.button': 'Bookmark',
|
|
18
|
+
'scroll-to-end.label': 'Scroll to latest',
|
|
19
19
|
|
|
20
|
-
'settings
|
|
20
|
+
'settings.entity-extraction.label': 'Entity extraction',
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
},
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Capability } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from '#meta';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
type MediaStreamRecorderProps,
|
|
11
|
+
type Transcriber,
|
|
12
|
+
type TranscriberProps,
|
|
13
|
+
type TranscriptMessageEnricher,
|
|
14
|
+
type TranscriptionManager,
|
|
15
|
+
} from '../transcriber';
|
|
16
|
+
|
|
17
|
+
export namespace TranscriptionCapabilities {
|
|
18
|
+
export type GetTranscriberProps = {
|
|
19
|
+
audioStreamTrack: MediaStreamTrack;
|
|
20
|
+
recorderConfig?: Partial<MediaStreamRecorderProps['config']>;
|
|
21
|
+
transcriberConfig?: Partial<TranscriberProps['config']>;
|
|
22
|
+
onSegments: TranscriberProps['onSegments'];
|
|
23
|
+
};
|
|
24
|
+
export type GetTranscriber = (props: GetTranscriberProps) => Transcriber;
|
|
25
|
+
export const Transcriber = Capability.make<GetTranscriber>(`${meta.id}.capability.transcriber`);
|
|
26
|
+
|
|
27
|
+
export type GetTranscriptionManagerProps = {
|
|
28
|
+
messageEnricher?: TranscriptMessageEnricher;
|
|
29
|
+
};
|
|
30
|
+
export type GetTranscriptionManager = (props: GetTranscriptionManagerProps) => TranscriptionManager;
|
|
31
|
+
export const TranscriptionManager = Capability.make<GetTranscriptionManager>(
|
|
32
|
+
`${meta.id}.capability.transcription-manager`,
|
|
33
|
+
);
|
|
34
|
+
}
|
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
|
+
};
|