@dxos/plugin-transcription 0.8.4-main.2e9d522 → 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-4FJIYH7T.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-FFEPEPCU.mjs → chunk-COBQIZ6B.mjs} +85 -94
- package/dist/lib/browser/chunk-COBQIZ6B.mjs.map +7 -0
- package/dist/lib/browser/chunk-GGHMOEKZ.mjs +63 -0
- package/dist/lib/browser/chunk-GGHMOEKZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-U6QBOGTN.mjs → chunk-LCK3YRQF.mjs} +5 -5
- package/dist/lib/browser/chunk-LCK3YRQF.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5KPYIC3N.mjs → chunk-ZS2FXKEF.mjs} +410 -418
- 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-E5D5AE3F.mjs → react-surface-LCP2D2MF.mjs} +10 -10
- package/dist/lib/browser/react-surface-LCP2D2MF.mjs.map +7 -0
- package/dist/lib/browser/{transcriber-PXT4QBFY.mjs → transcriber-NG5MRCP6.mjs} +7 -7
- package/dist/lib/browser/transcriber-NG5MRCP6.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +6 -8
- package/dist/lib/node-esm/{TranscriptContainer-VBAOM5DG.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-HT3W7LDP.mjs → chunk-A6SB234F.mjs} +85 -94
- package/dist/lib/node-esm/chunk-A6SB234F.mjs.map +7 -0
- 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-Y2B4HWSS.mjs → chunk-N5Z4SKPH.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-TJKAO7VR.mjs → chunk-PEZRQYKO.mjs} +410 -418
- package/dist/lib/node-esm/chunk-PEZRQYKO.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-RHF2ALML.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-QRDJOHN5.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-YUTEVANE.mjs → transcriber-SMU7HD6F.mjs} +7 -7
- package/dist/lib/node-esm/transcriber-SMU7HD6F.mjs.map +7 -0
- 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 +1 -1
- 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/capabilities/transcriber.d.ts.map +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/hooks/useVoiceInput.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 -325
- package/dist/types/src/segments-normalization/normalization.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +2 -2
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/transcriber/media-stream-recorder.d.ts +1 -1
- package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.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 +63 -62
- package/src/TranscriptionPlugin.tsx +57 -53
- package/src/capabilities/blueprint-definition.ts +31 -0
- package/src/capabilities/capabilities.ts +6 -6
- package/src/capabilities/index.ts +1 -0
- package/src/capabilities/intent-resolver.ts +5 -11
- package/src/capabilities/react-surface.tsx +2 -2
- package/src/capabilities/transcriber.ts +3 -2
- package/src/components/Transcript/Transcript.stories.tsx +34 -31
- package/src/components/Transcript/Transcript.tsx +20 -27
- package/src/components/Transcript/deprecated/OldTranscript.tsx +9 -9
- package/src/components/Transcript/transcript-extension.ts +2 -39
- package/src/components/TranscriptContainer.tsx +7 -6
- package/src/components/stories/FileTranscription.stories.tsx +49 -36
- package/src/components/stories/KeyWordRecognition.stories.tsx +17 -10
- package/src/components/stories/MicrophoneTranscription.stories.tsx +43 -38
- 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/hooks/useVoiceInput.ts +3 -2
- package/src/meta.ts +1 -3
- package/src/model/model.test.ts +1 -1
- package/src/segments-normalization/message-normalizer.ts +1 -1
- package/src/segments-normalization/normalization.test.ts +5 -5
- package/src/segments-normalization/normalization.ts +38 -37
- package/src/testing/testing.ts +7 -7
- package/src/transcriber/media-stream-recorder.ts +1 -1
- package/src/transcriber/transcriber.browser.test.ts +2 -1
- package/src/transcriber/transcriber.ts +2 -1
- 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 -23
- package/dist/lib/browser/TranscriptContainer-6WCKCXQ6.mjs +0 -11
- package/dist/lib/browser/chunk-5KPYIC3N.mjs.map +0 -7
- package/dist/lib/browser/chunk-5WH45KBY.mjs.map +0 -7
- package/dist/lib/browser/chunk-FFEPEPCU.mjs.map +0 -7
- package/dist/lib/browser/chunk-R7INNNUQ.mjs +0 -55
- package/dist/lib/browser/chunk-R7INNNUQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-U6QBOGTN.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-3O33MMP5.mjs +0 -30
- package/dist/lib/browser/intent-resolver-3O33MMP5.mjs.map +0 -7
- package/dist/lib/browser/react-surface-E5D5AE3F.mjs.map +0 -7
- package/dist/lib/browser/transcriber-PXT4QBFY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HT3W7LDP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RHF2ALML.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TJKAO7VR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-U65ZWK3L.mjs +0 -56
- package/dist/lib/node-esm/chunk-U65ZWK3L.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XMUCZBP3.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-YMN5SXNC.mjs +0 -31
- package/dist/lib/node-esm/intent-resolver-YMN5SXNC.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-QRDJOHN5.mjs.map +0 -7
- package/dist/lib/node-esm/transcriber-YUTEVANE.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-6WCKCXQ6.mjs.map → TranscriptContainer-QN5WUMWJ.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-4FJIYH7T.mjs.map → chunk-77NWYLC6.mjs.map} +0 -0
- /package/dist/lib/node-esm/{TranscriptContainer-VBAOM5DG.mjs.map → TranscriptContainer-WCUWVVSD.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-Y2B4HWSS.mjs.map → chunk-N5Z4SKPH.mjs.map} +0 -0
|
@@ -2,12 +2,12 @@ import {
|
|
|
2
2
|
MediaStreamRecorder,
|
|
3
3
|
Transcriber,
|
|
4
4
|
TranscriptionManager
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-R7INNNUQ.mjs";
|
|
5
|
+
} from "./chunk-COBQIZ6B.mjs";
|
|
7
6
|
import {
|
|
8
7
|
TranscriptionCapabilities
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-LCK3YRQF.mjs";
|
|
9
|
+
import "./chunk-GGHMOEKZ.mjs";
|
|
10
|
+
import "./chunk-7LNCQDTT.mjs";
|
|
11
11
|
|
|
12
12
|
// src/capabilities/transcriber.ts
|
|
13
13
|
import { contributes } from "@dxos/app-framework";
|
|
@@ -15,7 +15,7 @@ import { ClientCapabilities } from "@dxos/plugin-client";
|
|
|
15
15
|
var RECORD_INTERVAL = 200;
|
|
16
16
|
var PREFIXED_CHUNKS_AMOUNT = 10;
|
|
17
17
|
var TRANSCRIBE_AFTER_CHUNKS_AMOUNT = 50;
|
|
18
|
-
var transcriber_default = (context) => {
|
|
18
|
+
var transcriber_default = ((context) => {
|
|
19
19
|
const getTranscriber = ({ audioStreamTrack, onSegments, transcriberConfig, recorderConfig }) => {
|
|
20
20
|
return new Transcriber({
|
|
21
21
|
config: {
|
|
@@ -49,8 +49,8 @@ var transcriber_default = (context) => {
|
|
|
49
49
|
contributes(TranscriptionCapabilities.Transcriber, getTranscriber),
|
|
50
50
|
contributes(TranscriptionCapabilities.TranscriptionManager, getTranscriptionManager)
|
|
51
51
|
];
|
|
52
|
-
};
|
|
52
|
+
});
|
|
53
53
|
export {
|
|
54
54
|
transcriber_default as default
|
|
55
55
|
};
|
|
56
|
-
//# sourceMappingURL=transcriber-
|
|
56
|
+
//# sourceMappingURL=transcriber-NG5MRCP6.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/transcriber.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type PluginContext, contributes } from '@dxos/app-framework';\nimport { ClientCapabilities } from '@dxos/plugin-client';\n\nimport { MediaStreamRecorder, Transcriber, TranscriptionManager } from '../transcriber';\n\nimport { TranscriptionCapabilities } from './capabilities';\n\n// TODO(burdon): Move to config?\n\n/**\n * Length of the chunk in ms.\n */\nconst RECORD_INTERVAL = 200;\n\n/**\n * Number of chunks to save before the user starts speaking.\n */\nconst PREFIXED_CHUNKS_AMOUNT = 10;\n\n/**\n * Number of chunks to transcribe automatically after.\n * Combined should be mess than 25MB or whisper would fail.\n */\nconst TRANSCRIBE_AFTER_CHUNKS_AMOUNT = 50;\n\n/**\n * Records audio while user is speaking and transcribes it after user is done speaking.\n */\nexport default (context: PluginContext) => {\n const getTranscriber: TranscriptionCapabilities.GetTranscriber = ({\n audioStreamTrack,\n onSegments,\n transcriberConfig,\n recorderConfig,\n }) => {\n // Initialize audio transcription.\n return new Transcriber({\n config: {\n transcribeAfterChunksAmount: TRANSCRIBE_AFTER_CHUNKS_AMOUNT,\n prefixBufferChunksAmount: PREFIXED_CHUNKS_AMOUNT,\n ...transcriberConfig,\n },\n recorder: new MediaStreamRecorder({\n mediaStreamTrack: audioStreamTrack,\n config: {\n interval: RECORD_INTERVAL,\n ...recorderConfig,\n },\n }),\n onSegments,\n });\n };\n\n const getTranscriptionManager: TranscriptionCapabilities.GetTranscriptionManager = ({ messageEnricher }) => {\n const client = context.getCapability(ClientCapabilities.Client);\n const transcriptionManager = new TranscriptionManager({\n edgeClient: client.edge,\n messageEnricher,\n });\n\n const identity = client.halo.identity.get();\n if (identity) {\n transcriptionManager.setIdentityDid(identity.did);\n }\n\n return transcriptionManager;\n };\n\n return [\n contributes(TranscriptionCapabilities.Transcriber, getTranscriber),\n contributes(TranscriptionCapabilities.TranscriptionManager, getTranscriptionManager),\n ];\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAIA,SAA6BA,mBAAmB;AAChD,SAASC,0BAA0B;AAWnC,IAAMC,kBAAkB;AAKxB,IAAMC,yBAAyB;AAM/B,IAAMC,iCAAiC;AAKvC,IAAA,uBAAe,CAACC,YAAAA;AACd,QAAMC,iBAA2D,CAAC,EAChEC,kBACAC,YACAC,mBACAC,eAAc,MACf;AAEC,WAAO,IAAIC,YAAY;MACrBC,QAAQ;QACNC,6BAA6BT;QAC7BU,0BAA0BX;QAC1B,GAAGM;MACL;MACAM,UAAU,IAAIC,oBAAoB;QAChCC,kBAAkBV;QAClBK,QAAQ;UACNM,UAAUhB;UACV,GAAGQ;QACL;MACF,CAAA;MACAF;IACF,CAAA;EACF;AAEA,QAAMW,0BAA6E,CAAC,EAAEC,gBAAe,MAAE;AACrG,UAAMC,SAAShB,QAAQiB,cAAcC,mBAAmBC,MAAM;AAC9D,UAAMC,uBAAuB,IAAIC,qBAAqB;MACpDC,YAAYN,OAAOO;MACnBR;IACF,CAAA;AAEA,UAAMS,WAAWR,OAAOS,KAAKD,SAASE,IAAG;AACzC,QAAIF,UAAU;AACZJ,2BAAqBO,eAAeH,SAASI,GAAG;IAClD;AAEA,WAAOR;EACT;AAEA,SAAO;IACLS,YAAYC,0BAA0BxB,aAAaL,cAAAA;IACnD4B,YAAYC,0BAA0BT,sBAAsBP,uBAAAA;;AAEhE;",
|
|
6
|
+
"names": ["contributes", "ClientCapabilities", "RECORD_INTERVAL", "PREFIXED_CHUNKS_AMOUNT", "TRANSCRIBE_AFTER_CHUNKS_AMOUNT", "context", "getTranscriber", "audioStreamTrack", "onSegments", "transcriberConfig", "recorderConfig", "Transcriber", "config", "transcribeAfterChunksAmount", "prefixBufferChunksAmount", "recorder", "MediaStreamRecorder", "mediaStreamTrack", "interval", "getTranscriptionManager", "messageEnricher", "client", "getCapability", "ClientCapabilities", "Client", "transcriptionManager", "TranscriptionManager", "edgeClient", "edge", "identity", "halo", "get", "setIdentityDid", "did", "contributes", "TranscriptionCapabilities"]
|
|
7
|
+
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TRANSCRIPTION_URL,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import "../chunk-5WH45KBY.mjs";
|
|
3
|
+
TranscriptAction_exports,
|
|
4
|
+
Transcript_exports
|
|
5
|
+
} from "../chunk-GGHMOEKZ.mjs";
|
|
6
|
+
import "../chunk-7LNCQDTT.mjs";
|
|
8
7
|
export {
|
|
9
8
|
TRANSCRIPTION_URL,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
TranscriptionAction
|
|
9
|
+
Transcript_exports as Transcript,
|
|
10
|
+
TranscriptAction_exports as TranscriptAction
|
|
13
11
|
};
|
|
14
12
|
//# sourceMappingURL=index.mjs.map
|
package/dist/lib/node-esm/{TranscriptContainer-VBAOM5DG.mjs → TranscriptContainer-WCUWVVSD.mjs}
RENAMED
|
@@ -2,11 +2,11 @@ import { createRequire } from 'node:module';const require = createRequire(import
|
|
|
2
2
|
import {
|
|
3
3
|
TranscriptContainer_default,
|
|
4
4
|
TranscriptionContainer
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-PEZRQYKO.mjs";
|
|
6
|
+
import "./chunk-RWRG3S2O.mjs";
|
|
7
|
+
import "./chunk-KLTPFUKN.mjs";
|
|
8
8
|
export {
|
|
9
9
|
TranscriptionContainer,
|
|
10
10
|
TranscriptContainer_default as default
|
|
11
11
|
};
|
|
12
|
-
//# sourceMappingURL=TranscriptContainer-
|
|
12
|
+
//# sourceMappingURL=TranscriptContainer-WCUWVVSD.mjs.map
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import "./chunk-N5Z4SKPH.mjs";
|
|
3
|
+
import {
|
|
4
|
+
renderByline
|
|
5
|
+
} from "./chunk-PEZRQYKO.mjs";
|
|
6
|
+
import "./chunk-RWRG3S2O.mjs";
|
|
7
|
+
import {
|
|
8
|
+
Transcript_exports
|
|
9
|
+
} from "./chunk-FTTZ4YSX.mjs";
|
|
10
|
+
import "./chunk-KLTPFUKN.mjs";
|
|
11
|
+
|
|
12
|
+
// src/capabilities/blueprint-definition.ts
|
|
13
|
+
import { Capabilities, contributes } from "@dxos/app-framework";
|
|
14
|
+
import { Blueprint, Template } from "@dxos/blueprints";
|
|
15
|
+
import { trim as trim2 } from "@dxos/util";
|
|
16
|
+
|
|
17
|
+
// src/functions/open.ts
|
|
18
|
+
import * as Effect from "effect/Effect";
|
|
19
|
+
import * as Schema from "effect/Schema";
|
|
20
|
+
import { ArtifactId } from "@dxos/assistant";
|
|
21
|
+
import { Obj } from "@dxos/echo";
|
|
22
|
+
import { DatabaseService, QueueService, defineFunction } from "@dxos/functions";
|
|
23
|
+
import { DataType } from "@dxos/schema";
|
|
24
|
+
var open_default = defineFunction({
|
|
25
|
+
key: "dxos.org/function/transcription/open",
|
|
26
|
+
name: "Open",
|
|
27
|
+
description: "Opens and reads the contents of a transcription object.",
|
|
28
|
+
inputSchema: Schema.Struct({
|
|
29
|
+
id: ArtifactId.annotations({
|
|
30
|
+
description: "The ID of the transcription object."
|
|
31
|
+
})
|
|
32
|
+
}),
|
|
33
|
+
outputSchema: Schema.Struct({
|
|
34
|
+
content: Schema.String
|
|
35
|
+
}),
|
|
36
|
+
handler: Effect.fn(function* ({ data: { id } }) {
|
|
37
|
+
const transcript = yield* DatabaseService.resolve(ArtifactId.toDXN(id), Transcript_exports.Transcript);
|
|
38
|
+
const { dxn } = yield* Effect.promise(() => transcript.queue.load());
|
|
39
|
+
const queue = yield* QueueService.getQueue(dxn);
|
|
40
|
+
yield* Effect.promise(() => queue?.queryObjects());
|
|
41
|
+
const content = queue?.objects.filter((message) => Obj.instanceOf(DataType.Message, message)).flatMap((message, index) => renderByline([])(message, index)).join("\n\n");
|
|
42
|
+
return {
|
|
43
|
+
content
|
|
44
|
+
};
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// src/functions/summarize.ts
|
|
49
|
+
import * as Array from "effect/Array";
|
|
50
|
+
import * as Effect2 from "effect/Effect";
|
|
51
|
+
import * as Function from "effect/Function";
|
|
52
|
+
import * as Layer from "effect/Layer";
|
|
53
|
+
import * as Option from "effect/Option";
|
|
54
|
+
import * as Schema2 from "effect/Schema";
|
|
55
|
+
import { AiService, ConsolePrinter, ToolExecutionService, ToolResolverService } from "@dxos/ai";
|
|
56
|
+
import { AiSession, GenerationObserver } from "@dxos/assistant";
|
|
57
|
+
import { TracingService, defineFunction as defineFunction2 } from "@dxos/functions";
|
|
58
|
+
import { trim } from "@dxos/util";
|
|
59
|
+
var summarize_default = defineFunction2({
|
|
60
|
+
key: "dxos.org/function/transcription/summarize",
|
|
61
|
+
name: "Summarize",
|
|
62
|
+
description: "Summarize a transcript of a meeting.",
|
|
63
|
+
inputSchema: Schema2.Struct({
|
|
64
|
+
transcript: Schema2.String.annotations({
|
|
65
|
+
description: "The transcript of the meeting."
|
|
66
|
+
}),
|
|
67
|
+
notes: Schema2.optional(Schema2.String).annotations({
|
|
68
|
+
description: "Additional notes from the participants."
|
|
69
|
+
})
|
|
70
|
+
}),
|
|
71
|
+
outputSchema: Schema2.Struct({
|
|
72
|
+
summary: Schema2.String.annotations({
|
|
73
|
+
description: "The summary of the transcript."
|
|
74
|
+
})
|
|
75
|
+
}),
|
|
76
|
+
handler: Effect2.fnUntraced(function* ({ data: { transcript, notes } }) {
|
|
77
|
+
const result = yield* new AiSession().run({
|
|
78
|
+
prompt: `Transcript: ${transcript}
|
|
79
|
+
|
|
80
|
+
Notes: ${notes}`,
|
|
81
|
+
history: [],
|
|
82
|
+
system: systemPrompt,
|
|
83
|
+
observer: GenerationObserver.fromPrinter(new ConsolePrinter({
|
|
84
|
+
tag: "summarize"
|
|
85
|
+
}))
|
|
86
|
+
});
|
|
87
|
+
const summary = Function.pipe(result, Array.findLast((msg) => msg.sender.role === "assistant" && msg.blocks.some((block) => block._tag === "text")), Option.flatMap((msg) => Function.pipe(msg.blocks, Array.findLast((block) => block._tag === "text"), Option.map((block) => block.text))), Option.getOrThrowWith(() => new Error("No summary found")));
|
|
88
|
+
return {
|
|
89
|
+
summary
|
|
90
|
+
};
|
|
91
|
+
}, Effect2.provide(Layer.mergeAll(AiService.model("@anthropic/claude-sonnet-4-0"), ToolResolverService.layerEmpty, ToolExecutionService.layerEmpty, TracingService.layerNoop)))
|
|
92
|
+
});
|
|
93
|
+
var systemPrompt = trim`
|
|
94
|
+
You are a helpful assistant that summarizes transcripts of meetings.
|
|
95
|
+
|
|
96
|
+
# Goal
|
|
97
|
+
Create a markdown summary of the meeting transcript with text notes provided.
|
|
98
|
+
Notes are very important so make sure to include them in the summary if they contain meaningful information.
|
|
99
|
+
|
|
100
|
+
# Formatting
|
|
101
|
+
- Format the summary as a markdown document without extra comments like "Here is the summary of the transcript:".
|
|
102
|
+
- Use markdown formatting for headings and bullet points.
|
|
103
|
+
- Format the summary as a list of key points and takeaways.
|
|
104
|
+
- All names of people should be in bold.
|
|
105
|
+
|
|
106
|
+
# Note Taking
|
|
107
|
+
- Correlate items in the summary with the person of origin to build a coherent narrative.
|
|
108
|
+
- Include short quotes verbatim where appropriate. Especially when concerned with design decisions and problem descriptions.
|
|
109
|
+
|
|
110
|
+
# Tasks
|
|
111
|
+
At the end of the summary include tasks.
|
|
112
|
+
Extract only the tasks that are:
|
|
113
|
+
- Directly actionable.
|
|
114
|
+
- Clearly assigned to a person or team (or can easily be inferred).
|
|
115
|
+
- Strongly implied by the conversation and/or user note (no speculative tasks).
|
|
116
|
+
- Specific enough that someone reading them would know exactly what to do next.
|
|
117
|
+
|
|
118
|
+
Format all tasks as markdown checkboxes using the syntax:
|
|
119
|
+
- [ ] Task description.
|
|
120
|
+
|
|
121
|
+
Additional information can be included (indented).
|
|
122
|
+
|
|
123
|
+
If no actionable tasks are found, omit this tasks section.
|
|
124
|
+
`;
|
|
125
|
+
|
|
126
|
+
// src/capabilities/blueprint-definition.ts
|
|
127
|
+
var functions = [
|
|
128
|
+
open_default,
|
|
129
|
+
summarize_default
|
|
130
|
+
];
|
|
131
|
+
var blueprint_definition_default = (() => {
|
|
132
|
+
return [
|
|
133
|
+
contributes(Capabilities.Functions, functions),
|
|
134
|
+
contributes(Capabilities.BlueprintDefinition, Blueprint.make({
|
|
135
|
+
key: "dxos.org/blueprint/transcription",
|
|
136
|
+
name: "Transcription",
|
|
137
|
+
tools: Blueprint.toolDefinitions({
|
|
138
|
+
functions
|
|
139
|
+
}),
|
|
140
|
+
instructions: Template.make({
|
|
141
|
+
source: trim2`
|
|
142
|
+
You can open and summarize a meeting transcript.
|
|
143
|
+
`
|
|
144
|
+
})
|
|
145
|
+
}))
|
|
146
|
+
];
|
|
147
|
+
});
|
|
148
|
+
export {
|
|
149
|
+
blueprint_definition_default as default
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=blueprint-definition-6SU7GLBR.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/blueprint-definition.ts", "../../../src/functions/open.ts", "../../../src/functions/summarize.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, contributes } from '@dxos/app-framework';\nimport { Blueprint, Template } from '@dxos/blueprints';\nimport { type FunctionDefinition } from '@dxos/functions';\nimport { trim } from '@dxos/util';\n\nimport { open, summarize } from '../functions';\n\nconst functions: FunctionDefinition[] = [open, summarize];\n\nexport default () => {\n return [\n contributes(Capabilities.Functions, functions),\n contributes(\n Capabilities.BlueprintDefinition,\n Blueprint.make({\n key: 'dxos.org/blueprint/transcription',\n name: 'Transcription',\n tools: Blueprint.toolDefinitions({ functions }),\n instructions: Template.make({\n source: trim`\n You can open and summarize a meeting transcript.\n `,\n }),\n }),\n ),\n ];\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { ArtifactId } from '@dxos/assistant';\nimport { Obj } from '@dxos/echo';\nimport { DatabaseService, QueueService, defineFunction } from '@dxos/functions';\nimport { DataType } from '@dxos/schema';\n\nimport { renderByline } from '../components';\nimport { Transcript } from '../types';\n\nexport default defineFunction({\n key: 'dxos.org/function/transcription/open',\n name: 'Open',\n description: 'Opens and reads the contents of a transcription object.',\n inputSchema: Schema.Struct({\n id: ArtifactId.annotations({\n description: 'The ID of the transcription object.',\n }),\n }),\n outputSchema: Schema.Struct({\n content: Schema.String,\n }),\n handler: Effect.fn(function* ({ data: { id } }) {\n const transcript = yield* DatabaseService.resolve(ArtifactId.toDXN(id), Transcript.Transcript);\n const { dxn } = yield* Effect.promise(() => transcript.queue.load());\n const queue = yield* QueueService.getQueue(dxn);\n yield* Effect.promise(() => queue?.queryObjects());\n const content = queue?.objects\n .filter((message) => Obj.instanceOf(DataType.Message, message))\n .flatMap((message, index) => renderByline([])(message, index))\n .join('\\n\\n');\n return { content };\n }),\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Array from 'effect/Array';\nimport * as Effect from 'effect/Effect';\nimport * as Function from 'effect/Function';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\n\nimport { AiService, ConsolePrinter, ToolExecutionService, ToolResolverService } from '@dxos/ai';\nimport { AiSession, GenerationObserver } from '@dxos/assistant';\nimport { TracingService, defineFunction } from '@dxos/functions';\nimport { trim } from '@dxos/util';\n\n/**\n * Summarize a transcript of a meeting.\n */\nexport default defineFunction({\n key: 'dxos.org/function/transcription/summarize',\n name: 'Summarize',\n description: 'Summarize a transcript of a meeting.',\n inputSchema: Schema.Struct({\n transcript: Schema.String.annotations({\n description: 'The transcript of the meeting.',\n }),\n notes: Schema.optional(Schema.String).annotations({\n description: 'Additional notes from the participants.',\n }),\n }),\n outputSchema: Schema.Struct({\n summary: Schema.String.annotations({\n description: 'The summary of the transcript.',\n }),\n }),\n handler: Effect.fnUntraced(\n function* ({ data: { transcript, notes } }) {\n const result = yield* new AiSession().run({\n prompt: `Transcript: ${transcript}\\n\\nNotes: ${notes}`,\n history: [],\n system: systemPrompt,\n observer: GenerationObserver.fromPrinter(new ConsolePrinter({ tag: 'summarize' })),\n });\n\n const summary = Function.pipe(\n result,\n Array.findLast((msg) => msg.sender.role === 'assistant' && msg.blocks.some((block) => block._tag === 'text')),\n Option.flatMap((msg) =>\n Function.pipe(\n msg.blocks,\n Array.findLast((block) => block._tag === 'text'),\n Option.map((block) => block.text),\n ),\n ),\n Option.getOrThrowWith(() => new Error('No summary found')),\n );\n\n return { summary };\n },\n Effect.provide(\n Layer.mergeAll(\n AiService.model('@anthropic/claude-sonnet-4-0'),\n ToolResolverService.layerEmpty,\n ToolExecutionService.layerEmpty,\n TracingService.layerNoop,\n ),\n ),\n ),\n});\n\nconst systemPrompt = trim`\n You are a helpful assistant that summarizes transcripts of meetings.\n\n # Goal\n Create a markdown summary of the meeting transcript with text notes provided.\n Notes are very important so make sure to include them in the summary if they contain meaningful information.\n\n # Formatting\n - Format the summary as a markdown document without extra comments like \"Here is the summary of the transcript:\".\n - Use markdown formatting for headings and bullet points.\n - Format the summary as a list of key points and takeaways.\n - All names of people should be in bold.\n\n # Note Taking\n - Correlate items in the summary with the person of origin to build a coherent narrative.\n - Include short quotes verbatim where appropriate. Especially when concerned with design decisions and problem descriptions.\n\n # Tasks\n At the end of the summary include tasks.\n Extract only the tasks that are:\n - Directly actionable.\n - Clearly assigned to a person or team (or can easily be inferred).\n - Strongly implied by the conversation and/or user note (no speculative tasks).\n - Specific enough that someone reading them would know exactly what to do next.\n\n Format all tasks as markdown checkboxes using the syntax:\n - [ ] Task description.\n\n Additional information can be included (indented).\n\n If no actionable tasks are found, omit this tasks section.\n`;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["Capabilities", "contributes", "Blueprint", "Template", "trim", "Effect", "Schema", "ArtifactId", "Obj", "DatabaseService", "QueueService", "defineFunction", "DataType", "defineFunction", "key", "name", "description", "inputSchema", "Struct", "id", "ArtifactId", "annotations", "outputSchema", "content", "String", "handler", "fn", "data", "transcript", "DatabaseService", "resolve", "toDXN", "Transcript", "dxn", "promise", "queue", "load", "QueueService", "getQueue", "queryObjects", "objects", "filter", "message", "Obj", "instanceOf", "DataType", "Message", "flatMap", "index", "renderByline", "join", "Array", "Effect", "Function", "Layer", "Option", "Schema", "AiService", "ConsolePrinter", "ToolExecutionService", "ToolResolverService", "AiSession", "GenerationObserver", "TracingService", "defineFunction", "trim", "defineFunction", "key", "name", "description", "inputSchema", "Struct", "transcript", "String", "annotations", "notes", "optional", "outputSchema", "summary", "handler", "fnUntraced", "data", "result", "AiSession", "run", "prompt", "history", "system", "systemPrompt", "observer", "GenerationObserver", "fromPrinter", "ConsolePrinter", "tag", "pipe", "findLast", "msg", "sender", "role", "blocks", "some", "block", "_tag", "flatMap", "map", "text", "getOrThrowWith", "Error", "provide", "mergeAll", "AiService", "model", "ToolResolverService", "layerEmpty", "ToolExecutionService", "TracingService", "layerNoop", "trim", "functions", "open", "summarize", "contributes", "Capabilities", "Functions", "BlueprintDefinition", "Blueprint", "make", "key", "name", "tools", "toolDefinitions", "instructions", "Template", "source", "trim"]
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
TRANSCRIPTION_URL
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-FTTZ4YSX.mjs";
|
|
5
5
|
|
|
6
6
|
// src/transcriber/media-stream-recorder.ts
|
|
7
7
|
import { MediaRecorder, register } from "extendable-media-recorder";
|
|
@@ -10,6 +10,19 @@ import { synchronized } from "@dxos/async";
|
|
|
10
10
|
import { invariant } from "@dxos/invariant";
|
|
11
11
|
import { log } from "@dxos/log";
|
|
12
12
|
import { trace } from "@dxos/tracing";
|
|
13
|
+
function _define_property(obj, key, value) {
|
|
14
|
+
if (key in obj) {
|
|
15
|
+
Object.defineProperty(obj, key, {
|
|
16
|
+
value,
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
obj[key] = value;
|
|
23
|
+
}
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
13
26
|
function _ts_decorate(decorators, target, key, desc) {
|
|
14
27
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
28
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -23,12 +36,6 @@ var initializeExtendableMediaRecorder = async () => {
|
|
|
23
36
|
await register(await connect());
|
|
24
37
|
};
|
|
25
38
|
var MediaStreamRecorder = class {
|
|
26
|
-
constructor({ mediaStreamTrack, config }) {
|
|
27
|
-
this._mediaRecorder = void 0;
|
|
28
|
-
this._header = void 0;
|
|
29
|
-
this._mediaStreamTrack = mediaStreamTrack;
|
|
30
|
-
this._config = config;
|
|
31
|
-
}
|
|
32
39
|
get wavConfig() {
|
|
33
40
|
const settings = this._mediaStreamTrack.getSettings();
|
|
34
41
|
return {
|
|
@@ -44,7 +51,7 @@ var MediaStreamRecorder = class {
|
|
|
44
51
|
this._onChunk = onChunk;
|
|
45
52
|
}
|
|
46
53
|
async start() {
|
|
47
|
-
await (initializingPromise
|
|
54
|
+
await (initializingPromise ?? (initializingPromise = initializeExtendableMediaRecorder())).catch((err) => log.info("initializeExtendableMediaRecorder", {
|
|
48
55
|
err
|
|
49
56
|
}, {
|
|
50
57
|
F: __dxlog_file,
|
|
@@ -111,6 +118,15 @@ var MediaStreamRecorder = class {
|
|
|
111
118
|
data: wav.getSamples()
|
|
112
119
|
});
|
|
113
120
|
}
|
|
121
|
+
constructor({ mediaStreamTrack, config }) {
|
|
122
|
+
_define_property(this, "_mediaStreamTrack", void 0);
|
|
123
|
+
_define_property(this, "_config", void 0);
|
|
124
|
+
_define_property(this, "_mediaRecorder", void 0);
|
|
125
|
+
_define_property(this, "_header", void 0);
|
|
126
|
+
_define_property(this, "_onChunk", void 0);
|
|
127
|
+
this._mediaStreamTrack = mediaStreamTrack;
|
|
128
|
+
this._config = config;
|
|
129
|
+
}
|
|
114
130
|
};
|
|
115
131
|
_ts_decorate([
|
|
116
132
|
synchronized
|
|
@@ -138,6 +154,19 @@ var mergeFloat64Arrays = (arrays) => {
|
|
|
138
154
|
};
|
|
139
155
|
|
|
140
156
|
// src/transcriber/transcriber.ts
|
|
157
|
+
function _define_property2(obj, key, value) {
|
|
158
|
+
if (key in obj) {
|
|
159
|
+
Object.defineProperty(obj, key, {
|
|
160
|
+
value,
|
|
161
|
+
enumerable: true,
|
|
162
|
+
configurable: true,
|
|
163
|
+
writable: true
|
|
164
|
+
});
|
|
165
|
+
} else {
|
|
166
|
+
obj[key] = value;
|
|
167
|
+
}
|
|
168
|
+
return obj;
|
|
169
|
+
}
|
|
141
170
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
142
171
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
143
172
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -146,23 +175,10 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
146
175
|
}
|
|
147
176
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/transcriber/transcriber.ts";
|
|
148
177
|
var Transcriber = class extends Resource {
|
|
149
|
-
constructor({ config, recorder, onSegments }) {
|
|
150
|
-
super();
|
|
151
|
-
this._audioChunks = [];
|
|
152
|
-
this._lastUsedTimestamp = 0;
|
|
153
|
-
this._openTrigger = new Trigger({
|
|
154
|
-
autoReset: true
|
|
155
|
-
});
|
|
156
|
-
this._recording = false;
|
|
157
|
-
this._transcribeTask = void 0;
|
|
158
|
-
this._config = config;
|
|
159
|
-
this._recorder = recorder;
|
|
160
|
-
this._onSegments = onSegments;
|
|
161
|
-
}
|
|
162
178
|
async _open(ctx) {
|
|
163
179
|
log2.info("opening", void 0, {
|
|
164
180
|
F: __dxlog_file2,
|
|
165
|
-
L:
|
|
181
|
+
L: 102,
|
|
166
182
|
S: this,
|
|
167
183
|
C: (f, a) => f(...a)
|
|
168
184
|
});
|
|
@@ -174,7 +190,7 @@ var Transcriber = class extends Resource {
|
|
|
174
190
|
async _close() {
|
|
175
191
|
log2.info("closing", void 0, {
|
|
176
192
|
F: __dxlog_file2,
|
|
177
|
-
L:
|
|
193
|
+
L: 110,
|
|
178
194
|
S: this,
|
|
179
195
|
C: (f, a) => f(...a)
|
|
180
196
|
});
|
|
@@ -185,7 +201,7 @@ var Transcriber = class extends Resource {
|
|
|
185
201
|
startChunksRecording() {
|
|
186
202
|
log2.info("starting", void 0, {
|
|
187
203
|
F: __dxlog_file2,
|
|
188
|
-
L:
|
|
204
|
+
L: 117,
|
|
189
205
|
S: this,
|
|
190
206
|
C: (f, a) => f(...a)
|
|
191
207
|
});
|
|
@@ -202,7 +218,7 @@ var Transcriber = class extends Resource {
|
|
|
202
218
|
this._transcribeTask?.schedule();
|
|
203
219
|
log2.info("stopped", void 0, {
|
|
204
220
|
F: __dxlog_file2,
|
|
205
|
-
L:
|
|
221
|
+
L: 132,
|
|
206
222
|
S: this,
|
|
207
223
|
C: (f, a) => f(...a)
|
|
208
224
|
});
|
|
@@ -212,7 +228,7 @@ var Transcriber = class extends Resource {
|
|
|
212
228
|
chunk
|
|
213
229
|
}, {
|
|
214
230
|
F: __dxlog_file2,
|
|
215
|
-
L:
|
|
231
|
+
L: 136,
|
|
216
232
|
S: this,
|
|
217
233
|
C: (f, a) => f(...a)
|
|
218
234
|
});
|
|
@@ -228,7 +244,7 @@ var Transcriber = class extends Resource {
|
|
|
228
244
|
chunks: this._audioChunks.length
|
|
229
245
|
}, {
|
|
230
246
|
F: __dxlog_file2,
|
|
231
|
-
L:
|
|
247
|
+
L: 152,
|
|
232
248
|
S: this,
|
|
233
249
|
C: (f, a) => f(...a)
|
|
234
250
|
});
|
|
@@ -280,7 +296,7 @@ var Transcriber = class extends Resource {
|
|
|
280
296
|
string: segments.map((segments2) => segments2.text).join(" ")
|
|
281
297
|
}, {
|
|
282
298
|
F: __dxlog_file2,
|
|
283
|
-
L:
|
|
299
|
+
L: 216,
|
|
284
300
|
S: this,
|
|
285
301
|
C: (f, a) => f(...a)
|
|
286
302
|
});
|
|
@@ -307,6 +323,14 @@ var Transcriber = class extends Resource {
|
|
|
307
323
|
text: segment.text.trim()
|
|
308
324
|
}));
|
|
309
325
|
}
|
|
326
|
+
constructor({ config, recorder, onSegments }) {
|
|
327
|
+
super(), _define_property2(this, "_audioChunks", []), _define_property2(this, "_lastUsedTimestamp", 0), _define_property2(this, "_openTrigger", new Trigger({
|
|
328
|
+
autoReset: true
|
|
329
|
+
})), _define_property2(this, "_config", void 0), _define_property2(this, "_recorder", void 0), _define_property2(this, "_onSegments", void 0), _define_property2(this, "_recording", false), _define_property2(this, "_transcribeTask", void 0);
|
|
330
|
+
this._config = config;
|
|
331
|
+
this._recorder = recorder;
|
|
332
|
+
this._onSegments = onSegments;
|
|
333
|
+
}
|
|
310
334
|
};
|
|
311
335
|
_ts_decorate2([
|
|
312
336
|
trace2.span({
|
|
@@ -325,6 +349,19 @@ import { synchronized as synchronized2 } from "@dxos/async";
|
|
|
325
349
|
import { Resource as Resource2 } from "@dxos/context";
|
|
326
350
|
import { Obj } from "@dxos/echo";
|
|
327
351
|
import { DataType } from "@dxos/schema";
|
|
352
|
+
function _define_property3(obj, key, value) {
|
|
353
|
+
if (key in obj) {
|
|
354
|
+
Object.defineProperty(obj, key, {
|
|
355
|
+
value,
|
|
356
|
+
enumerable: true,
|
|
357
|
+
configurable: true,
|
|
358
|
+
writable: true
|
|
359
|
+
});
|
|
360
|
+
} else {
|
|
361
|
+
obj[key] = value;
|
|
362
|
+
}
|
|
363
|
+
return obj;
|
|
364
|
+
}
|
|
328
365
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
329
366
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
330
367
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -335,17 +372,6 @@ var RECORD_INTERVAL = 200;
|
|
|
335
372
|
var PREFIXED_CHUNKS_AMOUNT = 10;
|
|
336
373
|
var TRANSCRIBE_AFTER_CHUNKS_AMOUNT = 50;
|
|
337
374
|
var TranscriptionManager = class extends Resource2 {
|
|
338
|
-
constructor(options) {
|
|
339
|
-
super();
|
|
340
|
-
this._audioStreamTrack = void 0;
|
|
341
|
-
this._identityDid = void 0;
|
|
342
|
-
this._mediaRecorder = void 0;
|
|
343
|
-
this._transcriber = void 0;
|
|
344
|
-
this._queue = void 0;
|
|
345
|
-
this._enabled = signal(false);
|
|
346
|
-
this._edgeClient = options.edgeClient;
|
|
347
|
-
this._messageEnricher = options.messageEnricher;
|
|
348
|
-
}
|
|
349
375
|
/** @reactive */
|
|
350
376
|
get enabled() {
|
|
351
377
|
return this._enabled.value;
|
|
@@ -371,73 +397,32 @@ var TranscriptionManager = class extends Resource2 {
|
|
|
371
397
|
}
|
|
372
398
|
return this;
|
|
373
399
|
}
|
|
374
|
-
/**
|
|
375
|
-
* Enable or disable transcription.
|
|
376
|
-
* @param enabled - Whether to enable transcription.
|
|
377
|
-
*/
|
|
378
400
|
async setEnabled(enabled) {
|
|
379
401
|
if (this._enabled.value === enabled) {
|
|
380
402
|
return;
|
|
381
403
|
}
|
|
382
404
|
this._enabled.value = enabled ?? false;
|
|
383
|
-
|
|
405
|
+
if (enabled) {
|
|
406
|
+
await this._maybeRestartTranscriber();
|
|
407
|
+
} else {
|
|
408
|
+
await this._stopTranscriber();
|
|
409
|
+
}
|
|
384
410
|
}
|
|
385
411
|
async setAudioTrack(track) {
|
|
386
412
|
if (this._audioStreamTrack === track) {
|
|
387
413
|
return;
|
|
388
414
|
}
|
|
389
415
|
this._audioStreamTrack = track;
|
|
390
|
-
|
|
416
|
+
await this._maybeRestartTranscriber();
|
|
391
417
|
}
|
|
392
418
|
async _open() {
|
|
393
|
-
await this.
|
|
419
|
+
await this._maybeRestartTranscriber();
|
|
394
420
|
}
|
|
395
421
|
async _close() {
|
|
396
|
-
|
|
397
|
-
}
|
|
398
|
-
// TODO(burdon): Change this to setEnables (explicit), not toggle.
|
|
399
|
-
async _toggleTranscriber() {
|
|
400
|
-
await this._maybeReinitTranscriber();
|
|
401
|
-
if (this._enabled.value) {
|
|
402
|
-
await this._transcriber?.open();
|
|
403
|
-
const block = Obj.make(DataType.Message, {
|
|
404
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
405
|
-
blocks: [
|
|
406
|
-
{
|
|
407
|
-
_tag: "transcript",
|
|
408
|
-
text: "Started",
|
|
409
|
-
started: (/* @__PURE__ */ new Date()).toISOString()
|
|
410
|
-
}
|
|
411
|
-
],
|
|
412
|
-
sender: {
|
|
413
|
-
role: "assistant"
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
await this._queue?.append([
|
|
417
|
-
block
|
|
418
|
-
]);
|
|
419
|
-
} else {
|
|
420
|
-
await this._transcriber?.close();
|
|
421
|
-
const block = Obj.make(DataType.Message, {
|
|
422
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
423
|
-
blocks: [
|
|
424
|
-
{
|
|
425
|
-
_tag: "transcript",
|
|
426
|
-
text: "Stopped",
|
|
427
|
-
started: (/* @__PURE__ */ new Date()).toISOString()
|
|
428
|
-
}
|
|
429
|
-
],
|
|
430
|
-
sender: {
|
|
431
|
-
role: "assistant"
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
await this._queue?.append([
|
|
435
|
-
block
|
|
436
|
-
]);
|
|
437
|
-
}
|
|
422
|
+
await this._stopTranscriber();
|
|
438
423
|
}
|
|
439
|
-
async
|
|
440
|
-
if (!this._audioStreamTrack || !this._enabled.value) {
|
|
424
|
+
async _maybeRestartTranscriber() {
|
|
425
|
+
if (!this._audioStreamTrack || !this._enabled.value || !this.isOpen) {
|
|
441
426
|
return;
|
|
442
427
|
}
|
|
443
428
|
let needReinit = false;
|
|
@@ -460,8 +445,12 @@ var TranscriptionManager = class extends Resource2 {
|
|
|
460
445
|
recorder: this._mediaRecorder,
|
|
461
446
|
onSegments: (segments) => this._onSegments(segments)
|
|
462
447
|
});
|
|
448
|
+
await this._transcriber?.open();
|
|
463
449
|
}
|
|
464
450
|
}
|
|
451
|
+
async _stopTranscriber() {
|
|
452
|
+
await this._transcriber?.close();
|
|
453
|
+
}
|
|
465
454
|
async _onSegments(segments) {
|
|
466
455
|
if (!this.isOpen || !this._queue) {
|
|
467
456
|
return;
|
|
@@ -480,10 +469,12 @@ var TranscriptionManager = class extends Resource2 {
|
|
|
480
469
|
block
|
|
481
470
|
]);
|
|
482
471
|
}
|
|
472
|
+
constructor(options) {
|
|
473
|
+
super(), _define_property3(this, "_edgeClient", void 0), _define_property3(this, "_messageEnricher", void 0), _define_property3(this, "_audioStreamTrack", void 0), _define_property3(this, "_identityDid", void 0), _define_property3(this, "_mediaRecorder", void 0), _define_property3(this, "_transcriber", void 0), _define_property3(this, "_queue", void 0), _define_property3(this, "_enabled", signal(false));
|
|
474
|
+
this._edgeClient = options.edgeClient;
|
|
475
|
+
this._messageEnricher = options.messageEnricher;
|
|
476
|
+
}
|
|
483
477
|
};
|
|
484
|
-
_ts_decorate3([
|
|
485
|
-
synchronized2
|
|
486
|
-
], TranscriptionManager.prototype, "setEnabled", null);
|
|
487
478
|
_ts_decorate3([
|
|
488
479
|
synchronized2
|
|
489
480
|
], TranscriptionManager.prototype, "setAudioTrack", null);
|
|
@@ -493,4 +484,4 @@ export {
|
|
|
493
484
|
Transcriber,
|
|
494
485
|
TranscriptionManager
|
|
495
486
|
};
|
|
496
|
-
//# sourceMappingURL=chunk-
|
|
487
|
+
//# sourceMappingURL=chunk-A6SB234F.mjs.map
|