@dxos/plugin-transcription 0.8.4-main.f9ba587 → 0.8.4-main.fcc0d83b33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/blueprints/index.mjs +31 -0
- package/dist/lib/browser/blueprints/index.mjs.map +7 -0
- package/dist/lib/browser/chunk-3L623EVL.mjs +17 -0
- package/dist/lib/browser/chunk-3L623EVL.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-KAEXRX3Y.mjs +35 -0
- package/dist/lib/browser/chunk-KAEXRX3Y.mjs.map +7 -0
- package/dist/lib/browser/chunk-L4HW35L6.mjs +111 -0
- package/dist/lib/browser/chunk-L4HW35L6.mjs.map +7 -0
- package/dist/lib/browser/create-ULR5DPJZ.mjs +21 -0
- package/dist/lib/browser/create-ULR5DPJZ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1085 -98
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/open-SFMPLZVW.mjs +27 -0
- package/dist/lib/browser/open-SFMPLZVW.mjs.map +7 -0
- package/dist/lib/browser/operations/index.mjs +13 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/summarize-I3POXUK3.mjs +79 -0
- package/dist/lib/browser/summarize-I3POXUK3.mjs.map +7 -0
- package/dist/lib/browser/translations.mjs +22 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -8
- package/dist/lib/node-esm/blueprints/index.mjs +32 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7UIZWCD4.mjs +112 -0
- package/dist/lib/node-esm/chunk-7UIZWCD4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-KO3IOD2O.mjs +19 -0
- package/dist/lib/node-esm/chunk-KO3IOD2O.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-O533NBMK.mjs +37 -0
- package/dist/lib/node-esm/chunk-O533NBMK.mjs.map +7 -0
- package/dist/lib/node-esm/create-A5QHNWRF.mjs +22 -0
- package/dist/lib/node-esm/create-A5QHNWRF.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1085 -98
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/open-OI24QNTO.mjs +28 -0
- package/dist/lib/node-esm/open-OI24QNTO.mjs.map +7 -0
- package/dist/lib/node-esm/operations/index.mjs +14 -0
- package/dist/lib/node-esm/operations/index.mjs.map +7 -0
- package/dist/lib/node-esm/summarize-F3LLJ45P.mjs +80 -0
- package/dist/lib/node-esm/summarize-F3LLJ45P.mjs.map +7 -0
- package/dist/lib/node-esm/translations.mjs +23 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +4 -8
- package/dist/types/src/TranscriptionPlugin.d.ts +2 -1
- package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/transcription-blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/transcription-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -4
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/transcriber.d.ts +4 -3
- package/dist/types/src/capabilities/transcriber.d.ts.map +1 -1
- package/dist/types/src/components/Transcription/Transcription.d.ts +18 -0
- package/dist/types/src/components/Transcription/Transcription.d.ts.map +1 -0
- package/dist/types/src/components/Transcription/Transcription.stories.d.ts +40 -0
- package/dist/types/src/components/Transcription/Transcription.stories.d.ts.map +1 -0
- package/dist/types/src/components/Transcription/index.d.ts +2 -0
- package/dist/types/src/components/Transcription/index.d.ts.map +1 -0
- package/dist/types/src/components/Transcription/transcription-extension.d.ts +15 -0
- package/dist/types/src/components/Transcription/transcription-extension.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts +6 -0
- package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts.map +1 -0
- package/dist/types/src/containers/TranscriptionContainer/index.d.ts +2 -0
- package/dist/types/src/containers/TranscriptionContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useAudioFile.d.ts.map +1 -1
- package/dist/types/src/hooks/useAudioTrack.d.ts.map +1 -1
- package/dist/types/src/hooks/useQueueModelAdapter.d.ts +1 -1
- package/dist/types/src/hooks/useQueueModelAdapter.d.ts.map +1 -1
- package/dist/types/src/hooks/useTranscriber.d.ts +2 -2
- package/dist/types/src/hooks/useTranscriber.d.ts.map +1 -1
- package/dist/types/src/hooks/useVoiceInput.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/model.d.ts +2 -2
- package/dist/types/src/model/model.d.ts.map +1 -1
- package/dist/types/src/{segments-normalization → normalization}/index.d.ts +1 -1
- package/dist/types/src/normalization/index.d.ts.map +1 -0
- package/dist/types/src/{segments-normalization → normalization}/message-normalizer.d.ts +5 -5
- package/dist/types/src/normalization/message-normalizer.d.ts.map +1 -0
- package/dist/types/src/normalization/normalization.d.ts +364 -0
- package/dist/types/src/normalization/normalization.d.ts.map +1 -0
- package/dist/types/src/normalization/normalization.test.d.ts.map +1 -0
- package/dist/types/src/normalization/utils.d.ts +3 -0
- package/dist/types/src/normalization/utils.d.ts.map +1 -0
- package/dist/types/src/operations/create.d.ts +5 -0
- package/dist/types/src/operations/create.d.ts.map +1 -0
- package/dist/types/src/operations/definitions.d.ts +917 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/open.d.ts +5 -0
- package/dist/types/src/operations/open.d.ts.map +1 -0
- package/dist/types/src/operations/summarize.d.ts +8 -0
- package/dist/types/src/operations/summarize.d.ts.map +1 -0
- package/dist/types/src/stories/FileTranscription.stories.d.ts +18 -0
- package/dist/types/src/stories/FileTranscription.stories.d.ts.map +1 -0
- package/dist/types/src/stories/KeyWordRecognition.stories.d.ts +14 -0
- package/dist/types/src/stories/KeyWordRecognition.stories.d.ts.map +1 -0
- package/dist/types/src/stories/MicrophoneTranscription.stories.d.ts +20 -0
- package/dist/types/src/stories/MicrophoneTranscription.stories.d.ts.map +1 -0
- package/dist/types/src/stories/TranscriptionStory.d.ts +23 -0
- package/dist/types/src/stories/TranscriptionStory.d.ts.map +1 -0
- package/dist/types/src/stories/useIsSpeaking.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +10 -10
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/transcriber/media-stream-recorder.d.ts +3 -3
- package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.d.ts +60 -5
- package/dist/types/src/transcriber/transcriber.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.test.d.ts +2 -0
- package/dist/types/src/transcriber/transcriber.test.d.ts.map +1 -0
- package/dist/types/src/transcriber/transcription-manager.d.ts +12 -13
- package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +7 -8
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +19 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/defs.d.ts +5 -0
- package/dist/types/src/types/defs.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/util/array.d.ts.map +1 -1
- package/dist/types/src/util/get-time-str.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +1 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/monitor-audio-level.d.ts.map +1 -1
- package/dist/types/src/util/render-byline.d.ts +4 -0
- package/dist/types/src/util/render-byline.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +108 -80
- package/src/TranscriptionPlugin.tsx +47 -60
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/transcription-blueprint.ts +29 -0
- package/src/capabilities/blueprint-definition.ts +17 -0
- package/src/capabilities/index.ts +9 -6
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +23 -14
- package/src/capabilities/transcriber.ts +54 -42
- package/src/components/{Transcript/Transcript.stories.tsx → Transcription/Transcription.stories.tsx} +77 -72
- package/src/components/Transcription/Transcription.tsx +64 -0
- package/src/components/{Transcript → Transcription}/index.ts +1 -1
- package/src/components/{Transcript/transcript-extension.ts → Transcription/transcription-extension.ts} +15 -48
- package/src/components/index.ts +1 -6
- package/src/containers/TranscriptionContainer/TranscriptionContainer.tsx +35 -0
- package/src/containers/TranscriptionContainer/index.ts +5 -0
- package/src/containers/index.ts +7 -0
- package/src/hooks/useAudioFile.ts +49 -53
- package/src/hooks/useQueueModelAdapter.ts +1 -1
- package/src/hooks/useTranscriber.ts +12 -4
- package/src/hooks/useVoiceInput.ts +3 -3
- package/src/index.ts +1 -1
- package/src/meta.ts +9 -6
- package/src/model/model.test.ts +27 -21
- package/src/model/model.ts +3 -3
- package/src/{segments-normalization → normalization}/message-normalizer.ts +20 -19
- package/src/{segments-normalization → normalization}/normalization.test.ts +26 -33
- package/src/normalization/normalization.ts +77 -0
- package/src/{segments-normalization → normalization}/utils.ts +2 -2
- package/src/operations/create.ts +24 -0
- package/src/operations/definitions.ts +101 -0
- package/src/operations/index.ts +13 -0
- package/src/operations/open.ts +28 -0
- package/src/operations/summarize.ts +102 -0
- package/src/{components/stories → stories}/FileTranscription.stories.tsx +98 -71
- package/src/{components/stories → stories}/KeyWordRecognition.stories.tsx +46 -40
- package/src/{components/stories → stories}/MicrophoneTranscription.stories.tsx +84 -100
- package/src/stories/TranscriptionStory.tsx +93 -0
- package/src/testing/testing.ts +41 -41
- package/src/transcriber/media-stream-recorder.ts +4 -4
- package/src/transcriber/transcriber.browser.test.ts +5 -5
- package/src/transcriber/transcriber.test.ts +104 -0
- package/src/transcriber/transcriber.ts +101 -62
- package/src/transcriber/transcription-manager.ts +37 -52
- package/src/translations.ts +7 -7
- package/src/types/capabilities.ts +39 -0
- package/src/types/defs.ts +9 -0
- package/src/types/index.ts +2 -2
- package/src/util/index.ts +1 -0
- package/src/util/render-byline.ts +33 -0
- package/dist/lib/browser/TranscriptContainer-E5NBJPAY.mjs +0 -11
- package/dist/lib/browser/chunk-5WH45KBY.mjs +0 -19
- package/dist/lib/browser/chunk-5WH45KBY.mjs.map +0 -7
- package/dist/lib/browser/chunk-EQBICGOD.mjs +0 -8
- package/dist/lib/browser/chunk-EQBICGOD.mjs.map +0 -7
- package/dist/lib/browser/chunk-F2WY3YTD.mjs +0 -764
- package/dist/lib/browser/chunk-F2WY3YTD.mjs.map +0 -7
- package/dist/lib/browser/chunk-R7INNNUQ.mjs +0 -55
- package/dist/lib/browser/chunk-R7INNNUQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-U6QBOGTN.mjs +0 -16
- package/dist/lib/browser/chunk-U6QBOGTN.mjs.map +0 -7
- package/dist/lib/browser/chunk-VDKDOZRR.mjs +0 -495
- package/dist/lib/browser/chunk-VDKDOZRR.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-3O33MMP5.mjs +0 -30
- package/dist/lib/browser/intent-resolver-3O33MMP5.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FJTMNF3K.mjs +0 -34
- package/dist/lib/browser/react-surface-FJTMNF3K.mjs.map +0 -7
- package/dist/lib/browser/transcriber-YVOTUBKQ.mjs +0 -56
- package/dist/lib/browser/transcriber-YVOTUBKQ.mjs.map +0 -7
- package/dist/lib/node-esm/TranscriptContainer-UOS7JG72.mjs +0 -12
- package/dist/lib/node-esm/chunk-DN522SAP.mjs +0 -10
- package/dist/lib/node-esm/chunk-DN522SAP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSCG4XPR.mjs +0 -496
- package/dist/lib/node-esm/chunk-HSCG4XPR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Q3JKLPTW.mjs +0 -765
- package/dist/lib/node-esm/chunk-Q3JKLPTW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RHF2ALML.mjs +0 -17
- package/dist/lib/node-esm/chunk-RHF2ALML.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-U65ZWK3L.mjs +0 -56
- package/dist/lib/node-esm/chunk-U65ZWK3L.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XMUCZBP3.mjs +0 -21
- package/dist/lib/node-esm/chunk-XMUCZBP3.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-YMN5SXNC.mjs +0 -31
- package/dist/lib/node-esm/intent-resolver-YMN5SXNC.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-57TSIDR2.mjs +0 -35
- package/dist/lib/node-esm/react-surface-57TSIDR2.mjs.map +0 -7
- package/dist/lib/node-esm/transcriber-GPBV52ZR.mjs +0 -57
- package/dist/lib/node-esm/transcriber-GPBV52ZR.mjs.map +0 -7
- package/dist/types/src/capabilities/capabilities.d.ts +0 -17
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/Transcript.d.ts +0 -20
- package/dist/types/src/components/Transcript/Transcript.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts +0 -24
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts +0 -28
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/index.d.ts +0 -2
- package/dist/types/src/components/Transcript/index.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/transcript-extension.d.ts +0 -19
- package/dist/types/src/components/Transcript/transcript-extension.d.ts.map +0 -1
- package/dist/types/src/components/TranscriptContainer.d.ts +0 -9
- package/dist/types/src/components/TranscriptContainer.d.ts.map +0 -1
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts +0 -17
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +0 -1
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts +0 -10
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts.map +0 -1
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts +0 -19
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +0 -1
- package/dist/types/src/components/stories/TranscriptionStory.d.ts +0 -11
- package/dist/types/src/components/stories/TranscriptionStory.d.ts.map +0 -1
- package/dist/types/src/components/stories/useIsSpeaking.d.ts.map +0 -1
- package/dist/types/src/segments-normalization/index.d.ts.map +0 -1
- package/dist/types/src/segments-normalization/message-normalizer.d.ts.map +0 -1
- package/dist/types/src/segments-normalization/normalization.d.ts +0 -329
- package/dist/types/src/segments-normalization/normalization.d.ts.map +0 -1
- package/dist/types/src/segments-normalization/normalization.test.d.ts.map +0 -1
- package/dist/types/src/segments-normalization/utils.d.ts +0 -3
- package/dist/types/src/segments-normalization/utils.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -41
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -31
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/capabilities/capabilities.ts +0 -33
- package/src/capabilities/intent-resolver.ts +0 -24
- package/src/components/Transcript/Transcript.tsx +0 -100
- package/src/components/Transcript/deprecated/OldTranscript.tsx +0 -260
- package/src/components/TranscriptContainer.tsx +0 -35
- package/src/components/stories/TranscriptionStory.tsx +0 -41
- package/src/segments-normalization/normalization.ts +0 -106
- package/src/types/schema.ts +0 -41
- package/src/types/types.ts +0 -32
- package/dist/lib/browser/{TranscriptContainer-E5NBJPAY.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
- package/dist/lib/node-esm/{TranscriptContainer-UOS7JG72.mjs.map → chunk-HSLMI22Q.mjs.map} +0 -0
- package/dist/types/src/{segments-normalization → normalization}/normalization.test.d.ts +0 -0
- package/dist/types/src/{components/stories → stories}/useIsSpeaking.d.ts +0 -0
- package/src/{segments-normalization → normalization}/index.ts +1 -1
- /package/src/{components/stories → stories}/useIsSpeaking.tsx +0 -0
|
@@ -2,46 +2,42 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
8
7
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
9
8
|
|
|
10
|
-
import { EdgeAiServiceClient } from '@dxos/ai';
|
|
11
|
-
import { AI_SERVICE_ENDPOINT } from '@dxos/ai/testing';
|
|
12
|
-
import { Events, IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
|
|
13
9
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
|
+
import { AppActivationEvents } from '@dxos/app-toolkit';
|
|
14
11
|
import {
|
|
15
|
-
extractionAnthropicFn,
|
|
16
12
|
type ExtractionFunction,
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
extractionAnthropicFunction,
|
|
14
|
+
extractionNerFunction,
|
|
19
15
|
getNer,
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
processTranscriptMessage,
|
|
17
|
+
} from '@dxos/assistant/extraction';
|
|
18
|
+
import { Filter, type Obj } from '@dxos/echo';
|
|
22
19
|
import { MemoryQueue } from '@dxos/echo-db';
|
|
23
|
-
import { createQueueDXN } from '@dxos/echo
|
|
24
|
-
import { FunctionExecutor, ServiceContainer } from '@dxos/functions';
|
|
20
|
+
import { createQueueDXN } from '@dxos/echo/internal';
|
|
25
21
|
import { invariant } from '@dxos/invariant';
|
|
26
22
|
import { log } from '@dxos/log';
|
|
27
23
|
import { ClientPlugin } from '@dxos/plugin-client';
|
|
24
|
+
import { initializeIdentity } from '@dxos/plugin-client/testing';
|
|
28
25
|
import { PreviewPlugin } from '@dxos/plugin-preview';
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import { seedTestData, Testing } from '@dxos/schema/testing';
|
|
36
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
26
|
+
import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
|
|
27
|
+
import { IndexKind, useSpaces } from '@dxos/react-client/echo';
|
|
28
|
+
import { withLayout } from '@dxos/react-ui/testing';
|
|
29
|
+
import { TestSchema } from '@dxos/schema/testing';
|
|
30
|
+
import { Message, Organization, Person } from '@dxos/types';
|
|
31
|
+
import { seedTestData } from '@dxos/types/testing';
|
|
37
32
|
|
|
33
|
+
import { useAudioTrack, useQueueModelAdapter, useTranscriber } from '#hooks';
|
|
34
|
+
import { TestItem } from '#testing';
|
|
35
|
+
|
|
36
|
+
import { type MediaStreamRecorderProps, type TranscriberProps } from '../transcriber';
|
|
37
|
+
import { TranscriptionPlugin } from '../TranscriptionPlugin';
|
|
38
|
+
import { renderByline } from '../util';
|
|
38
39
|
import { TranscriptionStory } from './TranscriptionStory';
|
|
39
40
|
import { useIsSpeaking } from './useIsSpeaking';
|
|
40
|
-
import { TranscriptionPlugin } from '../../TranscriptionPlugin';
|
|
41
|
-
import { useAudioTrack, useQueueModelAdapter, useTranscriber } from '../../hooks';
|
|
42
|
-
import { TestItem } from '../../testing';
|
|
43
|
-
import { type MediaStreamRecorderParams, type TranscriberParams } from '../../transcriber';
|
|
44
|
-
import { renderMarkdown } from '../Transcript';
|
|
45
41
|
|
|
46
42
|
const TRANSCRIBER_CONFIG = {
|
|
47
43
|
transcribeAfterChunksAmount: 50,
|
|
@@ -52,10 +48,10 @@ const RECORDER_CONFIG = {
|
|
|
52
48
|
interval: 200,
|
|
53
49
|
};
|
|
54
50
|
|
|
55
|
-
type
|
|
51
|
+
type DefaultStoryProps = {
|
|
56
52
|
detectSpeaking?: boolean;
|
|
57
|
-
transcriberConfig:
|
|
58
|
-
recorderConfig:
|
|
53
|
+
transcriberConfig: TranscriberProps['config'];
|
|
54
|
+
recorderConfig: MediaStreamRecorderProps['config'];
|
|
59
55
|
audioConstraints?: MediaTrackConstraints;
|
|
60
56
|
entityExtraction: 'none' | 'ner' | 'llm';
|
|
61
57
|
};
|
|
@@ -66,7 +62,7 @@ const DefaultStory = ({
|
|
|
66
62
|
transcriberConfig,
|
|
67
63
|
recorderConfig,
|
|
68
64
|
audioConstraints,
|
|
69
|
-
}:
|
|
65
|
+
}: DefaultStoryProps) => {
|
|
70
66
|
const [running, setRunning] = useState(false);
|
|
71
67
|
|
|
72
68
|
// Audio.
|
|
@@ -78,9 +74,9 @@ const DefaultStory = ({
|
|
|
78
74
|
// Queue.
|
|
79
75
|
// TODO(dmaretskyi): Use space.queues.create() instead.
|
|
80
76
|
const queueDxn = useMemo(() => createQueueDXN(), []);
|
|
81
|
-
const queue = useMemo(() => new MemoryQueue<
|
|
82
|
-
const model = useQueueModelAdapter(
|
|
83
|
-
const space =
|
|
77
|
+
const queue = useMemo(() => new MemoryQueue<Message.Message>(queueDxn), [queueDxn]);
|
|
78
|
+
const model = useQueueModelAdapter(renderByline([]), queue);
|
|
79
|
+
const [space] = useSpaces();
|
|
84
80
|
|
|
85
81
|
useEffect(() => {
|
|
86
82
|
if (!space) {
|
|
@@ -89,49 +85,39 @@ const DefaultStory = ({
|
|
|
89
85
|
}, [space]);
|
|
90
86
|
|
|
91
87
|
// Entity extraction.
|
|
92
|
-
const { extractionFunction,
|
|
88
|
+
const { extractionFunction, objects } = useMemo(() => {
|
|
93
89
|
if (!space) {
|
|
94
90
|
log.warn('no space');
|
|
95
91
|
return {};
|
|
96
92
|
}
|
|
97
93
|
|
|
98
|
-
let executor: FunctionExecutor | undefined;
|
|
99
94
|
let extractionFunction: ExtractionFunction | undefined;
|
|
100
|
-
let objects: Promise<
|
|
95
|
+
let objects: Promise<Obj.Unknown[]> | undefined;
|
|
101
96
|
|
|
102
97
|
if (entityExtraction === 'ner') {
|
|
103
98
|
// Init model loading. Takes time.
|
|
104
99
|
void getNer();
|
|
105
|
-
extractionFunction =
|
|
100
|
+
extractionFunction = extractionNerFunction;
|
|
106
101
|
} else if (entityExtraction === 'llm') {
|
|
107
|
-
extractionFunction =
|
|
102
|
+
extractionFunction = extractionAnthropicFunction;
|
|
108
103
|
objects = space.db
|
|
109
104
|
.query(
|
|
110
105
|
Filter.or(
|
|
111
|
-
Filter.type(
|
|
112
|
-
Filter.type(
|
|
113
|
-
Filter.type(
|
|
106
|
+
Filter.type(Person.Person),
|
|
107
|
+
Filter.type(Organization.Organization),
|
|
108
|
+
Filter.type(TestSchema.DocumentType),
|
|
114
109
|
),
|
|
115
110
|
)
|
|
116
|
-
.run()
|
|
117
|
-
.then((result) => result.objects);
|
|
118
|
-
}
|
|
119
|
-
if (entityExtraction !== 'none') {
|
|
120
|
-
const AiService = new EdgeAiServiceClient({
|
|
121
|
-
endpoint: AI_SERVICE_ENDPOINT.REMOTE,
|
|
122
|
-
});
|
|
123
|
-
executor = new FunctionExecutor(
|
|
124
|
-
new ServiceContainer().setServices({ ai: { client: AiService }, database: { db: space!.db } }),
|
|
125
|
-
);
|
|
111
|
+
.run();
|
|
126
112
|
}
|
|
127
113
|
|
|
128
|
-
return { extractionFunction,
|
|
114
|
+
return { extractionFunction, objects };
|
|
129
115
|
}, [entityExtraction, space]);
|
|
130
116
|
|
|
131
117
|
// Transcriber.
|
|
132
|
-
const handleSegments = useCallback<
|
|
118
|
+
const handleSegments = useCallback<TranscriberProps['onSegments']>(
|
|
133
119
|
async (blocks) => {
|
|
134
|
-
const message =
|
|
120
|
+
const message = Message.make({
|
|
135
121
|
sender: { name: 'You' },
|
|
136
122
|
created: new Date().toISOString(),
|
|
137
123
|
blocks,
|
|
@@ -143,9 +129,7 @@ const DefaultStory = ({
|
|
|
143
129
|
|
|
144
130
|
if (entityExtraction !== 'none') {
|
|
145
131
|
invariant(extractionFunction, 'extractionFunction is required');
|
|
146
|
-
invariant(executor, 'executor is required');
|
|
147
132
|
const result = await processTranscriptMessage({
|
|
148
|
-
executor,
|
|
149
133
|
function: extractionFunction,
|
|
150
134
|
input: {
|
|
151
135
|
message,
|
|
@@ -190,52 +174,50 @@ const DefaultStory = ({
|
|
|
190
174
|
return <TranscriptionStory model={model} running={running} onRunningChange={setRunning} />;
|
|
191
175
|
};
|
|
192
176
|
|
|
193
|
-
const meta
|
|
194
|
-
title: 'plugins/plugin-transcription/MicrophoneTranscription',
|
|
177
|
+
const meta = {
|
|
178
|
+
title: 'plugins/plugin-transcription/components/MicrophoneTranscription',
|
|
195
179
|
render: DefaultStory,
|
|
196
180
|
decorators: [
|
|
181
|
+
withLayout({ layout: 'column' }),
|
|
197
182
|
withPluginManager({
|
|
198
183
|
plugins: [
|
|
199
|
-
|
|
200
|
-
|
|
184
|
+
...corePlugins(),
|
|
185
|
+
StorybookPlugin({}),
|
|
201
186
|
ClientPlugin({
|
|
202
|
-
types: [TestItem,
|
|
203
|
-
onClientInitialized:
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
187
|
+
types: [TestItem, Person.Person, Organization.Organization, TestSchema.DocumentType],
|
|
188
|
+
onClientInitialized: ({ client }) =>
|
|
189
|
+
Effect.gen(function* () {
|
|
190
|
+
const { personalSpace } = yield* initializeIdentity(client);
|
|
191
|
+
// TODO(mykola): Make API easier to use.
|
|
192
|
+
// TODO(mykola): Delete after enabling vector indexing by default.
|
|
193
|
+
// Enable vector indexing.
|
|
194
|
+
yield* Effect.promise(() =>
|
|
195
|
+
client.services.services.QueryService!.setConfig({
|
|
196
|
+
enabled: true,
|
|
197
|
+
indexes: [
|
|
198
|
+
//
|
|
199
|
+
{ kind: IndexKind.Kind.SCHEMA_MATCH },
|
|
200
|
+
{ kind: IndexKind.Kind.GRAPH },
|
|
201
|
+
{ kind: IndexKind.Kind.VECTOR },
|
|
202
|
+
],
|
|
203
|
+
}),
|
|
204
|
+
);
|
|
205
|
+
yield* Effect.promise(() => client.services.services.QueryService!.reindex());
|
|
206
|
+
yield* Effect.promise(() => seedTestData(personalSpace));
|
|
207
|
+
}),
|
|
222
208
|
}),
|
|
223
|
-
|
|
224
|
-
SettingsPlugin(),
|
|
209
|
+
|
|
225
210
|
PreviewPlugin(),
|
|
226
|
-
IntentPlugin(),
|
|
227
211
|
TranscriptionPlugin(),
|
|
228
212
|
],
|
|
229
|
-
fireEvents: [
|
|
213
|
+
fireEvents: [AppActivationEvents.SetupAppGraph],
|
|
230
214
|
}),
|
|
231
|
-
withTheme,
|
|
232
|
-
withLayout({ fullscreen: true, classNames: 'justify-center' }),
|
|
233
215
|
],
|
|
234
|
-
}
|
|
216
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
235
217
|
|
|
236
218
|
export default meta;
|
|
237
219
|
|
|
238
|
-
type Story = StoryObj<typeof
|
|
220
|
+
type Story = StoryObj<typeof meta>;
|
|
239
221
|
|
|
240
222
|
export const Default: Story = {
|
|
241
223
|
args: {
|
|
@@ -251,19 +233,21 @@ export const Default: Story = {
|
|
|
251
233
|
},
|
|
252
234
|
};
|
|
253
235
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
236
|
+
// NOTE: We are running out of free quota on hugging face entity extraction.
|
|
237
|
+
// TODO(mykola): Fix hugging face quota issues.
|
|
238
|
+
// export const EntityExtraction: Story = {
|
|
239
|
+
// args: {
|
|
240
|
+
// detectSpeaking: true,
|
|
241
|
+
// entityExtraction: 'ner',
|
|
242
|
+
// transcriberConfig: TRANSCRIBER_CONFIG,
|
|
243
|
+
// recorderConfig: RECORDER_CONFIG,
|
|
244
|
+
// audioConstraints: {
|
|
245
|
+
// echoCancellation: true,
|
|
246
|
+
// noiseSuppression: true,
|
|
247
|
+
// autoGainControl: true,
|
|
248
|
+
// },
|
|
249
|
+
// },
|
|
250
|
+
// };
|
|
267
251
|
|
|
268
252
|
export const SpeechDetection: Story = {
|
|
269
253
|
args: {
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import React, {
|
|
8
|
+
type ChangeEvent,
|
|
9
|
+
type Dispatch,
|
|
10
|
+
type FC,
|
|
11
|
+
type ReactNode,
|
|
12
|
+
type RefObject,
|
|
13
|
+
type SetStateAction,
|
|
14
|
+
useRef,
|
|
15
|
+
} from 'react';
|
|
16
|
+
|
|
17
|
+
import { IconButton, ScrollContainer, Toolbar } from '@dxos/react-ui';
|
|
18
|
+
import { type Message } from '@dxos/types';
|
|
19
|
+
|
|
20
|
+
import { Transcription } from '../components';
|
|
21
|
+
import { type SerializationModel } from '../model';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Story wrapper that renders a transcript with playback controls, an optional audio file
|
|
25
|
+
* upload affordance, and a toolbar slot for additional controls.
|
|
26
|
+
*
|
|
27
|
+
* @param onUpload - Callback fired when the user picks a local audio file via the upload button.
|
|
28
|
+
* @param uploadAccept - HTML `accept` filter for the hidden file input. Defaults to `audio/*`.
|
|
29
|
+
* @param toolbarSlot - Extra content rendered after the upload button inside the toolbar.
|
|
30
|
+
*/
|
|
31
|
+
export const TranscriptionStory: FC<{
|
|
32
|
+
model: SerializationModel<Message.Message>;
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
running: boolean;
|
|
35
|
+
onRunningChange: Dispatch<SetStateAction<boolean>>;
|
|
36
|
+
audioRef?: RefObject<HTMLAudioElement | null>;
|
|
37
|
+
onUpload?: (file: File) => void;
|
|
38
|
+
uploadAccept?: string;
|
|
39
|
+
toolbarSlot?: ReactNode;
|
|
40
|
+
}> = ({ model, running, onRunningChange, audioRef, disabled, onUpload, uploadAccept = 'audio/*', toolbarSlot }) => {
|
|
41
|
+
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
42
|
+
|
|
43
|
+
const handleFileChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
44
|
+
const file = event.target.files?.[0];
|
|
45
|
+
if (file && onUpload) {
|
|
46
|
+
onUpload(file);
|
|
47
|
+
}
|
|
48
|
+
// Reset so the same file can be re-selected.
|
|
49
|
+
event.target.value = '';
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
{audioRef && <audio ref={audioRef} autoPlay />}
|
|
55
|
+
<Toolbar.Root>
|
|
56
|
+
<IconButton
|
|
57
|
+
iconOnly
|
|
58
|
+
disabled={disabled}
|
|
59
|
+
icon={running ? 'ph--pause--regular' : 'ph--play--regular'}
|
|
60
|
+
label={running ? 'Pause' : 'Play'}
|
|
61
|
+
onClick={() => onRunningChange((running) => !running)}
|
|
62
|
+
/>
|
|
63
|
+
{onUpload && (
|
|
64
|
+
<>
|
|
65
|
+
<input
|
|
66
|
+
ref={fileInputRef}
|
|
67
|
+
type='file'
|
|
68
|
+
accept={uploadAccept}
|
|
69
|
+
disabled={disabled}
|
|
70
|
+
className='hidden'
|
|
71
|
+
onChange={handleFileChange}
|
|
72
|
+
/>
|
|
73
|
+
<IconButton
|
|
74
|
+
iconOnly
|
|
75
|
+
disabled={disabled}
|
|
76
|
+
icon='ph--upload--regular'
|
|
77
|
+
label='Upload audio'
|
|
78
|
+
onClick={() => fileInputRef.current?.click()}
|
|
79
|
+
/>
|
|
80
|
+
</>
|
|
81
|
+
)}
|
|
82
|
+
{toolbarSlot}
|
|
83
|
+
</Toolbar.Root>
|
|
84
|
+
<ScrollContainer.Root pin>
|
|
85
|
+
<ScrollContainer.Content>
|
|
86
|
+
<ScrollContainer.Viewport>
|
|
87
|
+
<Transcription model={model} />
|
|
88
|
+
</ScrollContainer.Viewport>
|
|
89
|
+
</ScrollContainer.Content>
|
|
90
|
+
</ScrollContainer.Root>
|
|
91
|
+
</>
|
|
92
|
+
);
|
|
93
|
+
};
|
package/src/testing/testing.ts
CHANGED
|
@@ -2,24 +2,22 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import { useEffect, useMemo, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import { AI_SERVICE_ENDPOINT } from '@dxos/ai/testing';
|
|
10
|
-
import { extractionAnthropicFn, processTranscriptMessage } from '@dxos/assistant';
|
|
8
|
+
import { extractionAnthropicFunction, processTranscriptMessage } from '@dxos/assistant/extraction';
|
|
11
9
|
import { scheduleTaskInterval } from '@dxos/async';
|
|
12
10
|
import { Filter, type Queue } from '@dxos/client/echo';
|
|
13
11
|
import { Context } from '@dxos/context';
|
|
14
12
|
import { type Key, Obj, Ref, Type } from '@dxos/echo';
|
|
15
|
-
import { createQueueDXN } from '@dxos/echo
|
|
16
|
-
import { FunctionExecutor, ServiceContainer } from '@dxos/functions';
|
|
13
|
+
import { createQueueDXN } from '@dxos/echo/internal';
|
|
17
14
|
import { IdentityDid } from '@dxos/keys';
|
|
18
15
|
import { log } from '@dxos/log';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
16
|
+
import { random } from '@dxos/random';
|
|
17
|
+
import { type Space, useQueue } from '@dxos/react-client/echo';
|
|
18
|
+
import { TestSchema } from '@dxos/schema/testing';
|
|
19
|
+
import { type ContentBlock, Message, Organization, Person } from '@dxos/types';
|
|
20
|
+
import { seedTestData } from '@dxos/types/testing';
|
|
23
21
|
|
|
24
22
|
// TODO(burdon): Reconcile with plugin-markdown. Move to @dxos/schema/testing.
|
|
25
23
|
export const TestItem = Schema.Struct({
|
|
@@ -32,15 +30,15 @@ export const TestItem = Schema.Struct({
|
|
|
32
30
|
description: 'Product description',
|
|
33
31
|
}),
|
|
34
32
|
}).pipe(
|
|
35
|
-
Type.
|
|
36
|
-
typename: 'dxos.
|
|
33
|
+
Type.object({
|
|
34
|
+
typename: 'org.dxos.type.test',
|
|
37
35
|
version: '0.1.0',
|
|
38
36
|
}),
|
|
39
37
|
);
|
|
40
38
|
|
|
41
39
|
// TODO(wittjosiah): Make builder generic and reuse for all message types.
|
|
42
40
|
abstract class AbstractMessageBuilder {
|
|
43
|
-
abstract createMessage(numSegments?: number): Promise<
|
|
41
|
+
abstract createMessage(numSegments?: number): Promise<Message.Message>;
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
/**
|
|
@@ -51,8 +49,8 @@ export class MessageBuilder extends AbstractMessageBuilder {
|
|
|
51
49
|
|
|
52
50
|
users = Array.from({ length: 5 }, () => ({
|
|
53
51
|
identityDid: IdentityDid.random().toString(),
|
|
54
|
-
name:
|
|
55
|
-
email:
|
|
52
|
+
name: random.person.fullName(),
|
|
53
|
+
email: random.internet.email(),
|
|
56
54
|
}));
|
|
57
55
|
|
|
58
56
|
start = new Date(Date.now() - 24 * 60 * 60 * 10_000);
|
|
@@ -61,27 +59,32 @@ export class MessageBuilder extends AbstractMessageBuilder {
|
|
|
61
59
|
super();
|
|
62
60
|
}
|
|
63
61
|
|
|
64
|
-
override async createMessage(numSegments = 1): Promise<
|
|
65
|
-
return Obj.make(
|
|
62
|
+
override async createMessage(numSegments = 1): Promise<Message.Message> {
|
|
63
|
+
return Obj.make(Message.Message, {
|
|
66
64
|
created: this.next().toISOString(),
|
|
67
|
-
sender:
|
|
65
|
+
sender: random.helpers.arrayElement(this.users),
|
|
68
66
|
blocks: Array.from({ length: numSegments }).map(() => this.createBlock()),
|
|
69
67
|
});
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
createBlock():
|
|
73
|
-
let text =
|
|
70
|
+
createBlock(): ContentBlock.Transcript {
|
|
71
|
+
let text = random.lorem.paragraph();
|
|
74
72
|
if (this._space) {
|
|
75
|
-
const label =
|
|
76
|
-
const obj = this._space.db.add(
|
|
73
|
+
const label = random.commerce.productName();
|
|
74
|
+
const obj = this._space.db.add(
|
|
75
|
+
Obj.make(TestItem, {
|
|
76
|
+
title: label,
|
|
77
|
+
description: random.lorem.paragraph(),
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
77
80
|
const dxn = Ref.make(obj).dxn.toString();
|
|
78
81
|
const words = text.split(' ');
|
|
79
|
-
words.splice(Math.floor(Math.random() * words.length), 0, `[${label}]
|
|
82
|
+
words.splice(Math.floor(Math.random() * words.length), 0, `[${label}](${dxn})`);
|
|
80
83
|
text = words.join(' ');
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
return {
|
|
84
|
-
|
|
87
|
+
_tag: 'transcript',
|
|
85
88
|
started: this.next().toISOString(),
|
|
86
89
|
text,
|
|
87
90
|
};
|
|
@@ -95,15 +98,9 @@ export class MessageBuilder extends AbstractMessageBuilder {
|
|
|
95
98
|
|
|
96
99
|
// TODO(burdon): Reconcile with BlockBuilder.
|
|
97
100
|
class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
|
|
98
|
-
AiService = new EdgeAiServiceClient({
|
|
99
|
-
endpoint: AI_SERVICE_ENDPOINT.REMOTE,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
executor = new FunctionExecutor(new ServiceContainer().setServices({ ai: { client: this.AiService } }));
|
|
103
|
-
|
|
104
101
|
space: Space | undefined;
|
|
105
102
|
currentMessage: number = 0;
|
|
106
|
-
transcriptMessages:
|
|
103
|
+
transcriptMessages: Message.Message[] = [];
|
|
107
104
|
|
|
108
105
|
async connect(space: Space): Promise<void> {
|
|
109
106
|
this.space = space;
|
|
@@ -111,14 +108,18 @@ class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
|
|
|
111
108
|
this.transcriptMessages = transcriptMessages;
|
|
112
109
|
}
|
|
113
110
|
|
|
114
|
-
override async createMessage(): Promise<
|
|
111
|
+
override async createMessage(): Promise<Message.Message> {
|
|
115
112
|
if (!this.space) {
|
|
116
113
|
throw new Error('Space not connected');
|
|
117
114
|
}
|
|
118
115
|
|
|
119
|
-
const
|
|
116
|
+
const objects = await this.space.db
|
|
120
117
|
.query(
|
|
121
|
-
Filter.or(
|
|
118
|
+
Filter.or(
|
|
119
|
+
Filter.type(Person.Person),
|
|
120
|
+
Filter.type(Organization.Organization),
|
|
121
|
+
Filter.type(TestSchema.DocumentType),
|
|
122
|
+
),
|
|
122
123
|
)
|
|
123
124
|
.run();
|
|
124
125
|
|
|
@@ -129,8 +130,7 @@ class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
|
|
|
129
130
|
|
|
130
131
|
const { message: enhancedMessage } = await processTranscriptMessage({
|
|
131
132
|
input: { message },
|
|
132
|
-
|
|
133
|
-
function: extractionAnthropicFn,
|
|
133
|
+
function: extractionAnthropicFunction,
|
|
134
134
|
});
|
|
135
135
|
|
|
136
136
|
return enhancedMessage;
|
|
@@ -142,7 +142,7 @@ type UseTestTranscriptionQueue = (
|
|
|
142
142
|
queueId?: Key.ObjectId,
|
|
143
143
|
running?: boolean,
|
|
144
144
|
interval?: number,
|
|
145
|
-
) => Queue<
|
|
145
|
+
) => Queue<Message.Message> | undefined;
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
* Test transcriptionqueue.
|
|
@@ -155,7 +155,7 @@ export const useTestTranscriptionQueue: UseTestTranscriptionQueue = (
|
|
|
155
155
|
) => {
|
|
156
156
|
// TODO(dmaretskyi): Use space.queues.create() instead.
|
|
157
157
|
const queueDxn = useMemo(() => (space ? createQueueDXN(space.id, queueId) : undefined), [space, queueId]);
|
|
158
|
-
const queue = useQueue<
|
|
158
|
+
const queue = useQueue<Message.Message>(queueDxn);
|
|
159
159
|
const builder = useMemo(() => new MessageBuilder(space), [space]);
|
|
160
160
|
|
|
161
161
|
useEffect(() => {
|
|
@@ -165,7 +165,7 @@ export const useTestTranscriptionQueue: UseTestTranscriptionQueue = (
|
|
|
165
165
|
|
|
166
166
|
const i = setInterval(() => {
|
|
167
167
|
void builder.createMessage(Math.ceil(Math.random() * 3)).then(async (message) => {
|
|
168
|
-
await queue.append([Obj.make(
|
|
168
|
+
await queue.append([Obj.make(Message.Message, message)]);
|
|
169
169
|
});
|
|
170
170
|
}, interval);
|
|
171
171
|
return () => clearInterval(i);
|
|
@@ -186,7 +186,7 @@ export const useTestTranscriptionQueueWithEntityExtraction: UseTestTranscription
|
|
|
186
186
|
) => {
|
|
187
187
|
// TODO(dmaretskyi): Use space.queues.create() instead.
|
|
188
188
|
const queueDxn = useMemo(() => (space ? createQueueDXN(space.id, queueId) : undefined), [space, queueId]);
|
|
189
|
-
const queue = useQueue<
|
|
189
|
+
const queue = useQueue<Message.Message>(queueDxn);
|
|
190
190
|
const [builder] = useState(() => new EntityExtractionMessageBuilder());
|
|
191
191
|
|
|
192
192
|
useEffect(() => {
|
|
@@ -203,7 +203,7 @@ export const useTestTranscriptionQueueWithEntityExtraction: UseTestTranscription
|
|
|
203
203
|
ctx,
|
|
204
204
|
async () => {
|
|
205
205
|
const message = await builder.createMessage();
|
|
206
|
-
void queue.append([Obj.make(
|
|
206
|
+
void queue.append([Obj.make(Message.Message, message)]);
|
|
207
207
|
},
|
|
208
208
|
interval,
|
|
209
209
|
);
|
|
@@ -10,7 +10,7 @@ import { invariant } from '@dxos/invariant';
|
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
11
|
import { trace } from '@dxos/tracing';
|
|
12
12
|
|
|
13
|
-
import { type
|
|
13
|
+
import { type AudioChunk, type AudioRecorder, type WavConfig } from './audio-recorder';
|
|
14
14
|
|
|
15
15
|
let initializingPromise: Promise<void> | undefined;
|
|
16
16
|
|
|
@@ -19,7 +19,7 @@ const initializeExtendableMediaRecorder = async () => {
|
|
|
19
19
|
await register(await connect());
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export type
|
|
22
|
+
export type MediaStreamRecorderProps = {
|
|
23
23
|
mediaStreamTrack: MediaStreamTrack;
|
|
24
24
|
config: {
|
|
25
25
|
interval: number;
|
|
@@ -37,12 +37,12 @@ export class MediaStreamRecorder implements AudioRecorder {
|
|
|
37
37
|
/**
|
|
38
38
|
* Default MediaRecorder implementation do not support wav encoding.
|
|
39
39
|
*/
|
|
40
|
-
private readonly _config:
|
|
40
|
+
private readonly _config: MediaStreamRecorderProps['config'];
|
|
41
41
|
private _mediaRecorder?: IMediaRecorder = undefined;
|
|
42
42
|
private _header?: Uint8Array = undefined;
|
|
43
43
|
private _onChunk?: (chunk: AudioChunk) => void;
|
|
44
44
|
|
|
45
|
-
constructor({ mediaStreamTrack, config }:
|
|
45
|
+
constructor({ mediaStreamTrack, config }: MediaStreamRecorderProps) {
|
|
46
46
|
this._mediaStreamTrack = mediaStreamTrack;
|
|
47
47
|
this._config = config;
|
|
48
48
|
}
|
|
@@ -9,9 +9,9 @@ import { WaveFile } from 'wavefile';
|
|
|
9
9
|
|
|
10
10
|
import { Trigger } from '@dxos/async';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
|
-
import { type DataType } from '@dxos/schema';
|
|
13
12
|
import { openAndClose } from '@dxos/test-utils';
|
|
14
|
-
import {
|
|
13
|
+
import { TRACE_PROCESSOR, trace } from '@dxos/tracing';
|
|
14
|
+
import { type ContentBlock } from '@dxos/types';
|
|
15
15
|
|
|
16
16
|
import { type AudioChunk, type AudioRecorder, Transcriber } from '../transcriber';
|
|
17
17
|
import { mergeFloat64Arrays } from '../util';
|
|
@@ -93,7 +93,7 @@ describe.skip('Transcriber', () => {
|
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
test.skip('transcription of audio recording', { timeout: 10_000 }, async () => {
|
|
96
|
-
const trigger = new Trigger<
|
|
96
|
+
const trigger = new Trigger<ContentBlock.Transcript[]>({ autoReset: true });
|
|
97
97
|
const recorder = new MockAudioRecorder({
|
|
98
98
|
buffer: await readFile('test.wav'),
|
|
99
99
|
chunkDuration: 3_000,
|
|
@@ -127,7 +127,7 @@ describe.skip('Transcriber', () => {
|
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
test.skip('transcription of audio recording with overlapping chunks', { timeout: 20_000 }, async () => {
|
|
130
|
-
const trigger = new Trigger<
|
|
130
|
+
const trigger = new Trigger<ContentBlock.Transcript[]>({ autoReset: true });
|
|
131
131
|
const recorder = new MockAudioRecorder({
|
|
132
132
|
buffer: await readFile('test.wav'),
|
|
133
133
|
chunkDuration: 3_000,
|
|
@@ -212,7 +212,7 @@ class MockAudioRecorder implements AudioRecorder {
|
|
|
212
212
|
|
|
213
213
|
@trace.span()
|
|
214
214
|
async start(): Promise<void> {
|
|
215
|
-
log.info('start mock audio recorder', {
|
|
215
|
+
log.info('start mock audio recorder', { wavProps: this.wav.fmt });
|
|
216
216
|
const now = Date.now();
|
|
217
217
|
const samples = this.wav.getSamples();
|
|
218
218
|
const sampleRate = this.wavConfig.sampleRate;
|