@dxos/plugin-transcription 0.8.4-main.7ace549 → 0.8.4-main.8baae0fced
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/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 +34 -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/neutral/blueprint-definition-HOXDG5QP.mjs +15 -0
- package/dist/lib/neutral/blueprint-definition-HOXDG5QP.mjs.map +7 -0
- package/dist/lib/neutral/blueprints/index.mjs +8 -0
- 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-5FXU36PN.mjs +120 -0
- package/dist/lib/neutral/chunk-5FXU36PN.mjs.map +7 -0
- package/dist/lib/{browser/chunk-7GNN7E3U.mjs → neutral/chunk-ILSA3DU7.mjs} +100 -131
- package/dist/lib/neutral/chunk-ILSA3DU7.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-KAEXRX3Y.mjs +35 -0
- package/dist/lib/neutral/chunk-KAEXRX3Y.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-Y5EQAFFR.mjs +8 -0
- package/dist/lib/neutral/chunk-Y5EQAFFR.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/{browser/chunk-VBUIO677.mjs → neutral/chunk-ZWOWQAFX.mjs} +3 -9
- package/dist/lib/neutral/chunk-ZWOWQAFX.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +272 -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-RRWRIUSR.mjs +21 -0
- package/dist/lib/neutral/create-RRWRIUSR.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/meta.mjs.map +7 -0
- package/dist/lib/neutral/open-CVMX5KXZ.mjs +27 -0
- package/dist/lib/neutral/open-CVMX5KXZ.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/operations/index.mjs.map +7 -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-LA7TRW7A.mjs +78 -0
- package/dist/lib/neutral/summarize-LA7TRW7A.mjs.map +7 -0
- package/dist/lib/neutral/text-content-F4ASMITB.mjs +30 -0
- package/dist/lib/neutral/text-content-F4ASMITB.mjs.map +7 -0
- package/dist/lib/{node-esm/transcriber-CPD3FZ7M.mjs → neutral/transcriber-ABHATBVH.mjs} +20 -18
- 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 +3 -1
- 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/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 -4
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +10 -5
- 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/text-content.d.ts +8 -0
- package/dist/types/src/capabilities/text-content.d.ts.map +1 -0
- 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/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 +13 -0
- package/dist/types/src/components/Transcription/Transcription.d.ts.map +1 -0
- package/dist/types/src/components/Transcription/Transcription.stories.d.ts +37 -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/{Transcript/transcript-extension.d.ts → Transcription/transcription-extension.d.ts} +3 -3
- package/dist/types/src/components/Transcription/transcription-extension.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -3
- 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 +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- 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 +2 -2
- 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 +8 -6
- package/dist/types/src/normalization/message-normalizer.d.ts.map +1 -0
- package/dist/types/src/normalization/normalization.d.ts +549 -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 +46 -0
- package/dist/types/src/stories/common.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +9 -10
- 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 +2 -2
- package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.d.ts +59 -4
- 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 -7
- 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 +927 -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 -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 +157 -84
- package/src/TranscriptionPlugin.node.ts +20 -0
- package/src/TranscriptionPlugin.test.ts +31 -0
- package/src/TranscriptionPlugin.tsx +20 -63
- package/src/TranscriptionPlugin.workerd.ts +18 -0
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/transcription-blueprint.ts +29 -0
- package/src/capabilities/blueprint-definition.ts +12 -24
- package/src/capabilities/index.ts +11 -7
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +22 -13
- package/src/capabilities/text-content.ts +33 -0
- package/src/capabilities/transcriber.ts +53 -42
- package/src/components/Oracle/Oracle.stories.tsx +147 -0
- package/src/components/Oracle/Oracle.tsx +141 -0
- package/src/components/Oracle/index.ts +5 -0
- package/src/components/Transcription/Transcription.stories.tsx +213 -0
- package/src/components/Transcription/Transcription.tsx +58 -0
- package/src/components/{Transcript → Transcription}/index.ts +1 -1
- package/src/components/{Transcript/transcript-extension.ts → Transcription/transcription-extension.ts} +4 -4
- package/src/components/index.ts +2 -6
- 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 +7 -0
- package/src/enrichment/conversation.test.ts +162 -0
- package/src/enrichment/conversation.txt +23 -0
- package/src/enrichment/operations.ts +268 -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 +6 -3
- package/src/hooks/useTranscriptionRecording.ts +87 -0
- package/src/hooks/useVoiceInput.ts +2 -3
- package/src/index.ts +4 -5
- package/src/meta.ts +4 -3
- package/src/model/model.test.ts +9 -3
- package/src/model/model.ts +3 -3
- package/src/{segments-normalization → normalization}/message-normalizer.ts +34 -21
- package/src/{segments-normalization → normalization}/normalization.test.ts +4 -43
- 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 +40 -40
- 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 +35 -47
- package/src/transcriber/index.ts +1 -1
- package/src/transcriber/media-stream-recorder.ts +3 -3
- package/src/transcriber/transcriber.browser.test.ts +1 -2
- package/src/transcriber/transcriber.test.ts +104 -0
- package/src/transcriber/transcriber.ts +102 -57
- package/src/transcriber/transcription-manager.ts +29 -18
- package/src/translations.ts +10 -7
- package/src/types/TranscriptOperation.ts +103 -0
- package/src/types/TranscriptionCapabilities.ts +39 -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-OQFBAGSP.mjs +0 -11
- package/dist/lib/browser/blueprint-definition-GZ7NOODS.mjs +0 -147
- package/dist/lib/browser/blueprint-definition-GZ7NOODS.mjs.map +0 -7
- package/dist/lib/browser/chunk-3MKZ2MNQ.mjs +0 -16
- package/dist/lib/browser/chunk-3MKZ2MNQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-7GNN7E3U.mjs.map +0 -7
- package/dist/lib/browser/chunk-C5YV3JZF.mjs +0 -738
- package/dist/lib/browser/chunk-C5YV3JZF.mjs.map +0 -7
- package/dist/lib/browser/chunk-O33THH53.mjs +0 -8
- package/dist/lib/browser/chunk-O33THH53.mjs.map +0 -7
- package/dist/lib/browser/chunk-QOSZIUE2.mjs +0 -32
- package/dist/lib/browser/chunk-QOSZIUE2.mjs.map +0 -7
- package/dist/lib/browser/chunk-VBUIO677.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -128
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-5CGCLOXB.mjs +0 -25
- package/dist/lib/browser/intent-resolver-5CGCLOXB.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-OK55WK7J.mjs +0 -32
- package/dist/lib/browser/react-surface-OK55WK7J.mjs.map +0 -7
- package/dist/lib/browser/transcriber-6YDM5ZDT.mjs +0 -56
- package/dist/lib/browser/transcriber-6YDM5ZDT.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -10
- package/dist/lib/node-esm/TranscriptContainer-GM47P6WH.mjs +0 -12
- package/dist/lib/node-esm/blueprint-definition-GAHQBYTF.mjs +0 -148
- package/dist/lib/node-esm/blueprint-definition-GAHQBYTF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5JN2MHYA.mjs +0 -467
- package/dist/lib/node-esm/chunk-5JN2MHYA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IKGUNN3Z.mjs +0 -739
- package/dist/lib/node-esm/chunk-IKGUNN3Z.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SSYFSLB7.mjs +0 -10
- package/dist/lib/node-esm/chunk-SSYFSLB7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SWUVPFKR.mjs +0 -17
- package/dist/lib/node-esm/chunk-SWUVPFKR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-U4YPUD2F.mjs +0 -33
- package/dist/lib/node-esm/chunk-U4YPUD2F.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YVNQN2J6.mjs +0 -30
- package/dist/lib/node-esm/chunk-YVNQN2J6.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -129
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-4H4CXIAL.mjs +0 -26
- package/dist/lib/node-esm/intent-resolver-4H4CXIAL.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-EK6K2MMD.mjs +0 -33
- package/dist/lib/node-esm/react-surface-EK6K2MMD.mjs.map +0 -7
- package/dist/lib/node-esm/transcriber-CPD3FZ7M.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -11
- 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 -19
- package/dist/types/src/components/Transcript/Transcript.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts +0 -39
- 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.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 -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/functions/index.d.ts +0 -3
- package/dist/types/src/functions/index.d.ts.map +0 -1
- package/dist/types/src/functions/open.d.ts +0 -7
- 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 -461
- 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 -23
- package/dist/types/src/types/TranscriptAction.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/capabilities.ts +0 -33
- package/src/capabilities/intent-resolver.ts +0 -19
- package/src/components/Transcript/Transcript.stories.tsx +0 -245
- package/src/components/Transcript/Transcript.tsx +0 -93
- package/src/components/Transcript/deprecated/OldTranscript.tsx +0 -260
- package/src/components/TranscriptContainer.tsx +0 -36
- package/src/components/stories/FileTranscription.stories.tsx +0 -257
- package/src/components/stories/MicrophoneTranscription.stories.tsx +0 -288
- package/src/components/stories/TranscriptionStory.tsx +0 -44
- package/src/components/stories/useIsSpeaking.tsx +0 -40
- package/src/functions/index.ts +0 -6
- package/src/functions/open.ts +0 -38
- 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 -23
- package/src/types/types.ts +0 -9
- package/dist/lib/{browser/types → neutral/blueprints}/index.mjs.map +0 -0
- package/dist/lib/{browser/TranscriptContainer-OQFBAGSP.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- package/dist/lib/{node-esm/types → neutral/hooks}/index.mjs.map +0 -0
- package/dist/lib/{node-esm/TranscriptContainer-GM47P6WH.mjs.map → neutral/index.mjs.map} +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
|
@@ -2,21 +2,14 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { effect } from '@preact/signals-core';
|
|
6
5
|
import { describe, test } from 'vitest';
|
|
7
6
|
|
|
8
|
-
import { scheduleTaskInterval } from '@dxos/async';
|
|
9
|
-
import { Context } from '@dxos/context';
|
|
10
7
|
import { Obj } from '@dxos/echo';
|
|
11
|
-
import { createQueueDXN } from '@dxos/echo/internal';
|
|
12
|
-
import { MemoryQueue } from '@dxos/echo-db';
|
|
13
8
|
import { FunctionExecutor, ServiceContainer } from '@dxos/functions-runtime';
|
|
14
9
|
import { log } from '@dxos/log';
|
|
15
10
|
import { type Actor, Message } from '@dxos/types';
|
|
16
11
|
|
|
17
|
-
import { MessageNormalizer } from './message-normalizer';
|
|
18
12
|
import { type MessageWithRangeId, sentenceNormalization } from './normalization';
|
|
19
|
-
import { getActorId } from './utils';
|
|
20
13
|
|
|
21
14
|
const sender: Actor.Actor = {
|
|
22
15
|
identityDid: 'did:key:123',
|
|
@@ -99,45 +92,13 @@ describe.skip('SentenceNormalization', () => {
|
|
|
99
92
|
}
|
|
100
93
|
|
|
101
94
|
log.info('sentences', {
|
|
102
|
-
|
|
95
|
+
messages: JSON.stringify(messages, null, 2),
|
|
103
96
|
sentences: JSON.stringify(sentences, null, 2),
|
|
104
97
|
});
|
|
105
98
|
throw new Error('test');
|
|
106
99
|
});
|
|
107
100
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const queue = new MemoryQueue<Message.Message>(createQueueDXN());
|
|
112
|
-
const ctx = new Context();
|
|
113
|
-
let idx = 0;
|
|
114
|
-
scheduleTaskInterval(
|
|
115
|
-
ctx,
|
|
116
|
-
async () => {
|
|
117
|
-
if (idx >= messages.length) {
|
|
118
|
-
void ctx.dispose();
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
await queue.append([messages[idx]]);
|
|
122
|
-
idx++;
|
|
123
|
-
},
|
|
124
|
-
2_000,
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
// Create normalizer.
|
|
128
|
-
const normalizer = new MessageNormalizer({
|
|
129
|
-
functionExecutor: getExecutor(),
|
|
130
|
-
queue,
|
|
131
|
-
startingCursor: { actorId: getActorId(sender), timestamp: '0' },
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
// Start normalizer.
|
|
135
|
-
await normalizer.open();
|
|
136
|
-
effect(() => {
|
|
137
|
-
log.info('normalizer');
|
|
138
|
-
log.info(JSON.stringify(queue.objects, null, 2));
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
await new Promise(() => {});
|
|
142
|
-
});
|
|
101
|
+
// TODO(burdon): Restore a Feed-based version once `MessageNormalizer` has a
|
|
102
|
+
// space-backed test fixture available; the previous `MemoryQueue`-based
|
|
103
|
+
// test was incompatible with the `Feed.Feed` + `FeedService` refactor.
|
|
143
104
|
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
7
|
+
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
9
|
+
import { log } from '@dxos/log';
|
|
10
|
+
import { trim } from '@dxos/util';
|
|
11
|
+
|
|
12
|
+
import { TranscriptOperation } from '../types';
|
|
13
|
+
|
|
14
|
+
type MessageWithRangeIdType = TranscriptOperation.MessageWithRangeIdType;
|
|
15
|
+
type SentenceNormalizationInputType = TranscriptOperation.SentenceNormalizationInputType;
|
|
16
|
+
const { SentenceNormalization, SentenceNormalizationOutput } = TranscriptOperation;
|
|
17
|
+
|
|
18
|
+
export type MessageWithRangeId = MessageWithRangeIdType;
|
|
19
|
+
|
|
20
|
+
/** @deprecated Use SentenceNormalizationInputType */
|
|
21
|
+
export type NormalizationInput = SentenceNormalizationInputType;
|
|
22
|
+
|
|
23
|
+
/** @deprecated Use SentenceNormalizationOutput */
|
|
24
|
+
export type NormalizationOutput = Schema.Schema.Type<typeof SentenceNormalizationOutput>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Sentence normalization for transcription.
|
|
28
|
+
* TODO(dmaretskyi): Reimplement using AiRequest.run or LanguageModel.generateObject - runStructured was removed.
|
|
29
|
+
*/
|
|
30
|
+
export const sentenceNormalization = SentenceNormalization.pipe(
|
|
31
|
+
Operation.withHandler(
|
|
32
|
+
Effect.fn(function* ({ messages }) {
|
|
33
|
+
log.info('input', { messages });
|
|
34
|
+
// TODO(dmaretskyi): runStructured was removed from AiRequest. Reimplement using new API.
|
|
35
|
+
return yield* Effect.die(
|
|
36
|
+
new Error(
|
|
37
|
+
'Sentence normalization needs to be reimplemented - runStructured was removed from AiRequest.Request. Use AiRequest.run or LanguageModel.generateObject.',
|
|
38
|
+
),
|
|
39
|
+
);
|
|
40
|
+
}),
|
|
41
|
+
),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const _unused = trim`
|
|
45
|
+
You are observing a real-time transcript of a single person speaking.
|
|
46
|
+
The transcription is delivered in chunks of 10 seconds or less. As a result, individual sentences may be split across multiple messages, or multiple sentences may appear within a single message. Additionally, because this is real-time transcription, punctuation and capitalization may be incorrect or missing.
|
|
47
|
+
|
|
48
|
+
# Task Description:
|
|
49
|
+
- Your task is to detect and reconstruct broken or incomplete sentences by merging segments into coherent, grammatically correct sentences where appropriate.
|
|
50
|
+
|
|
51
|
+
# Input Format:
|
|
52
|
+
- The input is an array of messages that contain transcription blocks.
|
|
53
|
+
- Each message is a Message.Message, as described in the output format.
|
|
54
|
+
|
|
55
|
+
# Output Format:
|
|
56
|
+
- You have been provided with the tool that defines the output format; make sure to query it.
|
|
57
|
+
- Do not output anything other than the expected format.
|
|
58
|
+
|
|
59
|
+
# Segment Handling Rules:
|
|
60
|
+
- Sort messages by timestamp.
|
|
61
|
+
- Leave ID of the first message in a sentence.
|
|
62
|
+
- Each divided sentence should be added to the output as a separate message or block within existing messages, preserving the original order.
|
|
63
|
+
- If one message contains multiple sentences, you should not split them.
|
|
64
|
+
- The last sentence may be incomplete; it should still be output as a separate block or message.
|
|
65
|
+
- Keep track of the original timestamps of the messages and blocks and, use the timestamp of the first message/block of a sentence as the 'started' field of the merged message.
|
|
66
|
+
- The 'rangeId' field of the merged message should include 'messageId'-s and 'rangeId'-s of all messages that have been used to construct this message.
|
|
67
|
+
|
|
68
|
+
# Punctuation and Capitalization:
|
|
69
|
+
- Do not rely on the original punctuation and capitalization—they may be incorrect.
|
|
70
|
+
- Use logical reasoning to apply appropriate punctuation (e.g., period, comma, question mark, exclamation mark) and capitalization.
|
|
71
|
+
|
|
72
|
+
# Restrictions:
|
|
73
|
+
- Do not alter the order of the original messages; maintain the natural flow of speech.
|
|
74
|
+
- Do not interpret or infer meaning beyond reconstructing sentences.
|
|
75
|
+
- Do not add or remove any words or phrases.
|
|
76
|
+
`;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Operation } from '@dxos/compute';
|
|
8
|
+
import { Feed, Ref } from '@dxos/echo';
|
|
9
|
+
import { Transcript } from '@dxos/types';
|
|
10
|
+
|
|
11
|
+
import { TranscriptOperation } from '../types';
|
|
12
|
+
|
|
13
|
+
const handler: Operation.WithHandler<typeof TranscriptOperation.Create> = TranscriptOperation.Create.pipe(
|
|
14
|
+
Operation.withHandler(
|
|
15
|
+
Effect.fn(function* ({ space }) {
|
|
16
|
+
const feed = space.db.add(Feed.make());
|
|
17
|
+
return {
|
|
18
|
+
object: Transcript.make(Ref.make(feed)),
|
|
19
|
+
};
|
|
20
|
+
}),
|
|
21
|
+
),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export default handler;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { OperationHandlerSet } from '@dxos/compute';
|
|
6
|
+
|
|
7
|
+
export const TranscriptionOperationHandlerSet = OperationHandlerSet.lazy(
|
|
8
|
+
() => import('./create'),
|
|
9
|
+
() => import('./open'),
|
|
10
|
+
() => import('./summarize'),
|
|
11
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Operation } from '@dxos/compute';
|
|
8
|
+
import { Database, Feed, Filter } from '@dxos/echo';
|
|
9
|
+
import { Message } from '@dxos/types';
|
|
10
|
+
|
|
11
|
+
import { TranscriptOperation } from '../types';
|
|
12
|
+
import { renderByline } from '../util';
|
|
13
|
+
|
|
14
|
+
const handler: Operation.WithHandler<typeof TranscriptOperation.Open> = TranscriptOperation.Open.pipe(
|
|
15
|
+
Operation.withHandler(
|
|
16
|
+
Effect.fn(function* ({ transcript }) {
|
|
17
|
+
const transcriptObj = yield* Database.load(transcript);
|
|
18
|
+
const feed = yield* Database.load(transcriptObj.feed);
|
|
19
|
+
const messages = yield* Feed.runQuery(feed, Filter.type(Message.Message));
|
|
20
|
+
const content = messages
|
|
21
|
+
.flatMap((message: Message.Message, index: number) => renderByline([])(message, index))
|
|
22
|
+
.join('\n\n');
|
|
23
|
+
return { content };
|
|
24
|
+
}),
|
|
25
|
+
),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export default handler;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Array from 'effect/Array';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import * as Function from 'effect/Function';
|
|
8
|
+
import * as Layer from 'effect/Layer';
|
|
9
|
+
import * as Option from 'effect/Option';
|
|
10
|
+
|
|
11
|
+
import { AiService, ConsolePrinter, ToolExecutionService, ToolResolverService } from '@dxos/ai';
|
|
12
|
+
import { AiRequest, GenerationObserver } from '@dxos/assistant';
|
|
13
|
+
import { Trace, Operation, OperationRegistry } from '@dxos/compute';
|
|
14
|
+
import { Database } from '@dxos/echo';
|
|
15
|
+
import { trim } from '@dxos/util';
|
|
16
|
+
|
|
17
|
+
import { TranscriptOperation } from '../types';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Summarize a transcript of a meeting.
|
|
21
|
+
*/
|
|
22
|
+
const handler: Operation.WithHandler<typeof TranscriptOperation.Summarize> = TranscriptOperation.Summarize.pipe(
|
|
23
|
+
Operation.withHandler(
|
|
24
|
+
Effect.fnUntraced(
|
|
25
|
+
function* ({ transcript, notes }) {
|
|
26
|
+
const result = yield* new AiRequest.Request({
|
|
27
|
+
observer: GenerationObserver.fromPrinter(new ConsolePrinter({ tag: 'summarize' })),
|
|
28
|
+
}).run({
|
|
29
|
+
prompt: `Transcript: ${transcript}\n\nNotes: ${notes}`,
|
|
30
|
+
history: [],
|
|
31
|
+
system: systemPrompt,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const summary = Function.pipe(
|
|
35
|
+
result,
|
|
36
|
+
Array.findLast((msg) => msg.sender.role === 'assistant' && msg.blocks.some((block) => block._tag === 'text')),
|
|
37
|
+
Option.flatMap((msg) =>
|
|
38
|
+
Function.pipe(
|
|
39
|
+
msg.blocks,
|
|
40
|
+
Array.findLast((block) => block._tag === 'text'),
|
|
41
|
+
Option.map((block) => block.text),
|
|
42
|
+
),
|
|
43
|
+
),
|
|
44
|
+
Option.getOrThrowWith(() => new Error('No summary found')),
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return { summary };
|
|
48
|
+
},
|
|
49
|
+
Effect.provide(
|
|
50
|
+
Layer.mergeAll(
|
|
51
|
+
AiService.model('@anthropic/claude-sonnet-4-0'),
|
|
52
|
+
ToolResolverService.layerEmpty,
|
|
53
|
+
ToolExecutionService.layerEmpty,
|
|
54
|
+
Trace.writerLayerNoop,
|
|
55
|
+
Database.notAvailable,
|
|
56
|
+
Layer.succeed(Operation.Service, {
|
|
57
|
+
invoke: () => Effect.die('Not available.'),
|
|
58
|
+
schedule: () => Effect.die('Not available.'),
|
|
59
|
+
invokePromise: async () => ({ error: new Error('Not available.') }),
|
|
60
|
+
} as any),
|
|
61
|
+
Layer.succeed(OperationRegistry.Service, { resolve: () => Effect.succeed(undefined) } as any),
|
|
62
|
+
),
|
|
63
|
+
),
|
|
64
|
+
),
|
|
65
|
+
),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
export default handler;
|
|
69
|
+
|
|
70
|
+
const systemPrompt = trim`
|
|
71
|
+
You are a helpful assistant that summarizes transcripts of meetings.
|
|
72
|
+
|
|
73
|
+
# Goal
|
|
74
|
+
Create a markdown summary of the meeting transcript with text notes provided.
|
|
75
|
+
Notes are very important so make sure to include them in the summary if they contain meaningful information.
|
|
76
|
+
|
|
77
|
+
# Formatting
|
|
78
|
+
- Format the summary as a markdown document without extra comments like "Here is the summary of the transcript:".
|
|
79
|
+
- Use markdown formatting for headings and bullet points.
|
|
80
|
+
- Format the summary as a list of key points and takeaways.
|
|
81
|
+
- All names of people should be in bold.
|
|
82
|
+
|
|
83
|
+
# Note Taking
|
|
84
|
+
- Correlate items in the summary with the person of origin to build a coherent narrative.
|
|
85
|
+
- Include short quotes verbatim where appropriate. Especially when concerned with design decisions and problem descriptions.
|
|
86
|
+
|
|
87
|
+
# Tasks
|
|
88
|
+
At the end of the summary include tasks.
|
|
89
|
+
Extract only the tasks that are:
|
|
90
|
+
- Directly actionable.
|
|
91
|
+
- Clearly assigned to a person or team (or can easily be inferred).
|
|
92
|
+
- Strongly implied by the conversation and/or user note (no speculative tasks).
|
|
93
|
+
- Specific enough that someone reading them would know exactly what to do next.
|
|
94
|
+
|
|
95
|
+
Format all tasks as markdown checkboxes using the syntax:
|
|
96
|
+
- [ ] Task description.
|
|
97
|
+
|
|
98
|
+
Additional information can be included (indented).
|
|
99
|
+
|
|
100
|
+
If no actionable tasks are found, omit this tasks section.
|
|
101
|
+
`;
|
package/src/plugin.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from './meta';
|
|
8
|
+
|
|
9
|
+
export const TranscriptionPlugin = Plugin.lazy(meta, () => import('#plugin'));
|
|
10
|
+
|
|
11
|
+
export { TranscriptionOperationHandlerSet } from './operations';
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { useAudioFile } from '#hooks';
|
|
9
|
+
|
|
10
|
+
import { type MediaStreamRecorderProps, type TranscriberProps } from '../transcriber';
|
|
11
|
+
import {
|
|
12
|
+
useIsSpeaking,
|
|
13
|
+
createStoryDecorators,
|
|
14
|
+
useStoryAppendSegments,
|
|
15
|
+
useStoryMessageModel,
|
|
16
|
+
useStoryTranscriber,
|
|
17
|
+
} from './common';
|
|
18
|
+
import { TranscriptionStory } from './TranscriptionStory';
|
|
19
|
+
|
|
20
|
+
const DEFAULT_TRANSCRIBER_CONFIG = {
|
|
21
|
+
transcribeAfterChunksAmount: 100,
|
|
22
|
+
prefixBufferChunksAmount: 50,
|
|
23
|
+
normalizeSentences: true,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const DEFAULT_RECORDER_CONFIG = {
|
|
27
|
+
interval: 200,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type DefaultStoryProps = {
|
|
31
|
+
detectSpeaking?: boolean;
|
|
32
|
+
normalizeSentences?: boolean;
|
|
33
|
+
audioUrl: string;
|
|
34
|
+
transcriberConfig?: TranscriberProps['config'];
|
|
35
|
+
recorderConfig?: MediaStreamRecorderProps['config'];
|
|
36
|
+
audioConstraints?: MediaTrackConstraints;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const DefaultStory = ({
|
|
40
|
+
detectSpeaking,
|
|
41
|
+
audioUrl,
|
|
42
|
+
normalizeSentences,
|
|
43
|
+
transcriberConfig = DEFAULT_TRANSCRIBER_CONFIG,
|
|
44
|
+
recorderConfig = DEFAULT_RECORDER_CONFIG,
|
|
45
|
+
audioConstraints,
|
|
46
|
+
}: DefaultStoryProps) => {
|
|
47
|
+
const [running, setRunning] = useState(false);
|
|
48
|
+
|
|
49
|
+
// Optional uploaded file overrides the default URL; revoke the previous URL on change/unmount.
|
|
50
|
+
const [uploadedUrl, setUploadedUrl] = useState<string>();
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
return () => {
|
|
53
|
+
if (uploadedUrl) {
|
|
54
|
+
URL.revokeObjectURL(uploadedUrl);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}, [uploadedUrl]);
|
|
58
|
+
|
|
59
|
+
const handleUpload = useCallback((file: File) => {
|
|
60
|
+
setRunning(false);
|
|
61
|
+
setUploadedUrl(URL.createObjectURL(file));
|
|
62
|
+
}, []);
|
|
63
|
+
|
|
64
|
+
const sourceUrl = uploadedUrl ?? audioUrl;
|
|
65
|
+
const { audio, track, stream } = useAudioFile(sourceUrl, audioConstraints);
|
|
66
|
+
const isSpeaking = detectSpeaking ? useIsSpeaking(track) : true;
|
|
67
|
+
|
|
68
|
+
// Pipe the decoded stream into the <audio> element so the user hears playback.
|
|
69
|
+
const ref = useRef<HTMLAudioElement>(null);
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (ref.current && stream) {
|
|
72
|
+
ref.current.srcObject = stream;
|
|
73
|
+
}
|
|
74
|
+
}, [stream]);
|
|
75
|
+
|
|
76
|
+
// Mirror the toolbar's running flag to the underlying HTMLAudioElement.
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (!audio) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (running) {
|
|
83
|
+
void audio.play();
|
|
84
|
+
} else {
|
|
85
|
+
void audio.pause();
|
|
86
|
+
}
|
|
87
|
+
}, [audio, running]);
|
|
88
|
+
|
|
89
|
+
const { model, appendMessage } = useStoryMessageModel();
|
|
90
|
+
const handleSegments = useStoryAppendSegments(appendMessage);
|
|
91
|
+
|
|
92
|
+
useStoryTranscriber({
|
|
93
|
+
audioStreamTrack: track,
|
|
94
|
+
running,
|
|
95
|
+
isSpeaking,
|
|
96
|
+
transcriberConfig,
|
|
97
|
+
recorderConfig,
|
|
98
|
+
onSegments: handleSegments,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// TODO(burdon): Sentence normalization moved to require a real space-backed Feed + FeedService runtime.
|
|
102
|
+
// Re-enable here once the story has access to one.
|
|
103
|
+
void normalizeSentences;
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<TranscriptionStory
|
|
107
|
+
audioRef={ref}
|
|
108
|
+
disabled={!stream}
|
|
109
|
+
model={model}
|
|
110
|
+
running={running}
|
|
111
|
+
onRunningChange={setRunning}
|
|
112
|
+
onUpload={handleUpload}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const meta = {
|
|
118
|
+
title: 'plugins/plugin-transcription/stories/FileTranscription',
|
|
119
|
+
render: DefaultStory,
|
|
120
|
+
decorators: createStoryDecorators(),
|
|
121
|
+
} satisfies Meta<DefaultStoryProps>;
|
|
122
|
+
|
|
123
|
+
export default meta;
|
|
124
|
+
|
|
125
|
+
type Story = StoryObj<typeof meta>;
|
|
126
|
+
|
|
127
|
+
export const Default: Story = {
|
|
128
|
+
args: {
|
|
129
|
+
detectSpeaking: true,
|
|
130
|
+
// https://learnenglish.britishcouncil.org/general-english/audio-zone/living-london
|
|
131
|
+
audioUrl: 'https://dxos.network/audio-london.m4a',
|
|
132
|
+
// textUrl: 'https://dxos.network/audio-london.txt',
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// TODO(mykola): Fix sentence normalization.
|
|
137
|
+
// export const WithSentenceNormalization: StoryObj<typeof AudioFile> = {
|
|
138
|
+
// args: {
|
|
139
|
+
// detectSpeaking: true,
|
|
140
|
+
// normalizeSentences: true,
|
|
141
|
+
// audioUrl: 'https://dxos.network/audio-london.m4a',
|
|
142
|
+
// },
|
|
143
|
+
// };
|
|
@@ -6,24 +6,23 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { log } from '@dxos/log';
|
|
9
|
-
import { Toolbar } from '@dxos/react-ui';
|
|
9
|
+
import { Panel, Toolbar } from '@dxos/react-ui';
|
|
10
10
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
|
-
import { mx } from '@dxos/
|
|
11
|
+
import { mx } from '@dxos/ui-theme';
|
|
12
12
|
|
|
13
13
|
type Word = {
|
|
14
14
|
text: string;
|
|
15
15
|
matched: boolean;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
type
|
|
18
|
+
type DefaultStoryProps = {
|
|
19
19
|
keywords: string[];
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const DefaultStory = ({ keywords }:
|
|
22
|
+
const DefaultStory = ({ keywords }: DefaultStoryProps) => {
|
|
23
23
|
const [running, setRunning] = useState(false);
|
|
24
24
|
const [matchingWords, setMatchingWords] = useState<Word[]>(keywords.map((word) => ({ text: word, matched: false })));
|
|
25
25
|
|
|
26
|
-
const [transcript, setTranscript] = useState('');
|
|
27
26
|
const recognition = useMemo(() => {
|
|
28
27
|
// TODO(mykola): Fix types
|
|
29
28
|
const SpeechRecognition = (window as any).SpeechRecognition || (window as any).webkitSpeechRecognition;
|
|
@@ -38,16 +37,16 @@ const DefaultStory = ({ keywords }: StoryProps) => {
|
|
|
38
37
|
recognition.interimResults = true;
|
|
39
38
|
recognition.lang = 'en-US';
|
|
40
39
|
recognition.maxAlternatives = 1;
|
|
41
|
-
// Add this line to enable punctuation
|
|
40
|
+
// Add this line to enable punctuation.
|
|
42
41
|
recognition.grammars = new SpeechGrammarList();
|
|
43
42
|
|
|
44
|
-
// TODO(mykola): Fix types
|
|
43
|
+
// TODO(mykola): Fix types.
|
|
45
44
|
recognition.onresult = (event: any) => {
|
|
46
45
|
log.info('recognition result', { event });
|
|
47
46
|
const current = event.resultIndex;
|
|
48
47
|
const transcript = event.results[current][0].transcript;
|
|
49
48
|
|
|
50
|
-
// Remove punctuation and normalize whitespace for comparison
|
|
49
|
+
// Remove punctuation and normalize whitespace for comparison.
|
|
51
50
|
const normalizeText = (text: string) =>
|
|
52
51
|
text
|
|
53
52
|
.toLowerCase()
|
|
@@ -57,7 +56,7 @@ const DefaultStory = ({ keywords }: StoryProps) => {
|
|
|
57
56
|
|
|
58
57
|
const normalizedTranscript = normalizeText(transcript);
|
|
59
58
|
|
|
60
|
-
// Check each keyword and update matching words
|
|
59
|
+
// Check each keyword and update matching words.
|
|
61
60
|
const updatedWords = matchingWords.map((word) => {
|
|
62
61
|
const normalizedKeyword = normalizeText(word.text);
|
|
63
62
|
const matched = normalizedTranscript.includes(normalizedKeyword);
|
|
@@ -65,10 +64,9 @@ const DefaultStory = ({ keywords }: StoryProps) => {
|
|
|
65
64
|
});
|
|
66
65
|
|
|
67
66
|
setMatchingWords(updatedWords);
|
|
68
|
-
setTranscript(transcript);
|
|
69
67
|
};
|
|
70
68
|
|
|
71
|
-
// TODO(mykola): Fix types
|
|
69
|
+
// TODO(mykola): Fix types.
|
|
72
70
|
recognition.onerror = (event: any) => {
|
|
73
71
|
log.error('Speech recognition error:', { error: event.error });
|
|
74
72
|
setRunning(false);
|
|
@@ -86,39 +84,41 @@ const DefaultStory = ({ keywords }: StoryProps) => {
|
|
|
86
84
|
}, [running, recognition]);
|
|
87
85
|
|
|
88
86
|
return (
|
|
89
|
-
<
|
|
90
|
-
<Toolbar
|
|
91
|
-
<Toolbar.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
87
|
+
<Panel.Root>
|
|
88
|
+
<Panel.Toolbar asChild>
|
|
89
|
+
<Toolbar.Root>
|
|
90
|
+
<Toolbar.IconButton
|
|
91
|
+
iconOnly
|
|
92
|
+
icon={running ? 'ph--pause--regular' : 'ph--play--regular'}
|
|
93
|
+
label={running ? 'Pause' : 'Play'}
|
|
94
|
+
onClick={() => setRunning((running) => !running)}
|
|
95
|
+
/>
|
|
96
|
+
</Toolbar.Root>
|
|
97
|
+
</Panel.Toolbar>
|
|
98
|
+
|
|
99
|
+
<Panel.Content>
|
|
100
|
+
<div className='p-2 grid grid-cols-[repeat(auto-fill,minmax(6rem,1fr))] gap-2'>
|
|
101
|
+
{matchingWords.map((word, index) => (
|
|
102
|
+
<span
|
|
103
|
+
key={index}
|
|
104
|
+
className={mx(
|
|
105
|
+
'grid place-items-center p-2 aspect-square rounded-sm border border-separator',
|
|
106
|
+
word.matched && 'border-red-300',
|
|
107
|
+
)}
|
|
108
|
+
>
|
|
109
|
+
{word.text}
|
|
110
|
+
</span>
|
|
111
|
+
))}
|
|
112
|
+
</div>
|
|
113
|
+
</Panel.Content>
|
|
114
|
+
</Panel.Root>
|
|
115
115
|
);
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
const meta = {
|
|
119
|
-
title: 'plugins/plugin-transcription/KeyWordDetection',
|
|
119
|
+
title: 'plugins/plugin-transcription/stories/KeyWordDetection',
|
|
120
120
|
render: DefaultStory,
|
|
121
|
-
decorators: [withTheme, withLayout({
|
|
121
|
+
decorators: [withTheme(), withLayout({ layout: 'column' })],
|
|
122
122
|
} satisfies Meta<typeof DefaultStory>;
|
|
123
123
|
|
|
124
124
|
export default meta;
|
|
@@ -127,6 +127,6 @@ type Story = StoryObj<typeof meta>;
|
|
|
127
127
|
|
|
128
128
|
export const SpeechRecognitionAPI: Story = {
|
|
129
129
|
args: {
|
|
130
|
-
keywords: ['kai', 'computer', 'hello'],
|
|
130
|
+
keywords: ['kai', 'computer', 'hello', 'dxos'],
|
|
131
131
|
},
|
|
132
132
|
};
|