@dxos/plugin-transcription 0.8.4-main.28f8d3d → 0.8.4-main.2c6827d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/TranscriptContainer-OQFBAGSP.mjs +11 -0
- package/dist/lib/browser/blueprint-definition-GZ7NOODS.mjs +147 -0
- package/dist/lib/browser/blueprint-definition-GZ7NOODS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SREIAQSP.mjs → chunk-3MKZ2MNQ.mjs} +5 -5
- package/dist/lib/browser/chunk-3MKZ2MNQ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-KJIQQHJB.mjs → chunk-7GNN7E3U.mjs} +18 -58
- package/dist/lib/browser/chunk-7GNN7E3U.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BJWYA2BU.mjs → chunk-C5YV3JZF.mjs} +91 -135
- package/dist/lib/browser/chunk-C5YV3JZF.mjs.map +7 -0
- package/dist/lib/browser/{chunk-UKUSJTQW.mjs → chunk-O33THH53.mjs} +2 -2
- package/dist/lib/browser/chunk-QOSZIUE2.mjs +32 -0
- package/dist/lib/browser/chunk-QOSZIUE2.mjs.map +7 -0
- package/dist/lib/browser/chunk-VBUIO677.mjs +29 -0
- package/dist/lib/browser/chunk-VBUIO677.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +23 -20
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-5CGCLOXB.mjs +25 -0
- package/dist/lib/browser/intent-resolver-5CGCLOXB.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-4MEJMKYQ.mjs → react-surface-OK55WK7J.mjs} +9 -11
- package/dist/lib/browser/react-surface-OK55WK7J.mjs.map +7 -0
- package/dist/lib/browser/{transcriber-V77CN7XX.mjs → transcriber-6YDM5ZDT.mjs} +7 -7
- package/dist/lib/browser/{transcriber-V77CN7XX.mjs.map → transcriber-6YDM5ZDT.mjs.map} +1 -1
- package/dist/lib/browser/types/index.mjs +4 -8
- package/dist/lib/node-esm/{TranscriptContainer-GEUOOYHX.mjs → TranscriptContainer-GM47P6WH.mjs} +4 -4
- package/dist/lib/node-esm/blueprint-definition-GAHQBYTF.mjs +148 -0
- package/dist/lib/node-esm/blueprint-definition-GAHQBYTF.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-A33GNR44.mjs → chunk-5JN2MHYA.mjs} +18 -58
- package/dist/lib/node-esm/chunk-5JN2MHYA.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-Y7PCJ34K.mjs → chunk-IKGUNN3Z.mjs} +91 -135
- package/dist/lib/node-esm/chunk-IKGUNN3Z.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-PHP7MCAY.mjs → chunk-SSYFSLB7.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-TM2ASOZA.mjs → chunk-SWUVPFKR.mjs} +5 -5
- package/dist/lib/node-esm/chunk-SWUVPFKR.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-U4YPUD2F.mjs +33 -0
- package/dist/lib/node-esm/chunk-U4YPUD2F.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YVNQN2J6.mjs +30 -0
- package/dist/lib/node-esm/chunk-YVNQN2J6.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +23 -20
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-4H4CXIAL.mjs +26 -0
- package/dist/lib/node-esm/intent-resolver-4H4CXIAL.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-EZUPNHUC.mjs → react-surface-EK6K2MMD.mjs} +9 -11
- package/dist/lib/node-esm/react-surface-EK6K2MMD.mjs.map +7 -0
- package/dist/lib/node-esm/{transcriber-3SX3DNLV.mjs → transcriber-CPD3FZ7M.mjs} +7 -7
- package/dist/lib/node-esm/{transcriber-3SX3DNLV.mjs.map → transcriber-CPD3FZ7M.mjs.map} +1 -1
- package/dist/lib/node-esm/types/index.mjs +4 -8
- package/dist/types/src/TranscriptionPlugin.d.ts +1 -1
- package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +3 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/transcriber.d.ts +1 -1
- package/dist/types/src/components/Transcript/Transcript.d.ts +6 -7
- package/dist/types/src/components/Transcript/Transcript.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts +33 -18
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts +3 -3
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/transcript-extension.d.ts +3 -7
- package/dist/types/src/components/Transcript/transcript-extension.d.ts.map +1 -1
- package/dist/types/src/components/TranscriptContainer.d.ts +2 -2
- package/dist/types/src/components/TranscriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts +5 -4
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts +10 -6
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts +7 -6
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/TranscriptionStory.d.ts +4 -3
- package/dist/types/src/components/stories/TranscriptionStory.d.ts.map +1 -1
- package/dist/types/src/functions/index.d.ts +3 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/open.d.ts +7 -0
- package/dist/types/src/functions/open.d.ts.map +1 -0
- package/dist/types/src/functions/summarize.d.ts +11 -0
- package/dist/types/src/functions/summarize.d.ts.map +1 -0
- package/dist/types/src/hooks/useAudioFile.d.ts.map +1 -1
- package/dist/types/src/hooks/useTranscriber.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/message-normalizer.d.ts +3 -3
- package/dist/types/src/segments-normalization/message-normalizer.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/normalization.d.ts +389 -335
- package/dist/types/src/segments-normalization/normalization.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/utils.d.ts +2 -2
- package/dist/types/src/segments-normalization/utils.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +6 -6
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.d.ts +2 -2
- package/dist/types/src/transcriber/transcriber.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcription-manager.d.ts +6 -10
- package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
- package/dist/types/src/types/TranscriptAction.d.ts +23 -0
- package/dist/types/src/types/TranscriptAction.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +0 -26
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +64 -63
- package/src/TranscriptionPlugin.tsx +58 -54
- package/src/capabilities/blueprint-definition.ts +31 -0
- package/src/capabilities/capabilities.ts +3 -3
- package/src/capabilities/index.ts +1 -0
- package/src/capabilities/intent-resolver.ts +5 -10
- package/src/capabilities/react-surface.tsx +2 -2
- package/src/components/Transcript/Transcript.stories.tsx +35 -33
- package/src/components/Transcript/Transcript.tsx +21 -29
- package/src/components/Transcript/deprecated/OldTranscript.tsx +7 -7
- package/src/components/Transcript/transcript-extension.ts +11 -44
- package/src/components/TranscriptContainer.tsx +10 -10
- package/src/components/stories/FileTranscription.stories.tsx +48 -37
- package/src/components/stories/KeyWordRecognition.stories.tsx +15 -11
- package/src/components/stories/MicrophoneTranscription.stories.tsx +43 -40
- package/src/components/stories/TranscriptionStory.tsx +14 -11
- package/src/functions/index.ts +6 -0
- package/src/functions/open.ts +38 -0
- package/src/functions/summarize.ts +103 -0
- package/src/hooks/useAudioFile.ts +49 -53
- package/src/hooks/useTranscriber.ts +7 -2
- package/src/meta.ts +7 -4
- package/src/model/model.test.ts +11 -11
- package/src/segments-normalization/message-normalizer.ts +6 -6
- package/src/segments-normalization/normalization.test.ts +6 -6
- package/src/segments-normalization/normalization.ts +7 -7
- package/src/segments-normalization/utils.ts +2 -2
- package/src/testing/testing.ts +25 -20
- package/src/transcriber/transcriber.browser.test.ts +3 -3
- package/src/transcriber/transcriber.ts +3 -3
- package/src/transcriber/transcription-manager.ts +23 -44
- package/src/types/TranscriptAction.ts +23 -0
- package/src/types/index.ts +1 -1
- package/src/types/types.ts +0 -24
- package/dist/lib/browser/TranscriptContainer-FH7VAWYA.mjs +0 -11
- package/dist/lib/browser/chunk-5WH45KBY.mjs +0 -19
- package/dist/lib/browser/chunk-5WH45KBY.mjs.map +0 -7
- package/dist/lib/browser/chunk-BJWYA2BU.mjs.map +0 -7
- package/dist/lib/browser/chunk-KJIQQHJB.mjs.map +0 -7
- package/dist/lib/browser/chunk-KWOOVS5G.mjs +0 -55
- package/dist/lib/browser/chunk-KWOOVS5G.mjs.map +0 -7
- package/dist/lib/browser/chunk-SREIAQSP.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-AOVQ7JI4.mjs +0 -30
- package/dist/lib/browser/intent-resolver-AOVQ7JI4.mjs.map +0 -7
- package/dist/lib/browser/react-surface-4MEJMKYQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-A33GNR44.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IKQMDRY6.mjs +0 -56
- package/dist/lib/node-esm/chunk-IKQMDRY6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TM2ASOZA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XMUCZBP3.mjs +0 -21
- package/dist/lib/node-esm/chunk-XMUCZBP3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y7PCJ34K.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-P4XPIKQF.mjs +0 -31
- package/dist/lib/node-esm/intent-resolver-P4XPIKQF.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-EZUPNHUC.mjs.map +0 -7
- package/dist/types/src/types/schema.d.ts +0 -41
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/types/schema.ts +0 -41
- /package/dist/lib/browser/{TranscriptContainer-FH7VAWYA.mjs.map → TranscriptContainer-OQFBAGSP.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-UKUSJTQW.mjs.map → chunk-O33THH53.mjs.map} +0 -0
- /package/dist/lib/node-esm/{TranscriptContainer-GEUOOYHX.mjs.map → TranscriptContainer-GM47P6WH.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-PHP7MCAY.mjs.map → chunk-SSYFSLB7.mjs.map} +0 -0
|
@@ -8,17 +8,17 @@ import { describe, test } from 'vitest';
|
|
|
8
8
|
import { scheduleTaskInterval } from '@dxos/async';
|
|
9
9
|
import { Context } from '@dxos/context';
|
|
10
10
|
import { Obj } from '@dxos/echo';
|
|
11
|
+
import { createQueueDXN } from '@dxos/echo/internal';
|
|
11
12
|
import { MemoryQueue } from '@dxos/echo-db';
|
|
12
|
-
import {
|
|
13
|
-
import { FunctionExecutor, ServiceContainer } from '@dxos/functions';
|
|
13
|
+
import { FunctionExecutor, ServiceContainer } from '@dxos/functions-runtime';
|
|
14
14
|
import { log } from '@dxos/log';
|
|
15
|
-
import {
|
|
15
|
+
import { type Actor, Message } from '@dxos/types';
|
|
16
16
|
|
|
17
17
|
import { MessageNormalizer } from './message-normalizer';
|
|
18
18
|
import { type MessageWithRangeId, sentenceNormalization } from './normalization';
|
|
19
19
|
import { getActorId } from './utils';
|
|
20
20
|
|
|
21
|
-
const sender:
|
|
21
|
+
const sender: Actor.Actor = {
|
|
22
22
|
identityDid: 'did:key:123',
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -48,7 +48,7 @@ const messages: MessageWithRangeId[] = [
|
|
|
48
48
|
// No punctuation.
|
|
49
49
|
'in classical physics objects have well-defined properties such as position speed and momentum',
|
|
50
50
|
].map((string, index) =>
|
|
51
|
-
Obj.make(
|
|
51
|
+
Obj.make(Message.Message, {
|
|
52
52
|
created: new Date(Date.now() + 1_000 * index).toISOString(),
|
|
53
53
|
sender,
|
|
54
54
|
blocks: [{ _tag: 'transcript', started: new Date(Date.now() + 1_000 * index).toISOString(), text: string }],
|
|
@@ -108,7 +108,7 @@ describe.skip('SentenceNormalization', () => {
|
|
|
108
108
|
test.only('queue', { timeout: 120_000 }, async () => {
|
|
109
109
|
// Create queue.
|
|
110
110
|
// TODO(dmaretskyi): Use space.queues.create() instead.
|
|
111
|
-
const queue = new MemoryQueue<
|
|
111
|
+
const queue = new MemoryQueue<Message.Message>(createQueueDXN());
|
|
112
112
|
const ctx = new Context();
|
|
113
113
|
let idx = 0;
|
|
114
114
|
scheduleTaskInterval(
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// ISSUE(burdon): defineFunction
|
|
6
6
|
// @ts-nocheck
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import * as Schema from 'effect/Schema';
|
|
9
9
|
|
|
10
10
|
import { AiService, DEFAULT_EDGE_MODEL } from '@dxos/ai';
|
|
11
11
|
import { AiSession } from '@dxos/assistant';
|
|
@@ -13,13 +13,13 @@ import { Obj } from '@dxos/echo';
|
|
|
13
13
|
import { defineFunction } from '@dxos/functions';
|
|
14
14
|
import { ObjectId } from '@dxos/keys';
|
|
15
15
|
import { log } from '@dxos/log';
|
|
16
|
-
import {
|
|
16
|
+
import { Message } from '@dxos/types';
|
|
17
17
|
import { trim } from '@dxos/util';
|
|
18
18
|
|
|
19
19
|
const MessageWithRangeId = Schema.extend(
|
|
20
|
-
|
|
20
|
+
Message.Message,
|
|
21
21
|
Schema.Struct({
|
|
22
|
-
// TODO(mykola): Move to meta in
|
|
22
|
+
// TODO(mykola): Move to meta in Message. Use `Message.Message` instead.
|
|
23
23
|
rangeId: Schema.optional(Schema.Array(Schema.String)).annotations({
|
|
24
24
|
description: 'The IDs of the messages that contain the sentences.',
|
|
25
25
|
}),
|
|
@@ -29,7 +29,7 @@ const MessageWithRangeId = Schema.extend(
|
|
|
29
29
|
export interface MessageWithRangeId extends Schema.Schema.Type<typeof MessageWithRangeId> {}
|
|
30
30
|
|
|
31
31
|
export const NormalizationInput = Schema.Struct({
|
|
32
|
-
// TODO(mykola): Move to meta in
|
|
32
|
+
// TODO(mykola): Move to meta in Message. Use `Message.Message` instead.
|
|
33
33
|
messages: Schema.Array(MessageWithRangeId).annotations({
|
|
34
34
|
description: 'Messages to normalize into sentences.',
|
|
35
35
|
}),
|
|
@@ -61,7 +61,7 @@ export const sentenceNormalization = defineFunction<NormalizationInput, Normaliz
|
|
|
61
61
|
tools: [],
|
|
62
62
|
artifacts: [],
|
|
63
63
|
history: [
|
|
64
|
-
Obj.make(
|
|
64
|
+
Obj.make(Message.Message, {
|
|
65
65
|
created: new Date().toISOString(),
|
|
66
66
|
sender: {
|
|
67
67
|
role: 'user',
|
|
@@ -89,7 +89,7 @@ const prompt = trim`
|
|
|
89
89
|
|
|
90
90
|
# Input Format:
|
|
91
91
|
- The input is an array of messages that contain transcription blocks.
|
|
92
|
-
- Each message is a
|
|
92
|
+
- Each message is a Message.Message, as described in the output format.
|
|
93
93
|
|
|
94
94
|
# Output Format:
|
|
95
95
|
- You have been provided with the tool that defines the output format; make sure to query it.
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Actor } from '@dxos/types';
|
|
6
6
|
|
|
7
|
-
export const getActorId = (actor:
|
|
7
|
+
export const getActorId = (actor: Actor.Actor) => {
|
|
8
8
|
return actor.identityDid || actor.identityKey || actor.email || actor.name || '';
|
|
9
9
|
};
|
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
12
|
import { type Key, Obj, Ref, Type } from '@dxos/echo';
|
|
13
|
-
import { createQueueDXN } from '@dxos/echo
|
|
14
|
-
import { FunctionExecutor, ServiceContainer } from '@dxos/functions';
|
|
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
18
|
import { type Space, useQueue } from '@dxos/react-client/echo';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
19
|
+
import { Testing } 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({
|
|
@@ -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,22 @@ 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
75
|
const obj = this._space.db.add(Obj.make(TestItem, { title: label, description: faker.lorem.paragraph() }));
|
|
75
76
|
const dxn = Ref.make(obj).dxn.toString();
|
|
76
77
|
const words = text.split(' ');
|
|
77
|
-
words.splice(Math.floor(Math.random() * words.length), 0, `[${label}]
|
|
78
|
+
words.splice(Math.floor(Math.random() * words.length), 0, `[${label}](${dxn})`);
|
|
78
79
|
text = words.join(' ');
|
|
79
80
|
}
|
|
80
81
|
|
|
@@ -103,7 +104,7 @@ class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
|
|
|
103
104
|
|
|
104
105
|
space: Space | undefined;
|
|
105
106
|
currentMessage: number = 0;
|
|
106
|
-
transcriptMessages:
|
|
107
|
+
transcriptMessages: Message.Message[] = [];
|
|
107
108
|
|
|
108
109
|
async connect(space: Space): Promise<void> {
|
|
109
110
|
this.space = space;
|
|
@@ -111,14 +112,18 @@ class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
|
|
|
111
112
|
this.transcriptMessages = transcriptMessages;
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
override async createMessage(): Promise<
|
|
115
|
+
override async createMessage(): Promise<Message.Message> {
|
|
115
116
|
if (!this.space) {
|
|
116
117
|
throw new Error('Space not connected');
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
const { objects } = await this.space.db
|
|
120
121
|
.query(
|
|
121
|
-
Filter.or(
|
|
122
|
+
Filter.or(
|
|
123
|
+
Filter.type(Person.Person),
|
|
124
|
+
Filter.type(Organization.Organization),
|
|
125
|
+
Filter.type(Testing.DocumentType),
|
|
126
|
+
),
|
|
122
127
|
)
|
|
123
128
|
.run();
|
|
124
129
|
|
|
@@ -130,7 +135,7 @@ class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
|
|
|
130
135
|
const { message: enhancedMessage } = await processTranscriptMessage({
|
|
131
136
|
input: { message },
|
|
132
137
|
executor: this.executor,
|
|
133
|
-
function:
|
|
138
|
+
function: extractionAnthropicFunction,
|
|
134
139
|
});
|
|
135
140
|
|
|
136
141
|
return enhancedMessage;
|
|
@@ -142,7 +147,7 @@ type UseTestTranscriptionQueue = (
|
|
|
142
147
|
queueId?: Key.ObjectId,
|
|
143
148
|
running?: boolean,
|
|
144
149
|
interval?: number,
|
|
145
|
-
) => Queue<
|
|
150
|
+
) => Queue<Message.Message> | undefined;
|
|
146
151
|
|
|
147
152
|
/**
|
|
148
153
|
* Test transcriptionqueue.
|
|
@@ -155,7 +160,7 @@ export const useTestTranscriptionQueue: UseTestTranscriptionQueue = (
|
|
|
155
160
|
) => {
|
|
156
161
|
// TODO(dmaretskyi): Use space.queues.create() instead.
|
|
157
162
|
const queueDxn = useMemo(() => (space ? createQueueDXN(space.id, queueId) : undefined), [space, queueId]);
|
|
158
|
-
const queue = useQueue<
|
|
163
|
+
const queue = useQueue<Message.Message>(queueDxn);
|
|
159
164
|
const builder = useMemo(() => new MessageBuilder(space), [space]);
|
|
160
165
|
|
|
161
166
|
useEffect(() => {
|
|
@@ -165,7 +170,7 @@ export const useTestTranscriptionQueue: UseTestTranscriptionQueue = (
|
|
|
165
170
|
|
|
166
171
|
const i = setInterval(() => {
|
|
167
172
|
void builder.createMessage(Math.ceil(Math.random() * 3)).then(async (message) => {
|
|
168
|
-
await queue.append([Obj.make(
|
|
173
|
+
await queue.append([Obj.make(Message.Message, message)]);
|
|
169
174
|
});
|
|
170
175
|
}, interval);
|
|
171
176
|
return () => clearInterval(i);
|
|
@@ -186,7 +191,7 @@ export const useTestTranscriptionQueueWithEntityExtraction: UseTestTranscription
|
|
|
186
191
|
) => {
|
|
187
192
|
// TODO(dmaretskyi): Use space.queues.create() instead.
|
|
188
193
|
const queueDxn = useMemo(() => (space ? createQueueDXN(space.id, queueId) : undefined), [space, queueId]);
|
|
189
|
-
const queue = useQueue<
|
|
194
|
+
const queue = useQueue<Message.Message>(queueDxn);
|
|
190
195
|
const [builder] = useState(() => new EntityExtractionMessageBuilder());
|
|
191
196
|
|
|
192
197
|
useEffect(() => {
|
|
@@ -203,7 +208,7 @@ export const useTestTranscriptionQueueWithEntityExtraction: UseTestTranscription
|
|
|
203
208
|
ctx,
|
|
204
209
|
async () => {
|
|
205
210
|
const message = await builder.createMessage();
|
|
206
|
-
void queue.append([Obj.make(
|
|
211
|
+
void queue.append([Obj.make(Message.Message, message)]);
|
|
207
212
|
},
|
|
208
213
|
interval,
|
|
209
214
|
);
|
|
@@ -10,9 +10,9 @@ import { WaveFile } from 'wavefile';
|
|
|
10
10
|
|
|
11
11
|
import { Trigger } from '@dxos/async';
|
|
12
12
|
import { log } from '@dxos/log';
|
|
13
|
-
import { type DataType } from '@dxos/schema';
|
|
14
13
|
import { openAndClose } from '@dxos/test-utils';
|
|
15
14
|
import { TRACE_PROCESSOR, trace } from '@dxos/tracing';
|
|
15
|
+
import { type ContentBlock } from '@dxos/types';
|
|
16
16
|
|
|
17
17
|
import { type AudioChunk, type AudioRecorder, Transcriber } from '../transcriber';
|
|
18
18
|
import { mergeFloat64Arrays } from '../util';
|
|
@@ -94,7 +94,7 @@ describe.skip('Transcriber', () => {
|
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
test.skip('transcription of audio recording', { timeout: 10_000 }, async () => {
|
|
97
|
-
const trigger = new Trigger<
|
|
97
|
+
const trigger = new Trigger<ContentBlock.Transcript[]>({ autoReset: true });
|
|
98
98
|
const recorder = new MockAudioRecorder({
|
|
99
99
|
buffer: await readFile('test.wav'),
|
|
100
100
|
chunkDuration: 3_000,
|
|
@@ -128,7 +128,7 @@ describe.skip('Transcriber', () => {
|
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
test.skip('transcription of audio recording with overlapping chunks', { timeout: 20_000 }, async () => {
|
|
131
|
-
const trigger = new Trigger<
|
|
131
|
+
const trigger = new Trigger<ContentBlock.Transcript[]>({ autoReset: true });
|
|
132
132
|
const recorder = new MockAudioRecorder({
|
|
133
133
|
buffer: await readFile('test.wav'),
|
|
134
134
|
chunkDuration: 3_000,
|
|
@@ -7,8 +7,8 @@ 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
13
|
import { TRANSCRIPTION_URL } from '../types';
|
|
14
14
|
import { mergeFloat64Arrays } from '../util';
|
|
@@ -70,7 +70,7 @@ export type TranscriberParams = {
|
|
|
70
70
|
* Callback to handle the transcribed segments, after all segment transformers are applied.
|
|
71
71
|
* @param segments - The transcribed segments.
|
|
72
72
|
*/
|
|
73
|
-
onSegments: (segments:
|
|
73
|
+
onSegments: (segments: ContentBlock.Transcript[]) => Promise<void>;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
/**
|
|
@@ -221,7 +221,7 @@ export class Transcriber extends Resource {
|
|
|
221
221
|
return segments;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
private _alignSegments(segments: WhisperSegment[], originalChunks: AudioChunk[]):
|
|
224
|
+
private _alignSegments(segments: WhisperSegment[], originalChunks: AudioChunk[]): ContentBlock.Transcript[] {
|
|
225
225
|
// Absolute zero for all relative timestamps in the segments.
|
|
226
226
|
const zeroTimestamp = originalChunks.at(0)!.timestamp;
|
|
227
227
|
|
|
@@ -9,7 +9,7 @@ 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,7 +30,7 @@ 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;
|
|
@@ -51,7 +51,7 @@ export class TranscriptionManager extends Resource {
|
|
|
51
51
|
private _identityDid?: string = undefined;
|
|
52
52
|
private _mediaRecorder?: MediaStreamRecorder = undefined;
|
|
53
53
|
private _transcriber?: Transcriber = undefined;
|
|
54
|
-
private _queue?: Queue<
|
|
54
|
+
private _queue?: Queue<Message.Message> = undefined;
|
|
55
55
|
private _enabled = signal(false);
|
|
56
56
|
|
|
57
57
|
constructor(options: TranscriptionManagerOptions) {
|
|
@@ -65,7 +65,7 @@ export class TranscriptionManager extends Resource {
|
|
|
65
65
|
return this._enabled.value;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
setQueue(queue: Queue<
|
|
68
|
+
setQueue(queue: Queue<Message.Message>): this {
|
|
69
69
|
this._queue = queue;
|
|
70
70
|
return this;
|
|
71
71
|
}
|
|
@@ -90,19 +90,17 @@ export class TranscriptionManager extends Resource {
|
|
|
90
90
|
return this;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
* Enable or disable transcription.
|
|
95
|
-
* @param enabled - Whether to enable transcription.
|
|
96
|
-
*/
|
|
97
|
-
@synchronized
|
|
98
|
-
async setEnabled(enabled?: boolean): Promise<void> {
|
|
93
|
+
async setEnabled(enabled: boolean): Promise<void> {
|
|
99
94
|
if (this._enabled.value === enabled) {
|
|
100
95
|
return;
|
|
101
96
|
}
|
|
102
97
|
|
|
103
98
|
this._enabled.value = enabled ?? false;
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
if (enabled) {
|
|
100
|
+
await this._maybeRestartTranscriber();
|
|
101
|
+
} else {
|
|
102
|
+
await this._stopTranscriber();
|
|
103
|
+
}
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
@synchronized
|
|
@@ -112,44 +110,19 @@ export class TranscriptionManager extends Resource {
|
|
|
112
110
|
}
|
|
113
111
|
|
|
114
112
|
this._audioStreamTrack = track;
|
|
115
|
-
|
|
113
|
+
await this._maybeRestartTranscriber();
|
|
116
114
|
}
|
|
117
115
|
|
|
118
116
|
protected override async _open(): Promise<void> {
|
|
119
|
-
await this.
|
|
117
|
+
await this._maybeRestartTranscriber();
|
|
120
118
|
}
|
|
121
119
|
|
|
122
120
|
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
|
-
}
|
|
121
|
+
await this._stopTranscriber();
|
|
149
122
|
}
|
|
150
123
|
|
|
151
|
-
private async
|
|
152
|
-
if (!this._audioStreamTrack || !this._enabled.value) {
|
|
124
|
+
private async _maybeRestartTranscriber(): Promise<void> {
|
|
125
|
+
if (!this._audioStreamTrack || !this._enabled.value || !this.isOpen) {
|
|
153
126
|
return;
|
|
154
127
|
}
|
|
155
128
|
|
|
@@ -172,15 +145,21 @@ export class TranscriptionManager extends Resource {
|
|
|
172
145
|
recorder: this._mediaRecorder,
|
|
173
146
|
onSegments: (segments) => this._onSegments(segments),
|
|
174
147
|
});
|
|
148
|
+
|
|
149
|
+
await this._transcriber?.open();
|
|
175
150
|
}
|
|
176
151
|
}
|
|
177
152
|
|
|
178
|
-
private async
|
|
153
|
+
private async _stopTranscriber(): Promise<void> {
|
|
154
|
+
await this._transcriber?.close();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private async _onSegments(segments: ContentBlock.Transcript[]): Promise<void> {
|
|
179
158
|
if (!this.isOpen || !this._queue) {
|
|
180
159
|
return;
|
|
181
160
|
}
|
|
182
161
|
|
|
183
|
-
let block = Obj.make(
|
|
162
|
+
let block = Obj.make(Message.Message, {
|
|
184
163
|
created: new Date().toISOString(),
|
|
185
164
|
blocks: segments,
|
|
186
165
|
sender: { identityDid: this._identityDid },
|
|
@@ -0,0 +1,23 @@
|
|
|
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 { Transcript } from '@dxos/types';
|
|
9
|
+
|
|
10
|
+
import { meta } from '../meta';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Endpoint to the calls service.
|
|
14
|
+
*/
|
|
15
|
+
export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {
|
|
16
|
+
input: Schema.Struct({
|
|
17
|
+
name: Schema.optional(Schema.String),
|
|
18
|
+
space: SpaceSchema,
|
|
19
|
+
}),
|
|
20
|
+
output: Schema.Struct({
|
|
21
|
+
object: Transcript.Transcript,
|
|
22
|
+
}),
|
|
23
|
+
}) {}
|
package/src/types/index.ts
CHANGED
package/src/types/types.ts
CHANGED
|
@@ -2,32 +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 { TRANSCRIPTION_PLUGIN } from '../meta';
|
|
10
|
-
|
|
11
|
-
import { TranscriptType } from './schema';
|
|
12
|
-
|
|
13
|
-
// TODO(burdon): Move to separate proto.
|
|
14
|
-
|
|
15
5
|
/**
|
|
16
6
|
* Endpoint to the calls service.
|
|
17
7
|
*/
|
|
18
8
|
// TODO(burdon): Reconfigure/move.
|
|
19
9
|
export const TRANSCRIPTION_URL = 'https://calls-service.dxos.workers.dev';
|
|
20
|
-
|
|
21
|
-
export namespace TranscriptionAction {
|
|
22
|
-
const TRANSCRIPTION_ACTION = `${TRANSCRIPTION_PLUGIN}/action`;
|
|
23
|
-
|
|
24
|
-
export class Create extends Schema.TaggedClass<Create>()(`${TRANSCRIPTION_ACTION}/create`, {
|
|
25
|
-
input: Schema.Struct({
|
|
26
|
-
name: Schema.optional(Schema.String),
|
|
27
|
-
spaceId: SpaceId,
|
|
28
|
-
}),
|
|
29
|
-
output: Schema.Struct({
|
|
30
|
-
object: TranscriptType,
|
|
31
|
-
}),
|
|
32
|
-
}) {}
|
|
33
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TranscriptContainer_default,
|
|
3
|
-
TranscriptionContainer
|
|
4
|
-
} from "./chunk-BJWYA2BU.mjs";
|
|
5
|
-
import "./chunk-SREIAQSP.mjs";
|
|
6
|
-
import "./chunk-5WH45KBY.mjs";
|
|
7
|
-
export {
|
|
8
|
-
TranscriptionContainer,
|
|
9
|
-
TranscriptContainer_default as default
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=TranscriptContainer-FH7VAWYA.mjs.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// src/meta.ts
|
|
2
|
-
var TRANSCRIPTION_PLUGIN = "dxos.org/plugin/transcription";
|
|
3
|
-
var meta = {
|
|
4
|
-
id: TRANSCRIPTION_PLUGIN,
|
|
5
|
-
name: "Transcription",
|
|
6
|
-
description: "Voice transcription.",
|
|
7
|
-
icon: "ph--microphone--regular",
|
|
8
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-transcription",
|
|
9
|
-
tags: [
|
|
10
|
-
"labs"
|
|
11
|
-
],
|
|
12
|
-
screenshots: []
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
TRANSCRIPTION_PLUGIN,
|
|
17
|
-
meta
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=chunk-5WH45KBY.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const TRANSCRIPTION_PLUGIN = 'dxos.org/plugin/transcription';\n\nexport const meta: PluginMeta = {\n id: TRANSCRIPTION_PLUGIN,\n name: 'Transcription',\n description: 'Voice transcription.',\n icon: 'ph--microphone--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-transcription',\n tags: ['labs'],\n screenshots: [],\n};\n"],
|
|
5
|
-
"mappings": ";AAMO,IAAMA,uBAAuB;AAE7B,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,QAAQ;EACRC,MAAM;IAAC;;EACPC,aAAa,CAAA;AACf;",
|
|
6
|
-
"names": ["TRANSCRIPTION_PLUGIN", "meta", "id", "name", "description", "icon", "source", "tags", "screenshots"]
|
|
7
|
-
}
|