@dxos/plugin-transcription 0.8.4-main.28f8d3d → 0.8.4-main.406dc2a
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-QN5WUMWJ.mjs +11 -0
- package/dist/lib/browser/blueprint-definition-GO6GTEBT.mjs +150 -0
- package/dist/lib/browser/blueprint-definition-GO6GTEBT.mjs.map +7 -0
- package/dist/lib/browser/{chunk-UKUSJTQW.mjs → chunk-77NWYLC6.mjs} +2 -2
- package/dist/lib/browser/{chunk-5WH45KBY.mjs → chunk-7LNCQDTT.mjs} +9 -4
- package/dist/lib/browser/chunk-7LNCQDTT.mjs.map +7 -0
- package/dist/lib/browser/{chunk-KJIQQHJB.mjs → chunk-COBQIZ6B.mjs} +78 -98
- package/dist/lib/browser/{chunk-KJIQQHJB.mjs.map → chunk-COBQIZ6B.mjs.map} +3 -3
- package/dist/lib/browser/chunk-GGHMOEKZ.mjs +63 -0
- package/dist/lib/browser/chunk-GGHMOEKZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SREIAQSP.mjs → chunk-LCK3YRQF.mjs} +5 -5
- package/dist/lib/browser/chunk-LCK3YRQF.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BJWYA2BU.mjs → chunk-ZS2FXKEF.mjs} +141 -168
- package/dist/lib/browser/chunk-ZS2FXKEF.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +22 -18
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-52EPFRMR.mjs +25 -0
- package/dist/lib/browser/intent-resolver-52EPFRMR.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-4MEJMKYQ.mjs → react-surface-LCP2D2MF.mjs} +10 -10
- package/dist/lib/browser/react-surface-LCP2D2MF.mjs.map +7 -0
- package/dist/lib/browser/{transcriber-V77CN7XX.mjs → transcriber-NG5MRCP6.mjs} +7 -7
- package/dist/lib/browser/{transcriber-V77CN7XX.mjs.map → transcriber-NG5MRCP6.mjs.map} +1 -1
- package/dist/lib/browser/types/index.mjs +6 -8
- package/dist/lib/node-esm/{TranscriptContainer-GEUOOYHX.mjs → TranscriptContainer-WCUWVVSD.mjs} +4 -4
- package/dist/lib/node-esm/blueprint-definition-6SU7GLBR.mjs +151 -0
- package/dist/lib/node-esm/blueprint-definition-6SU7GLBR.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-A33GNR44.mjs → chunk-A6SB234F.mjs} +78 -98
- package/dist/lib/node-esm/{chunk-A33GNR44.mjs.map → chunk-A6SB234F.mjs.map} +3 -3
- package/dist/lib/node-esm/chunk-FTTZ4YSX.mjs +64 -0
- package/dist/lib/node-esm/chunk-FTTZ4YSX.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-XMUCZBP3.mjs → chunk-KLTPFUKN.mjs} +8 -4
- package/dist/lib/node-esm/chunk-KLTPFUKN.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-PHP7MCAY.mjs → chunk-N5Z4SKPH.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-Y7PCJ34K.mjs → chunk-PEZRQYKO.mjs} +141 -168
- package/dist/lib/node-esm/chunk-PEZRQYKO.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-TM2ASOZA.mjs → chunk-RWRG3S2O.mjs} +5 -5
- package/dist/lib/node-esm/chunk-RWRG3S2O.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +22 -18
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-DZBQQRHN.mjs +26 -0
- package/dist/lib/node-esm/intent-resolver-DZBQQRHN.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-EZUPNHUC.mjs → react-surface-7UC2YXX2.mjs} +10 -10
- package/dist/lib/node-esm/react-surface-7UC2YXX2.mjs.map +7 -0
- package/dist/lib/node-esm/{transcriber-3SX3DNLV.mjs → transcriber-SMU7HD6F.mjs} +7 -7
- package/dist/lib/node-esm/{transcriber-3SX3DNLV.mjs.map → transcriber-SMU7HD6F.mjs.map} +1 -1
- package/dist/lib/node-esm/types/index.mjs +6 -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 +5 -5
- package/dist/types/src/components/Transcript/Transcript.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts +31 -16
- 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 +1 -5
- 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 +8 -4
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts +13 -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 -6
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/TranscriptionStory.d.ts +2 -1
- 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/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/normalization.d.ts +376 -331
- package/dist/types/src/segments-normalization/normalization.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +1 -1
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcription-manager.d.ts +3 -7
- package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
- package/dist/types/src/types/Transcript.d.ts +30 -0
- package/dist/types/src/types/Transcript.d.ts.map +1 -0
- 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 +2 -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 +61 -62
- package/src/TranscriptionPlugin.tsx +57 -53
- 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 +4 -10
- package/src/capabilities/react-surface.tsx +2 -2
- package/src/components/Transcript/Transcript.stories.tsx +32 -30
- package/src/components/Transcript/Transcript.tsx +17 -25
- package/src/components/Transcript/deprecated/OldTranscript.tsx +7 -7
- package/src/components/Transcript/transcript-extension.ts +2 -39
- package/src/components/TranscriptContainer.tsx +6 -6
- package/src/components/stories/FileTranscription.stories.tsx +42 -30
- package/src/components/stories/KeyWordRecognition.stories.tsx +16 -9
- package/src/components/stories/MicrophoneTranscription.stories.tsx +36 -32
- package/src/components/stories/TranscriptionStory.tsx +10 -6
- package/src/functions/index.ts +6 -0
- package/src/functions/open.ts +39 -0
- package/src/functions/summarize.ts +103 -0
- package/src/hooks/useAudioFile.ts +49 -53
- package/src/meta.ts +1 -3
- package/src/segments-normalization/normalization.test.ts +1 -1
- package/src/segments-normalization/normalization.ts +1 -1
- package/src/testing/testing.ts +5 -5
- package/src/transcriber/transcription-manager.ts +17 -38
- package/src/types/{schema.ts → Transcript.ts} +12 -9
- package/src/types/TranscriptAction.ts +24 -0
- package/src/types/index.ts +2 -1
- package/src/types/types.ts +0 -24
- package/dist/lib/browser/TranscriptContainer-FH7VAWYA.mjs +0 -11
- 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-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-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.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/dist/lib/browser/{TranscriptContainer-FH7VAWYA.mjs.map → TranscriptContainer-QN5WUMWJ.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-UKUSJTQW.mjs.map → chunk-77NWYLC6.mjs.map} +0 -0
- /package/dist/lib/node-esm/{TranscriptContainer-GEUOOYHX.mjs.map → TranscriptContainer-WCUWVVSD.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-PHP7MCAY.mjs.map → chunk-N5Z4SKPH.mjs.map} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
7
|
+
|
|
8
|
+
import { ArtifactId } from '@dxos/assistant';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { DatabaseService, QueueService, defineFunction } from '@dxos/functions';
|
|
11
|
+
import { DataType } from '@dxos/schema';
|
|
12
|
+
|
|
13
|
+
import { renderByline } from '../components';
|
|
14
|
+
import { Transcript } from '../types';
|
|
15
|
+
|
|
16
|
+
export default defineFunction({
|
|
17
|
+
key: 'dxos.org/function/transcription/open',
|
|
18
|
+
name: 'Open',
|
|
19
|
+
description: 'Opens and reads the contents of a transcription object.',
|
|
20
|
+
inputSchema: Schema.Struct({
|
|
21
|
+
id: ArtifactId.annotations({
|
|
22
|
+
description: 'The ID of the transcription object.',
|
|
23
|
+
}),
|
|
24
|
+
}),
|
|
25
|
+
outputSchema: Schema.Struct({
|
|
26
|
+
content: Schema.String,
|
|
27
|
+
}),
|
|
28
|
+
handler: Effect.fn(function* ({ data: { id } }) {
|
|
29
|
+
const transcript = yield* DatabaseService.resolve(ArtifactId.toDXN(id), Transcript.Transcript);
|
|
30
|
+
const { dxn } = yield* Effect.promise(() => transcript.queue.load());
|
|
31
|
+
const queue = yield* QueueService.getQueue(dxn);
|
|
32
|
+
yield* Effect.promise(() => queue?.queryObjects());
|
|
33
|
+
const content = queue?.objects
|
|
34
|
+
.filter((message) => Obj.instanceOf(DataType.Message, message))
|
|
35
|
+
.flatMap((message, index) => renderByline([])(message, index))
|
|
36
|
+
.join('\n\n');
|
|
37
|
+
return { content };
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Array from 'effect/Array';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import * as Function from 'effect/Function';
|
|
8
|
+
import * as Layer from 'effect/Layer';
|
|
9
|
+
import * as Option from 'effect/Option';
|
|
10
|
+
import * as Schema from 'effect/Schema';
|
|
11
|
+
|
|
12
|
+
import { AiService, ConsolePrinter, ToolExecutionService, ToolResolverService } from '@dxos/ai';
|
|
13
|
+
import { AiSession, GenerationObserver } from '@dxos/assistant';
|
|
14
|
+
import { TracingService, defineFunction } from '@dxos/functions';
|
|
15
|
+
import { trim } from '@dxos/util';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Summarize a transcript of a meeting.
|
|
19
|
+
*/
|
|
20
|
+
export default defineFunction({
|
|
21
|
+
key: 'dxos.org/function/transcription/summarize',
|
|
22
|
+
name: 'Summarize',
|
|
23
|
+
description: 'Summarize a transcript of a meeting.',
|
|
24
|
+
inputSchema: Schema.Struct({
|
|
25
|
+
transcript: Schema.String.annotations({
|
|
26
|
+
description: 'The transcript of the meeting.',
|
|
27
|
+
}),
|
|
28
|
+
notes: Schema.optional(Schema.String).annotations({
|
|
29
|
+
description: 'Additional notes from the participants.',
|
|
30
|
+
}),
|
|
31
|
+
}),
|
|
32
|
+
outputSchema: Schema.Struct({
|
|
33
|
+
summary: Schema.String.annotations({
|
|
34
|
+
description: 'The summary of the transcript.',
|
|
35
|
+
}),
|
|
36
|
+
}),
|
|
37
|
+
handler: Effect.fnUntraced(
|
|
38
|
+
function* ({ data: { transcript, notes } }) {
|
|
39
|
+
const result = yield* new AiSession().run({
|
|
40
|
+
prompt: `Transcript: ${transcript}\n\nNotes: ${notes}`,
|
|
41
|
+
history: [],
|
|
42
|
+
system: systemPrompt,
|
|
43
|
+
observer: GenerationObserver.fromPrinter(new ConsolePrinter({ tag: 'summarize' })),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const summary = Function.pipe(
|
|
47
|
+
result,
|
|
48
|
+
Array.findLast((msg) => msg.sender.role === 'assistant' && msg.blocks.some((block) => block._tag === 'text')),
|
|
49
|
+
Option.flatMap((msg) =>
|
|
50
|
+
Function.pipe(
|
|
51
|
+
msg.blocks,
|
|
52
|
+
Array.findLast((block) => block._tag === 'text'),
|
|
53
|
+
Option.map((block) => block.text),
|
|
54
|
+
),
|
|
55
|
+
),
|
|
56
|
+
Option.getOrThrowWith(() => new Error('No summary found')),
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return { summary };
|
|
60
|
+
},
|
|
61
|
+
Effect.provide(
|
|
62
|
+
Layer.mergeAll(
|
|
63
|
+
AiService.model('@anthropic/claude-sonnet-4-0'),
|
|
64
|
+
ToolResolverService.layerEmpty,
|
|
65
|
+
ToolExecutionService.layerEmpty,
|
|
66
|
+
TracingService.layerNoop,
|
|
67
|
+
),
|
|
68
|
+
),
|
|
69
|
+
),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const systemPrompt = trim`
|
|
73
|
+
You are a helpful assistant that summarizes transcripts of meetings.
|
|
74
|
+
|
|
75
|
+
# Goal
|
|
76
|
+
Create a markdown summary of the meeting transcript with text notes provided.
|
|
77
|
+
Notes are very important so make sure to include them in the summary if they contain meaningful information.
|
|
78
|
+
|
|
79
|
+
# Formatting
|
|
80
|
+
- Format the summary as a markdown document without extra comments like "Here is the summary of the transcript:".
|
|
81
|
+
- Use markdown formatting for headings and bullet points.
|
|
82
|
+
- Format the summary as a list of key points and takeaways.
|
|
83
|
+
- All names of people should be in bold.
|
|
84
|
+
|
|
85
|
+
# Note Taking
|
|
86
|
+
- Correlate items in the summary with the person of origin to build a coherent narrative.
|
|
87
|
+
- Include short quotes verbatim where appropriate. Especially when concerned with design decisions and problem descriptions.
|
|
88
|
+
|
|
89
|
+
# Tasks
|
|
90
|
+
At the end of the summary include tasks.
|
|
91
|
+
Extract only the tasks that are:
|
|
92
|
+
- Directly actionable.
|
|
93
|
+
- Clearly assigned to a person or team (or can easily be inferred).
|
|
94
|
+
- Strongly implied by the conversation and/or user note (no speculative tasks).
|
|
95
|
+
- Specific enough that someone reading them would know exactly what to do next.
|
|
96
|
+
|
|
97
|
+
Format all tasks as markdown checkboxes using the syntax:
|
|
98
|
+
- [ ] Task description.
|
|
99
|
+
|
|
100
|
+
Additional information can be included (indented).
|
|
101
|
+
|
|
102
|
+
If no actionable tasks are found, omit this tasks section.
|
|
103
|
+
`;
|
|
@@ -20,67 +20,63 @@ export const useAudioFile = (audioUrl: string, constraints?: MediaTrackConstrain
|
|
|
20
20
|
const ctx = new Context();
|
|
21
21
|
|
|
22
22
|
scheduleTask(ctx, async () => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
URL.
|
|
28
|
-
|
|
23
|
+
// TODO(wittjosiah): Fetch to external url fails in headless storybook test.
|
|
24
|
+
try {
|
|
25
|
+
const response = await fetch(audioUrl);
|
|
26
|
+
const blob = await response.blob();
|
|
27
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
28
|
+
ctx.onDispose(() => {
|
|
29
|
+
URL.revokeObjectURL(objectUrl);
|
|
30
|
+
});
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
const audio = new Audio();
|
|
33
|
+
audio.src = objectUrl;
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
log.info('starting...');
|
|
46
|
-
try {
|
|
47
|
-
// Try to play the audio
|
|
48
|
-
await audio.play();
|
|
35
|
+
await new Promise<void>((resolve, reject) => {
|
|
36
|
+
audio.addEventListener(
|
|
37
|
+
'error',
|
|
38
|
+
(err) => {
|
|
39
|
+
log.error('error', { err });
|
|
40
|
+
reject(err);
|
|
41
|
+
},
|
|
42
|
+
{ once: true },
|
|
43
|
+
);
|
|
44
|
+
audio.addEventListener(
|
|
45
|
+
'canplay',
|
|
46
|
+
async () => {
|
|
49
47
|
resolve();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
{ once: true },
|
|
57
|
-
);
|
|
58
|
-
audio.load();
|
|
59
|
-
});
|
|
48
|
+
},
|
|
49
|
+
{ once: true },
|
|
50
|
+
);
|
|
51
|
+
audio.load();
|
|
52
|
+
});
|
|
60
53
|
|
|
61
|
-
|
|
54
|
+
const audioCtx = new AudioContext();
|
|
62
55
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
// Resume AudioContext if it's suspended.
|
|
57
|
+
if (audioCtx.state === 'suspended') {
|
|
58
|
+
await audioCtx.resume();
|
|
59
|
+
}
|
|
67
60
|
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
const destination = audioCtx.createMediaStreamDestination();
|
|
62
|
+
destination.channelCount = 1;
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
64
|
+
const source = audioCtx.createMediaElementSource(audio);
|
|
65
|
+
source.connect(destination);
|
|
66
|
+
const track = destination.stream.getAudioTracks()[0];
|
|
67
|
+
if (constraints) {
|
|
68
|
+
await track.applyConstraints(constraints).catch((err) => log.catch(err));
|
|
69
|
+
}
|
|
77
70
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
// Also connect to speakers so audio is audible.
|
|
72
|
+
setStream({
|
|
73
|
+
audio,
|
|
74
|
+
stream: destination.stream,
|
|
75
|
+
track: destination.stream.getAudioTracks()[0],
|
|
76
|
+
});
|
|
77
|
+
} catch (err) {
|
|
78
|
+
log.catch(err);
|
|
79
|
+
}
|
|
84
80
|
});
|
|
85
81
|
|
|
86
82
|
return () => {
|
package/src/meta.ts
CHANGED
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
-
export const TRANSCRIPTION_PLUGIN = 'dxos.org/plugin/transcription';
|
|
8
|
-
|
|
9
7
|
export const meta: PluginMeta = {
|
|
10
|
-
id:
|
|
8
|
+
id: 'dxos.org/plugin/transcription',
|
|
11
9
|
name: 'Transcription',
|
|
12
10
|
description: 'Voice transcription.',
|
|
13
11
|
icon: 'ph--microphone--regular',
|
|
@@ -8,8 +8,8 @@ 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 { createQueueDXN } from '@dxos/echo-schema';
|
|
13
13
|
import { FunctionExecutor, ServiceContainer } from '@dxos/functions';
|
|
14
14
|
import { log } from '@dxos/log';
|
|
15
15
|
import { DataType } from '@dxos/schema';
|
package/src/testing/testing.ts
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
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
|
|
13
|
+
import { createQueueDXN } from '@dxos/echo/internal';
|
|
14
14
|
import { FunctionExecutor, ServiceContainer } from '@dxos/functions';
|
|
15
15
|
import { IdentityDid } from '@dxos/keys';
|
|
16
16
|
import { log } from '@dxos/log';
|
|
@@ -74,7 +74,7 @@ export class MessageBuilder extends AbstractMessageBuilder {
|
|
|
74
74
|
const obj = this._space.db.add(Obj.make(TestItem, { title: label, description: faker.lorem.paragraph() }));
|
|
75
75
|
const dxn = Ref.make(obj).dxn.toString();
|
|
76
76
|
const words = text.split(' ');
|
|
77
|
-
words.splice(Math.floor(Math.random() * words.length), 0, `[${label}]
|
|
77
|
+
words.splice(Math.floor(Math.random() * words.length), 0, `[${label}](${dxn})`);
|
|
78
78
|
text = words.join(' ');
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -130,7 +130,7 @@ class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
|
|
|
130
130
|
const { message: enhancedMessage } = await processTranscriptMessage({
|
|
131
131
|
input: { message },
|
|
132
132
|
executor: this.executor,
|
|
133
|
-
function:
|
|
133
|
+
function: extractionAnthropicFunction,
|
|
134
134
|
});
|
|
135
135
|
|
|
136
136
|
return enhancedMessage;
|
|
@@ -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,9 +145,15 @@ 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
|
|
|
153
|
+
private async _stopTranscriber(): Promise<void> {
|
|
154
|
+
await this._transcriber?.close();
|
|
155
|
+
}
|
|
156
|
+
|
|
178
157
|
private async _onSegments(segments: DataType.MessageBlock.Transcript[]): Promise<void> {
|
|
179
158
|
if (!this.isOpen || !this._queue) {
|
|
180
159
|
return;
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
7
|
import { Queue } from '@dxos/client/echo';
|
|
8
|
-
import { Type } from '@dxos/echo';
|
|
9
|
-
import { TypedObject } from '@dxos/echo-schema';
|
|
8
|
+
import { type DXN, Obj, Ref, Type } from '@dxos/echo';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Root transcript object created when the user starts a transcription.
|
|
13
12
|
*/
|
|
14
|
-
export const
|
|
13
|
+
export const Transcript = Schema.Struct({
|
|
15
14
|
// TODO(wittjosiah): Remove?
|
|
16
15
|
// TODO(burdon): Use Date or string?
|
|
17
16
|
started: Schema.optional(Schema.String),
|
|
@@ -21,12 +20,14 @@ export const TranscriptSchema = Schema.Struct({
|
|
|
21
20
|
* Queue containing TranscriptBlock objects.
|
|
22
21
|
*/
|
|
23
22
|
queue: Type.Ref(Queue),
|
|
24
|
-
})
|
|
23
|
+
}).pipe(
|
|
24
|
+
Type.Obj({
|
|
25
|
+
typename: 'dxos.org/type/Transcript',
|
|
26
|
+
version: '0.1.0',
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
25
29
|
|
|
26
|
-
export
|
|
27
|
-
typename: 'dxos.org/type/Transcript',
|
|
28
|
-
version: '0.1.0',
|
|
29
|
-
})(TranscriptSchema.fields) {}
|
|
30
|
+
export type Transcript = Schema.Schema.Type<typeof Transcript>;
|
|
30
31
|
|
|
31
32
|
// TODO(burdon): Do these need to be kept in sync with EDGE?
|
|
32
33
|
|
|
@@ -39,3 +40,5 @@ const TranscriptHeader = Schema.Struct({
|
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
export type TranscriptHeader = Schema.Schema.Type<typeof TranscriptHeader>;
|
|
43
|
+
|
|
44
|
+
export const makeTranscript = (queueDxn: DXN) => Obj.make(Transcript, { queue: Ref.fromDXN(queueDxn) });
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { SpaceSchema } from '@dxos/client/echo';
|
|
8
|
+
|
|
9
|
+
import { meta } from '../meta';
|
|
10
|
+
|
|
11
|
+
import { Transcript } from './Transcript';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Endpoint to the calls service.
|
|
15
|
+
*/
|
|
16
|
+
export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {
|
|
17
|
+
input: Schema.Struct({
|
|
18
|
+
name: Schema.optional(Schema.String),
|
|
19
|
+
space: SpaceSchema,
|
|
20
|
+
}),
|
|
21
|
+
output: Schema.Struct({
|
|
22
|
+
object: Transcript,
|
|
23
|
+
}),
|
|
24
|
+
}) {}
|
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,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
|
-
}
|