@dxos/plugin-transcription 0.8.4-main.c85a9c8dae → 0.8.4-main.d9fc60f731
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/LICENSE +102 -5
- package/PLUGIN.mdl +401 -0
- package/README.md +1 -1
- package/dist/lib/neutral/TranscriptionArticle-L6XANBH5.mjs +54 -0
- package/dist/lib/neutral/TranscriptionArticle-L6XANBH5.mjs.map +7 -0
- package/dist/lib/neutral/TranscriptionPlugin.mjs +46 -0
- package/dist/lib/neutral/TranscriptionPlugin.mjs.map +7 -0
- package/dist/lib/neutral/TranscriptionPlugin.node.mjs +25 -0
- package/dist/lib/neutral/TranscriptionPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/TranscriptionPlugin.workerd.mjs +21 -0
- package/dist/lib/neutral/TranscriptionPlugin.workerd.mjs.map +7 -0
- package/dist/lib/{browser/blueprint-definition-C6XA2SVZ.mjs → neutral/blueprint-definition-HOXDG5QP.mjs} +4 -7
- package/dist/lib/neutral/blueprint-definition-HOXDG5QP.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/blueprints/index.mjs +1 -2
- package/dist/lib/neutral/capabilities/index.mjs +17 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-2O3ONPRZ.mjs +298 -0
- package/dist/lib/neutral/chunk-2O3ONPRZ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FHNI26QW.mjs +45 -0
- package/dist/lib/neutral/chunk-FHNI26QW.mjs.map +7 -0
- package/dist/lib/{browser/chunk-EV5ZYKET.mjs → neutral/chunk-ILSA3DU7.mjs} +87 -112
- package/dist/lib/neutral/chunk-ILSA3DU7.mjs.map +7 -0
- package/dist/lib/{browser/chunk-HOOPZ7EM.mjs → neutral/chunk-KAEXRX3Y.mjs} +1 -1
- package/dist/lib/neutral/chunk-KVUT2KYT.mjs +124 -0
- package/dist/lib/neutral/chunk-KVUT2KYT.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MLRJWAQH.mjs +179 -0
- package/dist/lib/neutral/chunk-MLRJWAQH.mjs.map +7 -0
- package/dist/lib/neutral/chunk-Y4YI44ZD.mjs +8 -0
- package/dist/lib/neutral/chunk-Y4YI44ZD.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZR4BH4QQ.mjs +30 -0
- package/dist/lib/neutral/chunk-ZR4BH4QQ.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +273 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +9 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-VWFMMAUY.mjs +21 -0
- package/dist/lib/neutral/create-VWFMMAUY.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +19 -0
- package/dist/lib/neutral/index.mjs +44 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/open-V772IQYW.mjs +27 -0
- package/dist/lib/neutral/open-V772IQYW.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-NXMOAXFP.mjs +13 -0
- package/dist/lib/neutral/operation-handler-NXMOAXFP.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-YMZRO242.mjs +26 -0
- package/dist/lib/neutral/react-surface-YMZRO242.mjs.map +7 -0
- package/dist/lib/neutral/summarize-6PDRGTKE.mjs +78 -0
- package/dist/lib/neutral/summarize-6PDRGTKE.mjs.map +7 -0
- package/dist/lib/neutral/text-content-KBB37HSM.mjs +30 -0
- package/dist/lib/neutral/text-content-KBB37HSM.mjs.map +7 -0
- package/dist/lib/{browser/transcriber-WCPHHJYY.mjs → neutral/transcriber-ABHATBVH.mjs} +8 -10
- package/dist/lib/neutral/transcriber-ABHATBVH.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +24 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +10 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/TranscriptionPlugin.d.ts +1 -0
- package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
- package/dist/types/src/TranscriptionPlugin.node.d.ts +4 -0
- package/dist/types/src/TranscriptionPlugin.node.d.ts.map +1 -0
- package/dist/types/src/TranscriptionPlugin.test.d.ts +2 -0
- package/dist/types/src/TranscriptionPlugin.test.d.ts.map +1 -0
- package/dist/types/src/TranscriptionPlugin.workerd.d.ts +4 -0
- package/dist/types/src/TranscriptionPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/blueprints/transcription-blueprint.d.ts +2 -2
- package/dist/types/src/blueprints/transcription-blueprint.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +10 -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.map +1 -0
- package/dist/types/src/capabilities/text-content.d.ts +8 -0
- package/dist/types/src/capabilities/text-content.d.ts.map +1 -0
- package/dist/types/src/capabilities/{transcriber/transcriber.d.ts → transcriber.d.ts} +1 -1
- package/dist/types/src/capabilities/transcriber.d.ts.map +1 -0
- package/dist/types/src/components/Oracle/Oracle.d.ts +24 -0
- package/dist/types/src/components/Oracle/Oracle.d.ts.map +1 -0
- package/dist/types/src/components/Oracle/Oracle.stories.d.ts +32 -0
- package/dist/types/src/components/Oracle/Oracle.stories.d.ts.map +1 -0
- package/dist/types/src/components/Oracle/index.d.ts +2 -0
- package/dist/types/src/components/Oracle/index.d.ts.map +1 -0
- package/dist/types/src/components/Transcription/Transcription.d.ts +5 -9
- package/dist/types/src/components/Transcription/Transcription.d.ts.map +1 -1
- package/dist/types/src/components/Transcription/Transcription.stories.d.ts +21 -24
- package/dist/types/src/components/Transcription/Transcription.stories.d.ts.map +1 -1
- package/dist/types/src/components/Transcription/transcription-extension.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/TranscriptionArticle/TranscriptionArticle.d.ts +6 -0
- package/dist/types/src/containers/TranscriptionArticle/TranscriptionArticle.d.ts.map +1 -0
- package/dist/types/src/containers/TranscriptionArticle/TranscriptionArticle.stories.d.ts +28 -0
- package/dist/types/src/containers/TranscriptionArticle/TranscriptionArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/TranscriptionArticle/index.d.ts +2 -0
- package/dist/types/src/containers/TranscriptionArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +1 -1
- package/dist/types/src/containers/index.d.ts.map +1 -1
- package/dist/types/src/enrichment/conversation.test.d.ts +2 -0
- package/dist/types/src/enrichment/conversation.test.d.ts.map +1 -0
- package/dist/types/src/enrichment/operations.d.ts +200 -0
- package/dist/types/src/enrichment/operations.d.ts.map +1 -0
- package/dist/types/src/enrichment/parser.d.ts +26 -0
- package/dist/types/src/enrichment/parser.d.ts.map +1 -0
- package/dist/types/src/enrichment/stream-simulator.d.ts +38 -0
- package/dist/types/src/enrichment/stream-simulator.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +2 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- 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/useFeedModelAdapter.d.ts +12 -0
- package/dist/types/src/hooks/useFeedModelAdapter.d.ts.map +1 -0
- 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/useTranscriptionRecording.d.ts +12 -0
- package/dist/types/src/hooks/useTranscriptionRecording.d.ts.map +1 -0
- package/dist/types/src/hooks/useVoiceInput.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -1
- 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 +7 -5
- package/dist/types/src/normalization/message-normalizer.d.ts.map +1 -0
- package/dist/types/src/normalization/normalization.d.ts +834 -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.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/index.d.ts +3 -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/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/stories/FileTranscription.stories.d.ts +20 -0
- package/dist/types/src/stories/FileTranscription.stories.d.ts.map +1 -0
- package/dist/types/src/{components/stories → stories}/KeyWordRecognition.stories.d.ts +2 -2
- package/dist/types/src/stories/KeyWordRecognition.stories.d.ts.map +1 -0
- package/dist/types/src/{components/stories/MicrophoneTranscription.stories.d.ts → stories/LiveTranscription.stories.d.ts} +7 -7
- package/dist/types/src/stories/LiveTranscription.stories.d.ts.map +1 -0
- package/dist/types/src/stories/TranscriptionStory.d.ts +21 -0
- package/dist/types/src/stories/TranscriptionStory.d.ts.map +1 -0
- package/dist/types/src/stories/common.d.ts +248 -0
- package/dist/types/src/stories/common.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +5 -6
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/transcriber/index.d.ts +1 -1
- package/dist/types/src/transcriber/index.d.ts.map +1 -1
- package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.d.ts +58 -3
- 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 +6 -4
- package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +9 -8
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/TranscriptOperation.d.ts +1670 -0
- package/dist/types/src/types/TranscriptOperation.d.ts.map +1 -0
- package/dist/types/src/types/TranscriptionCapabilities.d.ts +17 -0
- package/dist/types/src/types/TranscriptionCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -4
- 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/monitor-audio-level.d.ts.map +1 -1
- package/dist/types/src/util/render-byline.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +140 -86
- package/src/TranscriptionPlugin.node.ts +20 -0
- package/src/TranscriptionPlugin.test.ts +31 -0
- package/src/TranscriptionPlugin.tsx +14 -29
- package/src/TranscriptionPlugin.workerd.ts +18 -0
- package/src/blueprints/transcription-blueprint.ts +5 -9
- package/src/capabilities/{blueprint-definition/blueprint-definition.ts → blueprint-definition.ts} +3 -1
- package/src/capabilities/index.ts +12 -4
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +31 -0
- package/src/capabilities/text-content.ts +33 -0
- package/src/capabilities/{transcriber/transcriber.ts → transcriber.ts} +5 -2
- package/src/components/Oracle/Oracle.stories.tsx +147 -0
- package/src/components/Oracle/Oracle.tsx +142 -0
- package/src/components/Oracle/index.ts +5 -0
- package/src/components/Transcription/Transcription.stories.tsx +125 -158
- package/src/components/Transcription/Transcription.tsx +33 -38
- package/src/components/index.ts +1 -0
- package/src/containers/TranscriptionArticle/TranscriptionArticle.stories.tsx +61 -0
- package/src/containers/TranscriptionArticle/TranscriptionArticle.tsx +62 -0
- package/src/containers/TranscriptionArticle/index.ts +5 -0
- package/src/containers/index.ts +1 -1
- package/src/enrichment/conversation.test.ts +162 -0
- package/src/enrichment/conversation.txt +23 -0
- package/src/enrichment/operations.ts +271 -0
- package/src/enrichment/parser.ts +101 -0
- package/src/enrichment/stream-simulator.ts +125 -0
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useFeedModelAdapter.ts +46 -0
- package/src/hooks/useTranscriber.ts +5 -2
- package/src/hooks/useTranscriptionRecording.ts +87 -0
- package/src/hooks/useVoiceInput.ts +0 -1
- package/src/index.ts +4 -5
- package/src/meta.ts +28 -6
- package/src/model/model.test.ts +8 -8
- package/src/model/model.ts +3 -3
- package/src/{segments-normalization → normalization}/message-normalizer.ts +25 -17
- package/src/{segments-normalization → normalization}/normalization.test.ts +3 -37
- package/src/normalization/normalization.ts +76 -0
- package/src/operations/create.ts +24 -0
- package/src/operations/index.ts +11 -0
- package/src/operations/open.ts +28 -0
- package/src/operations/summarize.ts +101 -0
- package/src/plugin.ts +11 -0
- package/src/stories/FileTranscription.stories.tsx +143 -0
- package/src/{components/stories → stories}/KeyWordRecognition.stories.tsx +38 -38
- package/src/stories/LiveTranscription.stories.tsx +153 -0
- package/src/stories/TranscriptionStory.tsx +101 -0
- package/src/stories/common.ts +233 -0
- package/src/testing/testing.ts +29 -51
- package/src/transcriber/index.ts +1 -1
- package/src/transcriber/transcriber.browser.test.ts +0 -1
- package/src/transcriber/transcriber.test.ts +104 -0
- package/src/transcriber/transcriber.ts +100 -55
- package/src/transcriber/transcription-manager.ts +14 -9
- package/src/translations.ts +10 -7
- package/src/types/TranscriptOperation.ts +106 -0
- package/src/types/TranscriptionCapabilities.ts +39 -0
- package/src/types/index.ts +2 -4
- package/src/vite-env.d.ts +10 -0
- package/dist/lib/browser/TranscriptionContainer-RBFHP2AV.mjs +0 -41
- package/dist/lib/browser/TranscriptionContainer-RBFHP2AV.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-C6XA2SVZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-2B74LZZD.mjs +0 -22
- package/dist/lib/browser/chunk-2B74LZZD.mjs.map +0 -7
- package/dist/lib/browser/chunk-EV5ZYKET.mjs.map +0 -7
- package/dist/lib/browser/chunk-GH4IIQ6C.mjs +0 -54
- package/dist/lib/browser/chunk-GH4IIQ6C.mjs.map +0 -7
- package/dist/lib/browser/chunk-O7ILGNBZ.mjs +0 -148
- package/dist/lib/browser/chunk-O7ILGNBZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-XLMRCOQN.mjs +0 -668
- package/dist/lib/browser/chunk-XLMRCOQN.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -114
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/operation-resolver-5BLRH4XE.mjs +0 -23
- package/dist/lib/browser/operation-resolver-5BLRH4XE.mjs.map +0 -7
- package/dist/lib/browser/react-surface-U2SI74JK.mjs +0 -36
- package/dist/lib/browser/react-surface-U2SI74JK.mjs.map +0 -7
- package/dist/lib/browser/transcriber-WCPHHJYY.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -15
- package/dist/lib/node-esm/TranscriptionContainer-3OOID5KH.mjs +0 -42
- package/dist/lib/node-esm/TranscriptionContainer-3OOID5KH.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-TLXDUXIQ.mjs +0 -19
- package/dist/lib/node-esm/blueprint-definition-TLXDUXIQ.mjs.map +0 -7
- package/dist/lib/node-esm/blueprints/index.mjs +0 -10
- package/dist/lib/node-esm/chunk-6GW5NZYG.mjs +0 -55
- package/dist/lib/node-esm/chunk-6GW5NZYG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7UE7G6DE.mjs +0 -461
- package/dist/lib/node-esm/chunk-7UE7G6DE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DYUGYQCB.mjs +0 -669
- package/dist/lib/node-esm/chunk-DYUGYQCB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F47HK7GT.mjs +0 -24
- package/dist/lib/node-esm/chunk-F47HK7GT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-H3MXHMQL.mjs +0 -149
- package/dist/lib/node-esm/chunk-H3MXHMQL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-NVM2QUMX.mjs +0 -37
- package/dist/lib/node-esm/chunk-NVM2QUMX.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -115
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/operation-resolver-CVZB7BF4.mjs +0 -24
- package/dist/lib/node-esm/operation-resolver-CVZB7BF4.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-2ICJPBPX.mjs +0 -37
- package/dist/lib/node-esm/react-surface-2ICJPBPX.mjs.map +0 -7
- package/dist/lib/node-esm/transcriber-2RIHUEX4.mjs +0 -62
- package/dist/lib/node-esm/transcriber-2RIHUEX4.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -16
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +0 -6
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +0 -3
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-handler/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-handler/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts +0 -5
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/transcriber/index.d.ts +0 -3
- package/dist/types/src/capabilities/transcriber/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/transcriber/transcriber.d.ts.map +0 -1
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts +0 -18
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +0 -1
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts.map +0 -1
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +0 -1
- package/dist/types/src/components/stories/TranscriptionStory.d.ts +0 -12
- package/dist/types/src/components/stories/TranscriptionStory.d.ts.map +0 -1
- package/dist/types/src/components/stories/useIsSpeaking.d.ts +0 -3
- package/dist/types/src/components/stories/useIsSpeaking.d.ts.map +0 -1
- package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts +0 -6
- package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts.map +0 -1
- package/dist/types/src/containers/TranscriptionContainer/index.d.ts +0 -3
- package/dist/types/src/containers/TranscriptionContainer/index.d.ts.map +0 -1
- package/dist/types/src/functions/index.d.ts +0 -18
- package/dist/types/src/functions/index.d.ts.map +0 -1
- package/dist/types/src/functions/open.d.ts +0 -11
- package/dist/types/src/functions/open.d.ts.map +0 -1
- package/dist/types/src/functions/summarize.d.ts +0 -11
- package/dist/types/src/functions/summarize.d.ts.map +0 -1
- package/dist/types/src/hooks/useQueueModelAdapter.d.ts +0 -8
- package/dist/types/src/hooks/useQueueModelAdapter.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 -534
- 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.map +0 -1
- package/dist/types/src/types/TranscriptAction.d.ts +0 -25
- package/dist/types/src/types/TranscriptAction.d.ts.map +0 -1
- package/dist/types/src/types/capabilities.d.ts +0 -18
- package/dist/types/src/types/capabilities.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -5
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/capabilities/blueprint-definition/index.ts +0 -7
- package/src/capabilities/operation-handler/index.ts +0 -7
- package/src/capabilities/operation-handler/operation-handler.ts +0 -25
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -25
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -28
- package/src/capabilities/transcriber/index.ts +0 -7
- package/src/components/stories/FileTranscription.stories.tsx +0 -252
- package/src/components/stories/MicrophoneTranscription.stories.tsx +0 -282
- package/src/components/stories/TranscriptionStory.tsx +0 -41
- package/src/components/stories/useIsSpeaking.tsx +0 -40
- package/src/containers/TranscriptionContainer/TranscriptionContainer.tsx +0 -33
- package/src/containers/TranscriptionContainer/index.ts +0 -7
- package/src/functions/index.ts +0 -11
- package/src/functions/open.ts +0 -37
- package/src/functions/summarize.ts +0 -103
- package/src/hooks/useQueueModelAdapter.ts +0 -66
- package/src/segments-normalization/normalization.ts +0 -115
- package/src/types/TranscriptAction.ts +0 -32
- package/src/types/capabilities.ts +0 -33
- package/src/types/types.ts +0 -9
- package/dist/lib/{browser → neutral}/blueprints/index.mjs.map +0 -0
- package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
- package/dist/lib/{browser/chunk-HOOPZ7EM.mjs.map → neutral/chunk-KAEXRX3Y.mjs.map} +0 -0
- package/dist/lib/{browser/types → neutral/hooks}/index.mjs.map +0 -0
- package/dist/lib/{node-esm/blueprints → neutral}/index.mjs.map +0 -0
- package/dist/lib/{node-esm/chunk-HSLMI22Q.mjs.map → neutral/meta.mjs.map} +0 -0
- package/dist/lib/{node-esm/types → neutral/operations}/index.mjs.map +0 -0
- package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
- package/dist/types/src/{segments-normalization → normalization}/normalization.test.d.ts +0 -0
- package/dist/types/src/{segments-normalization → normalization}/utils.d.ts +0 -0
- package/src/{segments-normalization → normalization}/index.ts +1 -1
- /package/src/{segments-normalization → normalization}/utils.ts +0 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// Helpers shared between LiveTranscription / FileTranscription stories.
|
|
6
|
+
// Each "live" story differs only in its *audio source* (mic vs file); everything else —
|
|
7
|
+
// the local in-memory message buffer, the transcriber lifecycle, and the plugin-manager
|
|
8
|
+
// decorator stack — is identical and lives here.
|
|
9
|
+
|
|
10
|
+
import { type Decorator } from '@storybook/react-vite';
|
|
11
|
+
import * as Effect from 'effect/Effect';
|
|
12
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
13
|
+
|
|
14
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
15
|
+
import { AppActivationEvents } from '@dxos/app-toolkit';
|
|
16
|
+
import { scheduleTask } from '@dxos/async';
|
|
17
|
+
import { Context } from '@dxos/context';
|
|
18
|
+
import { Obj } from '@dxos/echo';
|
|
19
|
+
import { SpeakingMonitor } from '@dxos/plugin-calls';
|
|
20
|
+
import { ClientPlugin, initializeIdentity } from '@dxos/plugin-client/testing';
|
|
21
|
+
import { PreviewPlugin } from '@dxos/plugin-preview/testing';
|
|
22
|
+
import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
|
|
23
|
+
import { IndexKind } from '@dxos/react-client/echo';
|
|
24
|
+
import { withLayout } from '@dxos/react-ui/testing';
|
|
25
|
+
import { Message, Organization, Person } from '@dxos/types';
|
|
26
|
+
import { seedTestData } from '@dxos/types/testing';
|
|
27
|
+
|
|
28
|
+
import { useFeedModelAdapter, useTranscriber } from '#hooks';
|
|
29
|
+
import { TestItem } from '#testing';
|
|
30
|
+
import { type TranscriptionCapabilities } from '#types';
|
|
31
|
+
|
|
32
|
+
import { type Transcriber, type TranscriberProps } from '../transcriber';
|
|
33
|
+
import { TranscriptionPlugin } from '../TranscriptionPlugin';
|
|
34
|
+
import { renderByline } from '../util';
|
|
35
|
+
|
|
36
|
+
export const useIsSpeaking = (track?: MediaStreamTrack) => {
|
|
37
|
+
const [isSpeaking, setIsSpeaking] = useState(false);
|
|
38
|
+
const speakingMonitor = useMemo(() => {
|
|
39
|
+
if (!track) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return new SpeakingMonitor(track);
|
|
44
|
+
}, [track]);
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!speakingMonitor) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const ctx = new Context();
|
|
52
|
+
scheduleTask(ctx, async () => {
|
|
53
|
+
speakingMonitor.speakingChanged.on(ctx, () => setIsSpeaking(speakingMonitor.isSpeaking));
|
|
54
|
+
await speakingMonitor.open();
|
|
55
|
+
ctx.onDispose(() => speakingMonitor.close());
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return () => {
|
|
59
|
+
void ctx.dispose();
|
|
60
|
+
};
|
|
61
|
+
}, [speakingMonitor]);
|
|
62
|
+
|
|
63
|
+
return isSpeaking;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
//
|
|
67
|
+
// Message model.
|
|
68
|
+
//
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* In-memory message buffer + model adapter for storybook use (production wires up a real
|
|
72
|
+
* space-backed `Feed`). Returns the renderable `model` plus an `appendMessage` callback.
|
|
73
|
+
*/
|
|
74
|
+
export const useStoryMessageModel = () => {
|
|
75
|
+
const [messages, setMessages] = useState<Message.Message[]>([]);
|
|
76
|
+
const appendMessage = useCallback((message: Message.Message) => setMessages((prev) => [...prev, message]), []);
|
|
77
|
+
const model = useFeedModelAdapter(renderByline([]), messages);
|
|
78
|
+
return { model, appendMessage };
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Wraps blocks in a `Message.Message` with the given sender and appends it to the local buffer.
|
|
83
|
+
* Provided as a convenience for stories that don't need entity-extraction or custom enrichment.
|
|
84
|
+
*/
|
|
85
|
+
export const useStoryAppendSegments = (
|
|
86
|
+
appendMessage: (message: Message.Message) => void,
|
|
87
|
+
sender: Message.Message['sender'] = {},
|
|
88
|
+
): TranscriberProps['onSegments'] =>
|
|
89
|
+
useCallback<TranscriberProps['onSegments']>(
|
|
90
|
+
async (blocks) => {
|
|
91
|
+
appendMessage(
|
|
92
|
+
Obj.make(Message.Message, {
|
|
93
|
+
created: new Date().toISOString(),
|
|
94
|
+
sender,
|
|
95
|
+
blocks,
|
|
96
|
+
}),
|
|
97
|
+
);
|
|
98
|
+
},
|
|
99
|
+
[appendMessage, sender],
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
//
|
|
103
|
+
// Transcriber lifecycle.
|
|
104
|
+
//
|
|
105
|
+
|
|
106
|
+
export type UseStoryTranscriberOptions = Pick<
|
|
107
|
+
TranscriptionCapabilities.GetTranscriberProps,
|
|
108
|
+
'transcriberConfig' | 'recorderConfig' | 'onSegments'
|
|
109
|
+
> & {
|
|
110
|
+
audioStreamTrack?: MediaStreamTrack;
|
|
111
|
+
/** Whether the user has the toolbar toggle on. */
|
|
112
|
+
running: boolean;
|
|
113
|
+
/** Voice-activity flag — chunks recording only fires while `true`. */
|
|
114
|
+
isSpeaking: boolean;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Drives the transcriber's open/close + chunk-recording lifecycle off `running`,
|
|
119
|
+
* the open flag, and an `isSpeaking` voice-activity gate. Returns the transcriber instance
|
|
120
|
+
* (`undefined` until the capability resolves and an audio track is available).
|
|
121
|
+
*/
|
|
122
|
+
export const useStoryTranscriber = ({
|
|
123
|
+
audioStreamTrack,
|
|
124
|
+
running,
|
|
125
|
+
isSpeaking,
|
|
126
|
+
transcriberConfig,
|
|
127
|
+
recorderConfig,
|
|
128
|
+
onSegments,
|
|
129
|
+
}: UseStoryTranscriberOptions): Transcriber | undefined => {
|
|
130
|
+
const transcriber = useTranscriber({
|
|
131
|
+
audioStreamTrack,
|
|
132
|
+
onSegments,
|
|
133
|
+
transcriberConfig,
|
|
134
|
+
recorderConfig,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Open the transcriber when it becomes available; close on teardown.
|
|
138
|
+
// `tokenRef` is a per-effect identity so a late `close()` completion from a stale
|
|
139
|
+
// transcriber instance can't clobber `isOpen` after a newer instance has opened.
|
|
140
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
141
|
+
const tokenRef = useRef<symbol | null>(null);
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (!transcriber) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const token = Symbol();
|
|
147
|
+
tokenRef.current = token;
|
|
148
|
+
void transcriber.open().then(
|
|
149
|
+
() => tokenRef.current === token && setIsOpen(true),
|
|
150
|
+
() => tokenRef.current === token && setIsOpen(false),
|
|
151
|
+
);
|
|
152
|
+
return () => {
|
|
153
|
+
void transcriber.close().then(() => {
|
|
154
|
+
if (tokenRef.current === token) {
|
|
155
|
+
setIsOpen(false);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
}, [transcriber]);
|
|
160
|
+
|
|
161
|
+
// Start/stop chunk recording based on running + open + isSpeaking.
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
if (!transcriber || !isOpen) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (running && isSpeaking) {
|
|
167
|
+
transcriber.startChunksRecording();
|
|
168
|
+
} else {
|
|
169
|
+
transcriber.stopChunksRecording();
|
|
170
|
+
}
|
|
171
|
+
}, [transcriber, isOpen, running, isSpeaking]);
|
|
172
|
+
|
|
173
|
+
return transcriber;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
//
|
|
177
|
+
// Plugin manager decorator.
|
|
178
|
+
//
|
|
179
|
+
|
|
180
|
+
export type StoryDecoratorsOptions = {
|
|
181
|
+
/**
|
|
182
|
+
* Enable schema/graph/vector indexes after the client boots; needed for entity-extraction
|
|
183
|
+
* queries over seeded `Person` / `Organization` objects.
|
|
184
|
+
* @default false
|
|
185
|
+
*/
|
|
186
|
+
enableVectorIndex?: boolean;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Standard plugin-manager decorator for transcription stories: core plugins,
|
|
191
|
+
* `ClientPlugin` with `Person`/`Organization`/`TestItem` schemas + seeded test data, plus
|
|
192
|
+
* the `PreviewPlugin` and `TranscriptionPlugin`. Toggle `enableVectorIndex` for entity-extraction.
|
|
193
|
+
*/
|
|
194
|
+
export const createStoryDecorators = ({ enableVectorIndex = false }: StoryDecoratorsOptions = {}): Decorator[] => [
|
|
195
|
+
withLayout({ layout: 'column' }),
|
|
196
|
+
withPluginManager({
|
|
197
|
+
plugins: [
|
|
198
|
+
...corePlugins(),
|
|
199
|
+
StorybookPlugin({}),
|
|
200
|
+
ClientPlugin({
|
|
201
|
+
types: [TestItem, Person.Person, Organization.Organization],
|
|
202
|
+
onClientInitialized: ({ client }) =>
|
|
203
|
+
Effect.gen(function* () {
|
|
204
|
+
const { personalSpace } = yield* initializeIdentity(client);
|
|
205
|
+
if (enableVectorIndex) {
|
|
206
|
+
yield* enableQueryIndexes(client.services.services);
|
|
207
|
+
}
|
|
208
|
+
yield* Effect.promise(() => seedTestData(personalSpace));
|
|
209
|
+
}),
|
|
210
|
+
}),
|
|
211
|
+
PreviewPlugin(),
|
|
212
|
+
TranscriptionPlugin(),
|
|
213
|
+
],
|
|
214
|
+
fireEvents: [AppActivationEvents.SetupAppGraph],
|
|
215
|
+
}),
|
|
216
|
+
];
|
|
217
|
+
|
|
218
|
+
// TODO(mykola): Make API easier to use.
|
|
219
|
+
// TODO(mykola): Delete after enabling vector indexing by default.
|
|
220
|
+
const enableQueryIndexes = (services: { QueryService?: any }) =>
|
|
221
|
+
Effect.gen(function* () {
|
|
222
|
+
yield* Effect.promise(() =>
|
|
223
|
+
services.QueryService!.setConfig({
|
|
224
|
+
enabled: true,
|
|
225
|
+
indexes: [
|
|
226
|
+
{ kind: IndexKind.Kind.SCHEMA_MATCH },
|
|
227
|
+
{ kind: IndexKind.Kind.GRAPH },
|
|
228
|
+
{ kind: IndexKind.Kind.VECTOR },
|
|
229
|
+
],
|
|
230
|
+
}),
|
|
231
|
+
);
|
|
232
|
+
yield* Effect.promise(() => services.QueryService!.reindex());
|
|
233
|
+
});
|
package/src/testing/testing.ts
CHANGED
|
@@ -2,20 +2,19 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
5
6
|
import * as Schema from 'effect/Schema';
|
|
6
7
|
import { useEffect, useMemo, useState } from 'react';
|
|
7
8
|
|
|
8
9
|
import { extractionAnthropicFunction, processTranscriptMessage } from '@dxos/assistant/extraction';
|
|
9
10
|
import { scheduleTaskInterval } from '@dxos/async';
|
|
10
|
-
import {
|
|
11
|
+
import { createFeedServiceLayer, type Space } from '@dxos/client/echo';
|
|
11
12
|
import { Context } from '@dxos/context';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { FunctionExecutor, ServiceContainer } from '@dxos/functions-runtime';
|
|
13
|
+
import { DXN, Feed, Filter, Obj, Ref, Type } from '@dxos/echo';
|
|
14
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
15
15
|
import { IdentityDid } from '@dxos/keys';
|
|
16
16
|
import { log } from '@dxos/log';
|
|
17
|
-
import {
|
|
18
|
-
import { type Space, useQueue } from '@dxos/react-client/echo';
|
|
17
|
+
import { random } from '@dxos/random';
|
|
19
18
|
import { TestSchema } from '@dxos/schema/testing';
|
|
20
19
|
import { type ContentBlock, Message, Organization, Person } from '@dxos/types';
|
|
21
20
|
import { seedTestData } from '@dxos/types/testing';
|
|
@@ -30,12 +29,7 @@ export const TestItem = Schema.Struct({
|
|
|
30
29
|
title: 'Description',
|
|
31
30
|
description: 'Product description',
|
|
32
31
|
}),
|
|
33
|
-
}).pipe(
|
|
34
|
-
Type.object({
|
|
35
|
-
typename: 'dxos.org/type/Test',
|
|
36
|
-
version: '0.1.0',
|
|
37
|
-
}),
|
|
38
|
-
);
|
|
32
|
+
}).pipe(Type.makeObject(DXN.make('org.dxos.type.test', '0.1.0')));
|
|
39
33
|
|
|
40
34
|
// TODO(wittjosiah): Make builder generic and reuse for all message types.
|
|
41
35
|
abstract class AbstractMessageBuilder {
|
|
@@ -50,8 +44,8 @@ export class MessageBuilder extends AbstractMessageBuilder {
|
|
|
50
44
|
|
|
51
45
|
users = Array.from({ length: 5 }, () => ({
|
|
52
46
|
identityDid: IdentityDid.random().toString(),
|
|
53
|
-
name:
|
|
54
|
-
email:
|
|
47
|
+
name: random.person.fullName(),
|
|
48
|
+
email: random.internet.email(),
|
|
55
49
|
}));
|
|
56
50
|
|
|
57
51
|
start = new Date(Date.now() - 24 * 60 * 60 * 10_000);
|
|
@@ -63,22 +57,22 @@ export class MessageBuilder extends AbstractMessageBuilder {
|
|
|
63
57
|
override async createMessage(numSegments = 1): Promise<Message.Message> {
|
|
64
58
|
return Obj.make(Message.Message, {
|
|
65
59
|
created: this.next().toISOString(),
|
|
66
|
-
sender:
|
|
60
|
+
sender: random.helpers.arrayElement(this.users),
|
|
67
61
|
blocks: Array.from({ length: numSegments }).map(() => this.createBlock()),
|
|
68
62
|
});
|
|
69
63
|
}
|
|
70
64
|
|
|
71
65
|
createBlock(): ContentBlock.Transcript {
|
|
72
|
-
let text =
|
|
66
|
+
let text = random.lorem.paragraph();
|
|
73
67
|
if (this._space) {
|
|
74
|
-
const label =
|
|
68
|
+
const label = random.commerce.productName();
|
|
75
69
|
const obj = this._space.db.add(
|
|
76
70
|
Obj.make(TestItem, {
|
|
77
71
|
title: label,
|
|
78
|
-
description:
|
|
72
|
+
description: random.lorem.paragraph(),
|
|
79
73
|
}),
|
|
80
74
|
);
|
|
81
|
-
const dxn = Ref.make(obj).
|
|
75
|
+
const dxn = Ref.make(obj).uri;
|
|
82
76
|
const words = text.split(' ');
|
|
83
77
|
words.splice(Math.floor(Math.random() * words.length), 0, `[${label}](${dxn})`);
|
|
84
78
|
text = words.join(' ');
|
|
@@ -99,14 +93,6 @@ export class MessageBuilder extends AbstractMessageBuilder {
|
|
|
99
93
|
|
|
100
94
|
// TODO(burdon): Reconcile with BlockBuilder.
|
|
101
95
|
class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
|
|
102
|
-
executor = new FunctionExecutor(
|
|
103
|
-
new ServiceContainer().setServices({
|
|
104
|
-
// ai: {
|
|
105
|
-
// client: this.AiService,
|
|
106
|
-
// },
|
|
107
|
-
}),
|
|
108
|
-
);
|
|
109
|
-
|
|
110
96
|
space: Space | undefined;
|
|
111
97
|
currentMessage: number = 0;
|
|
112
98
|
transcriptMessages: Message.Message[] = [];
|
|
@@ -139,7 +125,6 @@ class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
|
|
|
139
125
|
|
|
140
126
|
const { message: enhancedMessage } = await processTranscriptMessage({
|
|
141
127
|
input: { message },
|
|
142
|
-
executor: this.executor,
|
|
143
128
|
function: extractionAnthropicFunction,
|
|
144
129
|
});
|
|
145
130
|
|
|
@@ -149,71 +134,64 @@ class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
|
|
|
149
134
|
|
|
150
135
|
type UseTestTranscriptionQueue = (
|
|
151
136
|
space: Space | undefined,
|
|
152
|
-
queueId?: Key.ObjectId,
|
|
153
137
|
running?: boolean,
|
|
154
138
|
interval?: number,
|
|
155
|
-
) =>
|
|
139
|
+
) => Feed.Feed | undefined;
|
|
156
140
|
|
|
157
141
|
/**
|
|
158
|
-
* Test
|
|
142
|
+
* Test transcription feed.
|
|
159
143
|
*/
|
|
160
144
|
export const useTestTranscriptionQueue: UseTestTranscriptionQueue = (
|
|
161
145
|
space: Space | undefined,
|
|
162
|
-
queueId?: Key.ObjectId,
|
|
163
146
|
running = true,
|
|
164
147
|
interval = 1_000,
|
|
165
148
|
) => {
|
|
166
|
-
|
|
167
|
-
const queueDxn = useMemo(() => (space ? createQueueDXN(space.id, queueId) : undefined), [space, queueId]);
|
|
168
|
-
const queue = useQueue<Message.Message>(queueDxn);
|
|
149
|
+
const feed = useMemo(() => (space ? space.db.add(Feed.make({ name: 'transcription' })) : undefined), [space]);
|
|
169
150
|
const builder = useMemo(() => new MessageBuilder(space), [space]);
|
|
170
151
|
|
|
171
152
|
useEffect(() => {
|
|
172
|
-
if (!
|
|
153
|
+
if (!space || !feed || !running) {
|
|
173
154
|
return;
|
|
174
155
|
}
|
|
156
|
+
const feedServiceLayer = createFeedServiceLayer(space.queues);
|
|
175
157
|
|
|
176
158
|
const i = setInterval(() => {
|
|
177
159
|
void builder.createMessage(Math.ceil(Math.random() * 3)).then(async (message) => {
|
|
178
|
-
await
|
|
160
|
+
await Feed.append(feed, [message]).pipe(Effect.provide(feedServiceLayer), runAndForwardErrors);
|
|
179
161
|
});
|
|
180
162
|
}, interval);
|
|
181
163
|
return () => clearInterval(i);
|
|
182
|
-
}, [
|
|
164
|
+
}, [space, feed, running, interval]);
|
|
183
165
|
|
|
184
|
-
return
|
|
166
|
+
return feed;
|
|
185
167
|
};
|
|
186
168
|
|
|
187
169
|
/**
|
|
188
|
-
* Test transcription
|
|
170
|
+
* Test transcription feed with entity extraction.
|
|
189
171
|
*/
|
|
190
172
|
// TODO(burdon): Reconcile with useTestTranscriptionQueue.
|
|
191
173
|
export const useTestTranscriptionQueueWithEntityExtraction: UseTestTranscriptionQueue = (
|
|
192
174
|
space: Space | undefined,
|
|
193
|
-
queueId?: Key.ObjectId,
|
|
194
175
|
running = true,
|
|
195
176
|
interval = 1_000,
|
|
196
177
|
) => {
|
|
197
|
-
|
|
198
|
-
const queueDxn = useMemo(() => (space ? createQueueDXN(space.id, queueId) : undefined), [space, queueId]);
|
|
199
|
-
const queue = useQueue<Message.Message>(queueDxn);
|
|
178
|
+
const feed = useMemo(() => (space ? space.db.add(Feed.make({ name: 'transcription' })) : undefined), [space]);
|
|
200
179
|
const [builder] = useState(() => new EntityExtractionMessageBuilder());
|
|
201
180
|
|
|
202
181
|
useEffect(() => {
|
|
203
|
-
if (!
|
|
182
|
+
if (!space || !feed || !running) {
|
|
204
183
|
return;
|
|
205
184
|
}
|
|
206
185
|
|
|
207
|
-
|
|
208
|
-
void builder.connect(space);
|
|
209
|
-
}
|
|
186
|
+
void builder.connect(space);
|
|
210
187
|
|
|
188
|
+
const feedServiceLayer = createFeedServiceLayer(space.queues);
|
|
211
189
|
const ctx = new Context();
|
|
212
190
|
scheduleTaskInterval(
|
|
213
191
|
ctx,
|
|
214
192
|
async () => {
|
|
215
193
|
const message = await builder.createMessage();
|
|
216
|
-
|
|
194
|
+
await Feed.append(feed, [message]).pipe(Effect.provide(feedServiceLayer), runAndForwardErrors);
|
|
217
195
|
},
|
|
218
196
|
interval,
|
|
219
197
|
);
|
|
@@ -221,7 +199,7 @@ export const useTestTranscriptionQueueWithEntityExtraction: UseTestTranscription
|
|
|
221
199
|
return () => {
|
|
222
200
|
void ctx.dispose();
|
|
223
201
|
};
|
|
224
|
-
}, [space,
|
|
202
|
+
}, [space, feed, running, interval]);
|
|
225
203
|
|
|
226
|
-
return
|
|
204
|
+
return feed;
|
|
227
205
|
};
|
package/src/transcriber/index.ts
CHANGED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { type AudioChunk } from './audio-recorder';
|
|
8
|
+
import { alignWhisperSegments, type WhisperSegment } from './transcriber';
|
|
9
|
+
|
|
10
|
+
const T0 = Date.parse('2026-01-01T00:00:00.000Z');
|
|
11
|
+
|
|
12
|
+
const chunk = (offsetMs = 0, samples = 16): AudioChunk => ({
|
|
13
|
+
timestamp: T0 + offsetMs,
|
|
14
|
+
data: new Float64Array(samples),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const segment = (overrides: Partial<WhisperSegment>): WhisperSegment => ({
|
|
18
|
+
text: '',
|
|
19
|
+
start: 0,
|
|
20
|
+
end: 0,
|
|
21
|
+
no_speech_prob: 0,
|
|
22
|
+
words: [],
|
|
23
|
+
...overrides,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('alignWhisperSegments', () => {
|
|
27
|
+
test('returns empty when no chunks were transcribed', ({ expect }) => {
|
|
28
|
+
const result = alignWhisperSegments(
|
|
29
|
+
[segment({ text: 'x', end: 1, words: [{ word: 'x', start: 0, end: 1 }] })],
|
|
30
|
+
[],
|
|
31
|
+
0,
|
|
32
|
+
);
|
|
33
|
+
expect(result.transcripts).toEqual([]);
|
|
34
|
+
expect(result.lastTimestamp).toBeUndefined();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('absolute-timestamps and deduplicates segments against lastTimestamp', ({ expect }) => {
|
|
38
|
+
const segments: WhisperSegment[] = [
|
|
39
|
+
segment({
|
|
40
|
+
text: 'hello world',
|
|
41
|
+
start: 0,
|
|
42
|
+
end: 1,
|
|
43
|
+
words: [
|
|
44
|
+
{ word: 'hello ', start: 0, end: 0.5 },
|
|
45
|
+
{ word: 'world', start: 0.5, end: 1 },
|
|
46
|
+
],
|
|
47
|
+
}),
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const first = alignWhisperSegments(segments, [chunk(0)], 0);
|
|
51
|
+
expect(first.transcripts).toHaveLength(1);
|
|
52
|
+
expect(first.transcripts[0]._tag).toBe('transcript');
|
|
53
|
+
expect(first.transcripts[0].text).toBe('hello world');
|
|
54
|
+
expect(new Date(first.transcripts[0].started).getTime()).toBe(T0);
|
|
55
|
+
expect(first.lastTimestamp).toBe(T0 + 1_000);
|
|
56
|
+
|
|
57
|
+
// Same segments, same chunk start: every word's absolute start is < lastTimestamp -> filtered out.
|
|
58
|
+
const second = alignWhisperSegments(segments, [chunk(0)], first.lastTimestamp!);
|
|
59
|
+
expect(second.transcripts).toEqual([]);
|
|
60
|
+
expect(second.lastTimestamp).toBeUndefined();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('keeps later words when earlier words fall before lastTimestamp', ({ expect }) => {
|
|
64
|
+
const segments: WhisperSegment[] = [
|
|
65
|
+
segment({
|
|
66
|
+
text: 'old new',
|
|
67
|
+
start: 0,
|
|
68
|
+
end: 2,
|
|
69
|
+
words: [
|
|
70
|
+
{ word: 'old ', start: 0, end: 1 },
|
|
71
|
+
{ word: 'new', start: 1.5, end: 2 },
|
|
72
|
+
],
|
|
73
|
+
}),
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
// First word starts at T0, second at T0+1500 — only the second survives a cursor at T0+1000.
|
|
77
|
+
const result = alignWhisperSegments(segments, [chunk(0)], T0 + 1_000);
|
|
78
|
+
expect(result.transcripts).toHaveLength(1);
|
|
79
|
+
expect(result.transcripts[0].text).toBe('new');
|
|
80
|
+
expect(new Date(result.transcripts[0].started).getTime()).toBe(T0 + 1_500);
|
|
81
|
+
expect(result.lastTimestamp).toBe(T0 + 2_000);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('drops segments that end before lastTimestamp', ({ expect }) => {
|
|
85
|
+
const segments: WhisperSegment[] = [
|
|
86
|
+
segment({
|
|
87
|
+
text: 'stale',
|
|
88
|
+
start: 0,
|
|
89
|
+
end: 0.5,
|
|
90
|
+
words: [{ word: 'stale', start: 0, end: 0.5 }],
|
|
91
|
+
}),
|
|
92
|
+
segment({
|
|
93
|
+
text: 'fresh',
|
|
94
|
+
start: 1,
|
|
95
|
+
end: 2,
|
|
96
|
+
words: [{ word: 'fresh', start: 1.5, end: 2 }],
|
|
97
|
+
}),
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
const result = alignWhisperSegments(segments, [chunk(0)], T0 + 1_000);
|
|
101
|
+
expect(result.transcripts).toHaveLength(1);
|
|
102
|
+
expect(result.transcripts[0].text).toBe('fresh');
|
|
103
|
+
});
|
|
104
|
+
});
|