@dxos/plugin-transcription 0.8.4-main.9735255 → 0.8.4-main.abd8ff62ef
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/blueprints/index.mjs +27 -5
- package/dist/lib/browser/blueprints/index.mjs.map +4 -4
- package/dist/lib/browser/chunk-3L623EVL.mjs +17 -0
- package/dist/lib/browser/chunk-3L623EVL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-HOOPZ7EM.mjs → chunk-KAEXRX3Y.mjs} +1 -1
- package/dist/lib/browser/chunk-L4HW35L6.mjs +111 -0
- package/dist/lib/browser/chunk-L4HW35L6.mjs.map +7 -0
- package/dist/lib/browser/chunk-MLRJWAQH.mjs +179 -0
- package/dist/lib/browser/chunk-MLRJWAQH.mjs.map +7 -0
- package/dist/lib/browser/chunk-NQQK7UZQ.mjs +244 -0
- package/dist/lib/browser/chunk-NQQK7UZQ.mjs.map +7 -0
- package/dist/lib/browser/components/index.mjs +207 -0
- package/dist/lib/browser/components/index.mjs.map +7 -0
- package/dist/lib/browser/create-ULR5DPJZ.mjs +21 -0
- package/dist/lib/browser/create-ULR5DPJZ.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +17 -0
- package/dist/lib/browser/index.mjs +439 -83
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/open-SFMPLZVW.mjs +27 -0
- package/dist/lib/browser/open-SFMPLZVW.mjs.map +7 -0
- package/dist/lib/browser/operations/index.mjs +13 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/summarize-BDFX4APN.mjs +78 -0
- package/dist/lib/browser/summarize-BDFX4APN.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -5
- package/dist/lib/node-esm/blueprints/index.mjs +27 -5
- package/dist/lib/node-esm/blueprints/index.mjs.map +4 -4
- package/dist/lib/node-esm/chunk-7UIZWCD4.mjs +112 -0
- package/dist/lib/node-esm/chunk-7UIZWCD4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-C3AE2NYJ.mjs +181 -0
- package/dist/lib/node-esm/chunk-C3AE2NYJ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KO3IOD2O.mjs +19 -0
- package/dist/lib/node-esm/chunk-KO3IOD2O.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MQK4R6GT.mjs +245 -0
- package/dist/lib/node-esm/chunk-MQK4R6GT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-NVM2QUMX.mjs → chunk-O533NBMK.mjs} +1 -1
- package/dist/lib/node-esm/components/index.mjs +208 -0
- package/dist/lib/node-esm/components/index.mjs.map +7 -0
- package/dist/lib/node-esm/create-A5QHNWRF.mjs +22 -0
- package/dist/lib/node-esm/create-A5QHNWRF.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +18 -0
- package/dist/lib/node-esm/index.mjs +439 -83
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/open-OI24QNTO.mjs +28 -0
- package/dist/lib/node-esm/open-OI24QNTO.mjs.map +7 -0
- package/dist/lib/node-esm/operations/index.mjs +14 -0
- package/dist/lib/node-esm/operations/index.mjs.map +7 -0
- package/dist/lib/node-esm/summarize-3UNN24I2.mjs +79 -0
- package/dist/lib/node-esm/summarize-3UNN24I2.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -5
- 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/blueprints/index.d.ts +1 -1
- package/dist/types/src/blueprints/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/transcription-blueprint.d.ts +3 -20
- 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 +6 -4
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/transcriber.d.ts +9 -0
- package/dist/types/src/capabilities/transcriber.d.ts.map +1 -0
- package/dist/types/src/components/{Transcript/Transcript.d.ts → Transcription/Transcription.d.ts} +6 -5
- package/dist/types/src/components/Transcription/Transcription.d.ts.map +1 -0
- package/dist/types/src/components/{Transcript/Transcript.stories.d.ts → Transcription/Transcription.stories.d.ts} +13 -13
- 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 +1 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts +6 -0
- package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts.map +1 -0
- package/dist/types/src/containers/TranscriptionContainer/index.d.ts +2 -0
- package/dist/types/src/containers/TranscriptionContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useAudioFile.d.ts.map +1 -1
- package/dist/types/src/hooks/useAudioTrack.d.ts.map +1 -1
- package/dist/types/src/hooks/useQueueModelAdapter.d.ts.map +1 -1
- package/dist/types/src/hooks/useTranscriber.d.ts +2 -2
- package/dist/types/src/hooks/useTranscriber.d.ts.map +1 -1
- package/dist/types/src/hooks/useVoiceInput.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -3
- package/dist/types/src/index.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/normalization/message-normalizer.d.ts.map +1 -0
- package/dist/types/src/{segments-normalization → normalization}/normalization.d.ts +182 -339
- 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/definitions.d.ts +917 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/open.d.ts +5 -0
- package/dist/types/src/operations/open.d.ts.map +1 -0
- package/dist/types/src/operations/summarize.d.ts +8 -0
- package/dist/types/src/operations/summarize.d.ts.map +1 -0
- package/dist/types/src/{components/stories → stories}/FileTranscription.stories.d.ts +3 -3
- 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 → stories}/MicrophoneTranscription.stories.d.ts +3 -3
- package/dist/types/src/stories/MicrophoneTranscription.stories.d.ts.map +1 -0
- package/dist/types/src/stories/TranscriptionStory.d.ts +23 -0
- package/dist/types/src/stories/TranscriptionStory.d.ts.map +1 -0
- package/dist/types/src/stories/useIsSpeaking.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts.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 +57 -2
- 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.map +1 -1
- package/dist/types/src/translations.d.ts +7 -8
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +2 -1
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/{types.d.ts → defs.d.ts} +1 -1
- package/dist/types/src/types/defs.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -3
- 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 +105 -75
- package/src/TranscriptionPlugin.node.ts +48 -0
- package/src/TranscriptionPlugin.test.ts +31 -0
- package/src/TranscriptionPlugin.tsx +23 -15
- package/src/blueprints/index.ts +1 -1
- package/src/blueprints/transcription-blueprint.ts +13 -9
- package/src/capabilities/blueprint-definition.ts +19 -0
- package/src/capabilities/index.ts +11 -4
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +31 -0
- package/src/capabilities/{transcriber/transcriber.ts → transcriber.ts} +9 -6
- package/src/components/{Transcript/Transcript.stories.tsx → Transcription/Transcription.stories.tsx} +27 -26
- package/src/components/Transcription/Transcription.tsx +64 -0
- package/src/components/{Transcript → Transcription}/index.ts +1 -1
- package/src/components/{Transcript/transcript-extension.ts → Transcription/transcription-extension.ts} +4 -4
- package/src/components/index.ts +1 -6
- package/src/containers/TranscriptionContainer/TranscriptionContainer.tsx +35 -0
- package/src/containers/TranscriptionContainer/index.ts +5 -0
- package/src/containers/index.ts +7 -0
- package/src/hooks/useTranscriber.ts +6 -3
- package/src/hooks/useVoiceInput.ts +0 -1
- package/src/index.ts +9 -4
- package/src/meta.ts +1 -1
- package/src/model/model.test.ts +6 -6
- package/src/model/model.ts +3 -3
- package/src/{segments-normalization → normalization}/message-normalizer.ts +1 -5
- package/src/{segments-normalization → normalization}/normalization.test.ts +2 -2
- package/src/normalization/normalization.ts +77 -0
- package/src/operations/create.ts +24 -0
- package/src/operations/definitions.ts +101 -0
- package/src/operations/index.ts +13 -0
- package/src/operations/open.ts +28 -0
- package/src/{functions → operations}/summarize.ts +46 -48
- package/src/{components/stories → stories}/FileTranscription.stories.tsx +34 -17
- package/src/{components/stories → stories}/KeyWordRecognition.stories.tsx +34 -32
- package/src/{components/stories → stories}/MicrophoneTranscription.stories.tsx +19 -37
- package/src/stories/TranscriptionStory.tsx +93 -0
- package/src/testing/testing.ts +8 -18
- 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 +94 -53
- package/src/translations.ts +7 -7
- package/src/types/capabilities.ts +9 -3
- package/src/types/index.ts +1 -3
- package/dist/lib/browser/TranscriptContainer-6EHKWVS4.mjs +0 -12
- package/dist/lib/browser/blueprint-definition-FTRNMLJZ.mjs +0 -18
- package/dist/lib/browser/blueprint-definition-FTRNMLJZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-ICM7JRCO.mjs +0 -698
- package/dist/lib/browser/chunk-ICM7JRCO.mjs.map +0 -7
- package/dist/lib/browser/chunk-Q5OC3WVG.mjs +0 -72
- package/dist/lib/browser/chunk-Q5OC3WVG.mjs.map +0 -7
- package/dist/lib/browser/chunk-SYGEFDWO.mjs +0 -8
- package/dist/lib/browser/chunk-SYGEFDWO.mjs.map +0 -7
- package/dist/lib/browser/chunk-TKFU53OZ.mjs +0 -460
- package/dist/lib/browser/chunk-TKFU53OZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZZF7ICVM.mjs +0 -150
- package/dist/lib/browser/chunk-ZZF7ICVM.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-ZUWTU7C5.mjs +0 -22
- package/dist/lib/browser/operation-resolver-ZUWTU7C5.mjs.map +0 -7
- package/dist/lib/browser/react-surface-ZXH5267I.mjs +0 -34
- package/dist/lib/browser/react-surface-ZXH5267I.mjs.map +0 -7
- package/dist/lib/browser/transcriber-EZZTUCPE.mjs +0 -60
- package/dist/lib/browser/transcriber-EZZTUCPE.mjs.map +0 -7
- package/dist/lib/node-esm/TranscriptContainer-5YT5W73I.mjs +0 -13
- package/dist/lib/node-esm/blueprint-definition-IOX35YUX.mjs +0 -19
- package/dist/lib/node-esm/blueprint-definition-IOX35YUX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4BFY6P2D.mjs +0 -73
- package/dist/lib/node-esm/chunk-4BFY6P2D.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BX2AB7S7.mjs +0 -699
- package/dist/lib/node-esm/chunk-BX2AB7S7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CWP22IHV.mjs +0 -151
- package/dist/lib/node-esm/chunk-CWP22IHV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EPC27WWV.mjs +0 -461
- package/dist/lib/node-esm/chunk-EPC27WWV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GVAVEVZ6.mjs +0 -10
- package/dist/lib/node-esm/chunk-GVAVEVZ6.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-Z72B4H2Q.mjs +0 -23
- package/dist/lib/node-esm/operation-resolver-Z72B4H2Q.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-6GUBZX2V.mjs +0 -35
- package/dist/lib/node-esm/react-surface-6GUBZX2V.mjs.map +0 -7
- package/dist/lib/node-esm/transcriber-RGW3YYT4.mjs +0 -61
- package/dist/lib/node-esm/transcriber-RGW3YYT4.mjs.map +0 -7
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +0 -9
- 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 +0 -5
- 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 +0 -9
- package/dist/types/src/capabilities/transcriber/transcriber.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/Transcript.d.ts.map +0 -1
- 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 -7
- package/dist/types/src/components/TranscriptContainer.d.ts.map +0 -1
- 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.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/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.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/types.d.ts.map +0 -1
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +0 -23
- 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 -27
- package/src/capabilities/transcriber/index.ts +0 -7
- package/src/components/Transcript/Transcript.tsx +0 -66
- package/src/components/Transcript/deprecated/OldTranscript.tsx +0 -260
- package/src/components/TranscriptContainer.tsx +0 -34
- package/src/components/stories/TranscriptionStory.tsx +0 -41
- package/src/functions/index.ts +0 -6
- package/src/functions/open.ts +0 -39
- package/src/segments-normalization/normalization.ts +0 -115
- package/src/types/TranscriptAction.ts +0 -32
- package/dist/lib/browser/{chunk-HOOPZ7EM.mjs.map → chunk-KAEXRX3Y.mjs.map} +0 -0
- package/dist/lib/browser/{TranscriptContainer-6EHKWVS4.mjs.map → hooks/index.mjs.map} +0 -0
- package/dist/lib/node-esm/{chunk-NVM2QUMX.mjs.map → chunk-O533NBMK.mjs.map} +0 -0
- package/dist/lib/node-esm/{TranscriptContainer-5YT5W73I.mjs.map → hooks/index.mjs.map} +0 -0
- package/dist/types/src/{segments-normalization → normalization}/message-normalizer.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/dist/types/src/{components/stories → stories}/useIsSpeaking.d.ts +0 -0
- package/src/{segments-normalization → normalization}/index.ts +1 -1
- /package/src/{segments-normalization → normalization}/utils.ts +0 -0
- /package/src/{components/stories → stories}/useIsSpeaking.tsx +0 -0
- /package/src/types/{types.ts → defs.ts} +0 -0
|
@@ -1,9 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
transcription_blueprint_exports
|
|
3
|
-
} from "../chunk-ZZF7ICVM.mjs";
|
|
4
|
-
import "../chunk-HOOPZ7EM.mjs";
|
|
5
1
|
import "../chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/blueprints/transcription-blueprint.ts
|
|
4
|
+
import { Blueprint, Template } from "@dxos/compute";
|
|
5
|
+
import { trim } from "@dxos/util";
|
|
6
|
+
import { TranscriptOperation } from "#operations";
|
|
7
|
+
var BLUEPRINT_KEY = "org.dxos.blueprint.transcription";
|
|
8
|
+
var make = () => Blueprint.make({
|
|
9
|
+
key: BLUEPRINT_KEY,
|
|
10
|
+
name: "Transcription",
|
|
11
|
+
tools: Blueprint.toolDefinitions({
|
|
12
|
+
operations: [
|
|
13
|
+
TranscriptOperation.Open,
|
|
14
|
+
TranscriptOperation.Summarize
|
|
15
|
+
]
|
|
16
|
+
}),
|
|
17
|
+
instructions: Template.make({
|
|
18
|
+
source: trim`
|
|
19
|
+
You can open and summarize a meeting transcript.
|
|
20
|
+
`
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
var blueprint = {
|
|
24
|
+
key: BLUEPRINT_KEY,
|
|
25
|
+
make
|
|
26
|
+
};
|
|
27
|
+
var transcription_blueprint_default = blueprint;
|
|
6
28
|
export {
|
|
7
|
-
|
|
29
|
+
transcription_blueprint_default as TranscriptionBlueprint
|
|
8
30
|
};
|
|
9
31
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
4
|
-
"sourcesContent": [],
|
|
5
|
-
"mappings": "",
|
|
6
|
-
"names": []
|
|
3
|
+
"sources": ["../../../../src/blueprints/transcription-blueprint.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Blueprint, Template } from '@dxos/compute';\nimport { trim } from '@dxos/util';\n\nimport { TranscriptOperation } from '#operations';\n\nconst BLUEPRINT_KEY = 'org.dxos.blueprint.transcription';\n\nconst make = () =>\n Blueprint.make({\n key: BLUEPRINT_KEY,\n name: 'Transcription',\n tools: Blueprint.toolDefinitions({ operations: [TranscriptOperation.Open, TranscriptOperation.Summarize] }),\n instructions: Template.make({\n source: trim`\n You can open and summarize a meeting transcript.\n `,\n }),\n });\n\nconst blueprint: Blueprint.Definition = {\n key: BLUEPRINT_KEY,\n make,\n};\n\nexport default blueprint;\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,WAAWC,gBAAgB;AACpC,SAASC,YAAY;AAErB,SAASC,2BAA2B;AAEpC,IAAMC,gBAAgB;AAEtB,IAAMC,OAAO,MACXL,UAAUK,KAAK;EACbC,KAAKF;EACLG,MAAM;EACNC,OAAOR,UAAUS,gBAAgB;IAAEC,YAAY;MAACP,oBAAoBQ;MAAMR,oBAAoBS;;EAAW,CAAA;EACzGC,cAAcZ,SAASI,KAAK;IAC1BS,QAAQZ;;;EAGV,CAAA;AACF,CAAA;AAEF,IAAMa,YAAkC;EACtCT,KAAKF;EACLC;AACF;AAEA,IAAA,kCAAeU;",
|
|
6
|
+
"names": ["Blueprint", "Template", "trim", "TranscriptOperation", "BLUEPRINT_KEY", "make", "key", "name", "tools", "toolDefinitions", "operations", "Open", "Summarize", "instructions", "source", "blueprint"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/types/capabilities.ts
|
|
2
|
+
import { Capability } from "@dxos/app-framework";
|
|
3
|
+
import { meta } from "#meta";
|
|
4
|
+
(function(TranscriptionCapabilities2) {
|
|
5
|
+
TranscriptionCapabilities2.Transcriber = Capability.make(`${meta.id}.capability.transcriber`);
|
|
6
|
+
TranscriptionCapabilities2.TranscriptionManager = Capability.make(`${meta.id}.capability.transcription-manager`);
|
|
7
|
+
})(TranscriptionCapabilities || (TranscriptionCapabilities = {}));
|
|
8
|
+
var TranscriptionCapabilities;
|
|
9
|
+
|
|
10
|
+
// src/types/defs.ts
|
|
11
|
+
var TRANSCRIPTION_URL = "https://calls-service.dxos.workers.dev";
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
TranscriptionCapabilities,
|
|
15
|
+
TRANSCRIPTION_URL
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=chunk-3L623EVL.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/capabilities.ts", "../../../src/types/defs.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nimport { meta } from '#meta';\n\nimport {\n type MediaStreamRecorderProps,\n type Transcriber,\n type TranscriberProps,\n type TranscriptMessageEnricher,\n type TranscriptionManager,\n} from '../transcriber';\n\nexport namespace TranscriptionCapabilities {\n export type GetTranscriberProps = {\n audioStreamTrack: MediaStreamTrack;\n recorderConfig?: Partial<MediaStreamRecorderProps['config']>;\n transcriberConfig?: Partial<TranscriberProps['config']>;\n onSegments: TranscriberProps['onSegments'];\n transcribe?: TranscriberProps['transcribe'];\n };\n\n export type GetTranscriber = (props: GetTranscriberProps) => Transcriber;\n\n export type GetTranscriptionManagerProps = {\n messageEnricher?: TranscriptMessageEnricher;\n };\n\n export type GetTranscriptionManager = (props: GetTranscriptionManagerProps) => TranscriptionManager;\n\n export const Transcriber = Capability.make<GetTranscriber>(`${meta.id}.capability.transcriber`);\n\n export const TranscriptionManager = Capability.make<GetTranscriptionManager>(\n `${meta.id}.capability.transcription-manager`,\n );\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\n/**\n * Endpoint to the calls service.\n */\n// TODO(burdon): Reconfigure/move.\nexport const TRANSCRIPTION_URL = 'https://calls-service.dxos.workers.dev';\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,kBAAkB;AAE3B,SAASC,YAAY;UAUJC,4BAAAA;6BAiBFC,cAAcH,WAAWI,KAAqB,GAAGH,KAAKI,EAAE,yBAAyB;6BAEjFC,uBAAuBN,WAAWI,KAC7C,GAAGH,KAAKI,EAAE,mCAAmC;AAEjD,GAtBiBH,8BAAAA,4BAAAA,CAAAA,EAAAA;;;;ACRV,IAAMK,oBAAoB;",
|
|
6
|
+
"names": ["Capability", "meta", "TranscriptionCapabilities", "Transcriber", "make", "id", "TranscriptionManager", "TRANSCRIPTION_URL"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
4
|
+
|
|
5
|
+
// src/operations/definitions.ts
|
|
6
|
+
var definitions_exports = {};
|
|
7
|
+
__export(definitions_exports, {
|
|
8
|
+
Create: () => Create,
|
|
9
|
+
MessageWithRangeId: () => MessageWithRangeId,
|
|
10
|
+
Open: () => Open,
|
|
11
|
+
SentenceNormalization: () => SentenceNormalization,
|
|
12
|
+
SentenceNormalizationInput: () => SentenceNormalizationInput,
|
|
13
|
+
SentenceNormalizationOutput: () => SentenceNormalizationOutput,
|
|
14
|
+
Summarize: () => Summarize
|
|
15
|
+
});
|
|
16
|
+
import * as Schema from "effect/Schema";
|
|
17
|
+
import { AiService } from "@dxos/ai";
|
|
18
|
+
import { SpaceSchema } from "@dxos/client/echo";
|
|
19
|
+
import { Operation } from "@dxos/compute";
|
|
20
|
+
import { Database, Feed, Ref } from "@dxos/echo";
|
|
21
|
+
import { Message, Transcript } from "@dxos/types";
|
|
22
|
+
import { meta } from "#meta";
|
|
23
|
+
var TRANSCRIPT_OPERATION = `${meta.id}.operation`;
|
|
24
|
+
var Create = Operation.make({
|
|
25
|
+
meta: {
|
|
26
|
+
key: `${TRANSCRIPT_OPERATION}.create`,
|
|
27
|
+
name: "Create Transcript"
|
|
28
|
+
},
|
|
29
|
+
input: Schema.Struct({
|
|
30
|
+
name: Schema.optional(Schema.String),
|
|
31
|
+
space: SpaceSchema
|
|
32
|
+
}),
|
|
33
|
+
output: Schema.Struct({
|
|
34
|
+
object: Transcript.Transcript
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
var MessageWithRangeId = Schema.extend(Message.Message, Schema.Struct({
|
|
38
|
+
rangeId: Schema.optional(Schema.Array(Schema.String)).annotations({
|
|
39
|
+
description: "The IDs of the messages that contain the sentences."
|
|
40
|
+
})
|
|
41
|
+
}));
|
|
42
|
+
var Open = Operation.make({
|
|
43
|
+
meta: {
|
|
44
|
+
key: "org.dxos.function.transcription.open",
|
|
45
|
+
name: "Open",
|
|
46
|
+
description: "Opens and reads the contents of a transcription object."
|
|
47
|
+
},
|
|
48
|
+
input: Schema.Struct({
|
|
49
|
+
transcript: Ref.Ref(Transcript.Transcript).annotations({
|
|
50
|
+
description: "The ID of the transcription object."
|
|
51
|
+
})
|
|
52
|
+
}),
|
|
53
|
+
output: Schema.Struct({
|
|
54
|
+
content: Schema.String
|
|
55
|
+
}),
|
|
56
|
+
services: [
|
|
57
|
+
Database.Service,
|
|
58
|
+
Feed.FeedService
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
var Summarize = Operation.make({
|
|
62
|
+
meta: {
|
|
63
|
+
key: "org.dxos.function.transcription.summarize",
|
|
64
|
+
name: "Summarize",
|
|
65
|
+
description: "Summarize a transcript of a meeting."
|
|
66
|
+
},
|
|
67
|
+
input: Schema.Struct({
|
|
68
|
+
transcript: Schema.String.annotations({
|
|
69
|
+
description: "The transcript of the meeting."
|
|
70
|
+
}),
|
|
71
|
+
notes: Schema.optional(Schema.String).annotations({
|
|
72
|
+
description: "Additional notes from the participants."
|
|
73
|
+
})
|
|
74
|
+
}),
|
|
75
|
+
output: Schema.Struct({
|
|
76
|
+
summary: Schema.String.annotations({
|
|
77
|
+
description: "The summary of the transcript."
|
|
78
|
+
})
|
|
79
|
+
}),
|
|
80
|
+
services: [
|
|
81
|
+
AiService.AiService
|
|
82
|
+
]
|
|
83
|
+
});
|
|
84
|
+
var SentenceNormalizationInput = Schema.Struct({
|
|
85
|
+
messages: Schema.Array(MessageWithRangeId).annotations({
|
|
86
|
+
description: "Messages to normalize into sentences."
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
var SentenceNormalizationOutput = Schema.Struct({
|
|
90
|
+
sentences: Schema.Array(MessageWithRangeId.pipe(Schema.mutable)).pipe(Schema.mutable).annotations({
|
|
91
|
+
description: "The sentences of the transcript."
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
var SentenceNormalization = Operation.make({
|
|
95
|
+
meta: {
|
|
96
|
+
key: "org.dxos.function.transcription.sentence-normalization",
|
|
97
|
+
name: "Sentence Normalization",
|
|
98
|
+
description: "Post process of transcription for sentence normalization"
|
|
99
|
+
},
|
|
100
|
+
input: SentenceNormalizationInput,
|
|
101
|
+
output: SentenceNormalizationOutput,
|
|
102
|
+
services: []
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
Create,
|
|
107
|
+
Open,
|
|
108
|
+
Summarize,
|
|
109
|
+
definitions_exports
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=chunk-L4HW35L6.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/operations/definitions.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { AiService } from '@dxos/ai';\nimport { SpaceSchema } from '@dxos/client/echo';\nimport { Operation } from '@dxos/compute';\nimport { Database, Feed, Ref } from '@dxos/echo';\nimport { Message, Transcript } from '@dxos/types';\n\nimport { meta } from '#meta';\n\nconst TRANSCRIPT_OPERATION = `${meta.id}.operation`;\n\nexport const Create = Operation.make({\n meta: { key: `${TRANSCRIPT_OPERATION}.create`, name: 'Create Transcript' },\n input: Schema.Struct({\n name: Schema.optional(Schema.String),\n space: SpaceSchema,\n }),\n output: Schema.Struct({\n object: Transcript.Transcript,\n }),\n});\n\nexport const MessageWithRangeId = Schema.extend(\n Message.Message,\n Schema.Struct({\n rangeId: Schema.optional(Schema.Array(Schema.String)).annotations({\n description: 'The IDs of the messages that contain the sentences.',\n }),\n }),\n);\n\nexport type MessageWithRangeIdType = Schema.Schema.Type<typeof MessageWithRangeId>;\n\nexport const Open = Operation.make({\n meta: {\n key: 'org.dxos.function.transcription.open',\n name: 'Open',\n description: 'Opens and reads the contents of a transcription object.',\n },\n input: Schema.Struct({\n transcript: Ref.Ref(Transcript.Transcript).annotations({\n description: 'The ID of the transcription object.',\n }),\n }),\n output: Schema.Struct({\n content: Schema.String,\n }),\n services: [Database.Service, Feed.FeedService],\n});\n\nexport const Summarize = Operation.make({\n meta: {\n key: 'org.dxos.function.transcription.summarize',\n name: 'Summarize',\n description: 'Summarize a transcript of a meeting.',\n },\n input: Schema.Struct({\n transcript: Schema.String.annotations({\n description: 'The transcript of the meeting.',\n }),\n notes: Schema.optional(Schema.String).annotations({\n description: 'Additional notes from the participants.',\n }),\n }),\n output: Schema.Struct({\n summary: Schema.String.annotations({\n description: 'The summary of the transcript.',\n }),\n }),\n services: [AiService.AiService],\n});\n\nexport const SentenceNormalizationInput = Schema.Struct({\n messages: Schema.Array(MessageWithRangeId).annotations({\n description: 'Messages to normalize into sentences.',\n }),\n});\n\nexport type SentenceNormalizationInputType = Schema.Schema.Type<typeof SentenceNormalizationInput>;\n\nexport const SentenceNormalizationOutput = Schema.Struct({\n sentences: Schema.Array(MessageWithRangeId.pipe(Schema.mutable)).pipe(Schema.mutable).annotations({\n description: 'The sentences of the transcript.',\n }),\n});\n\nexport const SentenceNormalization = Operation.make({\n meta: {\n key: 'org.dxos.function.transcription.sentence-normalization',\n name: 'Sentence Normalization',\n description: 'Post process of transcription for sentence normalization',\n },\n input: SentenceNormalizationInput,\n output: SentenceNormalizationOutput,\n services: [],\n});\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA;;;;;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,iBAAiB;AAC1B,SAASC,mBAAmB;AAC5B,SAASC,iBAAiB;AAC1B,SAASC,UAAUC,MAAMC,WAAW;AACpC,SAASC,SAASC,kBAAkB;AAEpC,SAASC,YAAY;AAErB,IAAMC,uBAAuB,GAAGD,KAAKE,EAAE;AAEhC,IAAMC,SAAST,UAAUU,KAAK;EACnCJ,MAAM;IAAEK,KAAK,GAAGJ,oBAAAA;IAA+BK,MAAM;EAAoB;EACzEC,OAAcC,cAAO;IACnBF,MAAaG,gBAAgBC,aAAM;IACnCC,OAAOlB;EACT,CAAA;EACAmB,QAAeJ,cAAO;IACpBK,QAAQd,WAAWA;EACrB,CAAA;AACF,CAAA;AAEO,IAAMe,qBAA4BC,cACvCjB,QAAQA,SACDU,cAAO;EACZQ,SAAgBP,gBAAgBQ,aAAaP,aAAM,CAAA,EAAGQ,YAAY;IAChEC,aAAa;EACf,CAAA;AACF,CAAA,CAAA;AAKK,IAAMC,OAAO1B,UAAUU,KAAK;EACjCJ,MAAM;IACJK,KAAK;IACLC,MAAM;IACNa,aAAa;EACf;EACAZ,OAAcC,cAAO;IACnBa,YAAYxB,IAAIA,IAAIE,WAAWA,UAAU,EAAEmB,YAAY;MACrDC,aAAa;IACf,CAAA;EACF,CAAA;EACAP,QAAeJ,cAAO;IACpBc,SAAgBZ;EAClB,CAAA;EACAa,UAAU;IAAC5B,SAAS6B;IAAS5B,KAAK6B;;AACpC,CAAA;AAEO,IAAMC,YAAYhC,UAAUU,KAAK;EACtCJ,MAAM;IACJK,KAAK;IACLC,MAAM;IACNa,aAAa;EACf;EACAZ,OAAcC,cAAO;IACnBa,YAAmBX,cAAOQ,YAAY;MACpCC,aAAa;IACf,CAAA;IACAQ,OAAclB,gBAAgBC,aAAM,EAAEQ,YAAY;MAChDC,aAAa;IACf,CAAA;EACF,CAAA;EACAP,QAAeJ,cAAO;IACpBoB,SAAgBlB,cAAOQ,YAAY;MACjCC,aAAa;IACf,CAAA;EACF,CAAA;EACAI,UAAU;IAAC/B,UAAUA;;AACvB,CAAA;AAEO,IAAMqC,6BAAoCrB,cAAO;EACtDsB,UAAiBb,aAAMH,kBAAAA,EAAoBI,YAAY;IACrDC,aAAa;EACf,CAAA;AACF,CAAA;AAIO,IAAMY,8BAAqCvB,cAAO;EACvDwB,WAAkBf,aAAMH,mBAAmBmB,KAAYC,cAAO,CAAA,EAAGD,KAAYC,cAAO,EAAEhB,YAAY;IAChGC,aAAa;EACf,CAAA;AACF,CAAA;AAEO,IAAMgB,wBAAwBzC,UAAUU,KAAK;EAClDJ,MAAM;IACJK,KAAK;IACLC,MAAM;IACNa,aAAa;EACf;EACAZ,OAAOsB;EACPjB,QAAQmB;EACRR,UAAU,CAAA;AACZ,CAAA;",
|
|
6
|
+
"names": ["Schema", "AiService", "SpaceSchema", "Operation", "Database", "Feed", "Ref", "Message", "Transcript", "meta", "TRANSCRIPT_OPERATION", "id", "Create", "make", "key", "name", "input", "Struct", "optional", "String", "space", "output", "object", "MessageWithRangeId", "extend", "rangeId", "Array", "annotations", "description", "Open", "transcript", "content", "services", "Service", "FeedService", "Summarize", "notes", "summary", "SentenceNormalizationInput", "messages", "SentenceNormalizationOutput", "sentences", "pipe", "mutable", "SentenceNormalization"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// src/model/model.ts
|
|
2
|
+
import { Text } from "@codemirror/state";
|
|
3
|
+
import { Event } from "@dxos/async";
|
|
4
|
+
import { invariant } from "@dxos/invariant";
|
|
5
|
+
import { log } from "@dxos/log";
|
|
6
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/model/model.ts";
|
|
7
|
+
var DocumentAdapter = class {
|
|
8
|
+
_view;
|
|
9
|
+
constructor(_view) {
|
|
10
|
+
this._view = _view;
|
|
11
|
+
}
|
|
12
|
+
/** The document must always have at least one line. */
|
|
13
|
+
lineCount() {
|
|
14
|
+
return this._view.state.doc.lines - 1;
|
|
15
|
+
}
|
|
16
|
+
replaceLines(from, remove, insert) {
|
|
17
|
+
log("replaceLines", {
|
|
18
|
+
count: this._view.state.doc.lines,
|
|
19
|
+
from,
|
|
20
|
+
remove,
|
|
21
|
+
insert
|
|
22
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 19, S: this });
|
|
23
|
+
const numLines = this._view.state.doc.lines;
|
|
24
|
+
const posFrom = this._view.state.doc.line(from).from;
|
|
25
|
+
const posTo = remove === 0 ? posFrom : this._view.state.doc.line(Math.min(numLines, from + remove)).from;
|
|
26
|
+
let text = insert.join("\n");
|
|
27
|
+
if (posTo === this._view.state.doc.length) {
|
|
28
|
+
text += "\n";
|
|
29
|
+
}
|
|
30
|
+
this._view.dispatch({
|
|
31
|
+
changes: {
|
|
32
|
+
from: posFrom,
|
|
33
|
+
to: posTo,
|
|
34
|
+
insert: text
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var SerializationModel = class {
|
|
40
|
+
_renderer;
|
|
41
|
+
/** Emits when the document is updated. */
|
|
42
|
+
update = new Event();
|
|
43
|
+
/** Ordered set of chunks. */
|
|
44
|
+
_chunks = [];
|
|
45
|
+
/** Map of chunk IDs to their current line counts. */
|
|
46
|
+
_chunkLineCounts = /* @__PURE__ */ new Map();
|
|
47
|
+
/** Map of line numbers to chunk IDs. */
|
|
48
|
+
_lineToChunk = /* @__PURE__ */ new Map();
|
|
49
|
+
/** Track chunk changes since last sync. */
|
|
50
|
+
_changes = [];
|
|
51
|
+
constructor(_renderer, initialChunks = []) {
|
|
52
|
+
this._renderer = _renderer;
|
|
53
|
+
initialChunks.forEach((chunk) => {
|
|
54
|
+
this.appendChunk(chunk);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
toJSON() {
|
|
58
|
+
return {
|
|
59
|
+
chunks: this._chunks.length,
|
|
60
|
+
changes: this._changes.length
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
get doc() {
|
|
64
|
+
return Text.of([
|
|
65
|
+
...this._chunks.flatMap((chunk, index) => this._renderer(chunk, index)),
|
|
66
|
+
""
|
|
67
|
+
]);
|
|
68
|
+
}
|
|
69
|
+
get chunks() {
|
|
70
|
+
return this._chunks;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get the block ID at the given line number.
|
|
74
|
+
*/
|
|
75
|
+
getChunkAtLine(line) {
|
|
76
|
+
return this._lineToChunk.get(line);
|
|
77
|
+
}
|
|
78
|
+
reset() {
|
|
79
|
+
this._chunks.length = 0;
|
|
80
|
+
this._chunkLineCounts.clear();
|
|
81
|
+
this._lineToChunk.clear();
|
|
82
|
+
this.update.emit();
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
appendChunk(chunk) {
|
|
86
|
+
const index = this._chunks.length;
|
|
87
|
+
this._chunks.push(chunk);
|
|
88
|
+
this._changes.push({
|
|
89
|
+
type: "append",
|
|
90
|
+
index,
|
|
91
|
+
chunk
|
|
92
|
+
});
|
|
93
|
+
this.update.emit();
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
updateChunk(chunk) {
|
|
97
|
+
const index = this._chunks.findIndex((c) => c.id === chunk.id);
|
|
98
|
+
invariant(index !== -1, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 102, S: this, A: ["index !== -1", ""] });
|
|
99
|
+
this._chunks[index] = chunk;
|
|
100
|
+
this._changes.push({
|
|
101
|
+
type: "update",
|
|
102
|
+
index,
|
|
103
|
+
chunk
|
|
104
|
+
});
|
|
105
|
+
this.update.emit();
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
deleteBlock(id) {
|
|
109
|
+
const index = this._chunks.findIndex((c) => c.id === id);
|
|
110
|
+
invariant(index !== -1, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 114, S: this, A: ["index !== -1", ""] });
|
|
111
|
+
this._chunks.splice(index, 1);
|
|
112
|
+
this._changes.push({
|
|
113
|
+
type: "delete",
|
|
114
|
+
index,
|
|
115
|
+
id
|
|
116
|
+
});
|
|
117
|
+
this.update.emit();
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Syncs the tracked changes with the ChunkDocument.
|
|
122
|
+
*/
|
|
123
|
+
sync(document) {
|
|
124
|
+
log("sync", {
|
|
125
|
+
changes: this._changes
|
|
126
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 127, S: this });
|
|
127
|
+
for (const change of this._changes) {
|
|
128
|
+
switch (change.type) {
|
|
129
|
+
case "append": {
|
|
130
|
+
const lines = this._renderer(change.chunk, change.index);
|
|
131
|
+
const lastLine = document.lineCount();
|
|
132
|
+
document.replaceLines(lastLine + 1, 0, lines);
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case "update": {
|
|
136
|
+
let lineStart = 1;
|
|
137
|
+
for (let i = 0; i < change.index; i++) {
|
|
138
|
+
lineStart += this._chunkLineCounts.get(this._chunks[i].id);
|
|
139
|
+
}
|
|
140
|
+
const previousLineCount = this._chunkLineCounts.get(change.chunk.id);
|
|
141
|
+
const newLines = this._renderer(change.chunk, change.index);
|
|
142
|
+
document.replaceLines(lineStart, previousLineCount, newLines);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
case "delete": {
|
|
146
|
+
let lineStart = 1;
|
|
147
|
+
for (let i = 0; i < change.index; i++) {
|
|
148
|
+
lineStart += this._chunkLineCounts.get(this._chunks[i].id);
|
|
149
|
+
}
|
|
150
|
+
const previousLineCount = this._chunkLineCounts.get(change.id);
|
|
151
|
+
document.replaceLines(lineStart, previousLineCount, []);
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
this._lineToChunk.clear();
|
|
157
|
+
let currentLine = 1;
|
|
158
|
+
for (const [index, chunk] of this._chunks.entries()) {
|
|
159
|
+
const lineCount = this._renderer(chunk, index).length;
|
|
160
|
+
this._chunkLineCounts.set(chunk.id, lineCount);
|
|
161
|
+
this._lineToChunk.set(currentLine, chunk);
|
|
162
|
+
currentLine += lineCount;
|
|
163
|
+
}
|
|
164
|
+
const chunkIds = new Set(this._chunks.map((chunk) => chunk.id));
|
|
165
|
+
for (const id of this._chunkLineCounts.keys()) {
|
|
166
|
+
if (!chunkIds.has(id)) {
|
|
167
|
+
this._chunkLineCounts.delete(id);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
this._changes.length = 0;
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export {
|
|
176
|
+
DocumentAdapter,
|
|
177
|
+
SerializationModel
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=chunk-MLRJWAQH.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/model/model.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Text } from '@codemirror/state';\nimport { type EditorView } from '@codemirror/view';\n\nimport { Event } from '@dxos/async';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nexport type Chunk = { id: string };\n\n/**\n * Covert block to a set of markdown lines.\n */\nexport type ChunkRenderer<T extends Chunk> = (chunk: T, index: number, debug?: boolean) => string[];\n\n/**\n * Abstract representation of the document model.\n */\nexport interface ChunkDocument {\n lineCount(): number;\n replaceLines(from: number, remove: number, insert: string[]): void;\n}\n\n/**\n * Codemirror document adapter.\n */\nexport class DocumentAdapter implements ChunkDocument {\n constructor(private readonly _view: EditorView) {}\n\n /** The document must always have at least one line. */\n lineCount(): number {\n return this._view.state.doc.lines - 1;\n }\n\n replaceLines(from: number, remove: number, insert: string[]): void {\n log('replaceLines', { count: this._view.state.doc.lines, from, remove, insert });\n\n const numLines = this._view.state.doc.lines;\n const posFrom = this._view.state.doc.line(from).from;\n const posTo = remove === 0 ? posFrom : this._view.state.doc.line(Math.min(numLines, from + remove)).from;\n\n // Don't remove the last line.\n let text = insert.join('\\n');\n if (posTo === this._view.state.doc.length) {\n text += '\\n';\n }\n\n this._view.dispatch({\n changes: { from: posFrom, to: posTo, insert: text },\n });\n }\n}\n\ntype ChunkChange<T extends Chunk> =\n | {\n type: 'append';\n index: number;\n chunk: T;\n }\n | {\n type: 'update';\n index: number;\n chunk: T;\n }\n | {\n type: 'delete';\n index: number;\n id: string;\n };\n\n/**\n * Each Chunk can be converted into a set of lines.\n * Chunks can be added, updated or deleted from the Queue.\n * A Document is an immutable projection that represents a flat list of lines corresponding to the Queue.\n *\n * Ideally we would implement a custom virtual Text model for the View, but this currently isn't possible in Codemirror.\n * Instead this model tracks changes and syncs them with the ChunkDocument.\n */\nexport class SerializationModel<T extends Chunk> {\n /** Emits when the document is updated. */\n public readonly update = new Event<void>();\n\n /** Ordered set of chunks. */\n private readonly _chunks: T[] = [];\n\n /** Map of chunk IDs to their current line counts. */\n private readonly _chunkLineCounts = new Map<string, number>();\n\n /** Map of line numbers to chunk IDs. */\n private readonly _lineToChunk = new Map<number, T>();\n\n /** Track chunk changes since last sync. */\n private readonly _changes: Array<ChunkChange<T>> = [];\n\n constructor(\n private readonly _renderer: ChunkRenderer<T>,\n initialChunks: T[] = [],\n ) {\n initialChunks.forEach((chunk) => {\n this.appendChunk(chunk);\n });\n }\n\n toJSON(): { chunks: number; changes: number } {\n return {\n chunks: this._chunks.length,\n changes: this._changes.length,\n };\n }\n\n get doc() {\n return Text.of([...this._chunks.flatMap((chunk, index) => this._renderer(chunk, index)), '']);\n }\n\n get chunks() {\n return this._chunks;\n }\n\n /**\n * Get the block ID at the given line number.\n */\n getChunkAtLine(line: number): T | undefined {\n return this._lineToChunk.get(line);\n }\n\n reset(): this {\n this._chunks.length = 0;\n this._chunkLineCounts.clear();\n this._lineToChunk.clear();\n this.update.emit();\n return this;\n }\n\n appendChunk(chunk: T): this {\n const index = this._chunks.length;\n this._chunks.push(chunk);\n this._changes.push({ type: 'append', index, chunk });\n this.update.emit();\n return this;\n }\n\n updateChunk(chunk: T): this {\n const index = this._chunks.findIndex((c) => c.id === chunk.id);\n invariant(index !== -1);\n this._chunks[index] = chunk;\n this._changes.push({ type: 'update', index, chunk });\n this.update.emit();\n return this;\n }\n\n deleteBlock(id: string): this {\n const index = this._chunks.findIndex((c) => c.id === id);\n invariant(index !== -1);\n this._chunks.splice(index, 1);\n this._changes.push({ type: 'delete', index, id });\n this.update.emit();\n return this;\n }\n\n /**\n * Syncs the tracked changes with the ChunkDocument.\n */\n sync(document: ChunkDocument): this {\n log('sync', { changes: this._changes });\n\n // Process each change in order.\n for (const change of this._changes) {\n switch (change.type) {\n case 'append': {\n // For appends, convert block to lines and add at the end.\n const lines = this._renderer(change.chunk, change.index);\n const lastLine = document.lineCount();\n document.replaceLines(lastLine + 1, 0, lines);\n break;\n }\n\n case 'update': {\n // For updates, find the block's line range and replace with new lines.\n let lineStart = 1;\n for (let i = 0; i < change.index; i++) {\n lineStart += this._chunkLineCounts.get(this._chunks[i].id)!;\n }\n const previousLineCount = this._chunkLineCounts.get(change.chunk.id)!;\n const newLines = this._renderer(change.chunk, change.index);\n document.replaceLines(lineStart, previousLineCount, newLines);\n break;\n }\n\n case 'delete': {\n // For deletes, find the block's line range and remove those lines.\n let lineStart = 1;\n for (let i = 0; i < change.index; i++) {\n lineStart += this._chunkLineCounts.get(this._chunks[i].id)!;\n }\n const previousLineCount = this._chunkLineCounts.get(change.id)!;\n document.replaceLines(lineStart, previousLineCount, []);\n break;\n }\n }\n }\n\n // Clear the line-to-block mapping.\n this._lineToChunk.clear();\n\n // Update all block line counts and line-to-block mapping after processing changes.\n let currentLine = 1;\n for (const [index, chunk] of this._chunks.entries()) {\n const lineCount = this._renderer(chunk, index).length;\n this._chunkLineCounts.set(chunk.id, lineCount);\n this._lineToChunk.set(currentLine, chunk);\n currentLine += lineCount;\n }\n\n // Clean up deleted blocks.\n const chunkIds = new Set(this._chunks.map((chunk) => chunk.id));\n for (const id of this._chunkLineCounts.keys()) {\n if (!chunkIds.has(id)) {\n this._chunkLineCounts.delete(id);\n }\n }\n\n // Clear changes after sync.\n this._changes.length = 0;\n return this;\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["Text", "Event", "invariant", "log", "_view", "replaceLines", "from", "remove", "insert", "count", "state", "posFrom", "line", "posTo", "text", "dispatch", "_chunkLineCounts", "_lineToChunk", "_changes", "_renderer", "initialChunks", "forEach", "chunk", "appendChunk", "toJSON", "chunks", "changes", "doc", "reset", "clear", "update", "_chunks", "push", "type", "index", "updateChunk", "deleteBlock", "splice", "id", "change", "document", "lastLine", "lines", "lineStart", "previousLineCount", "get", "newLines", "currentLine", "lineCount", "set", "chunkIds"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SerializationModel
|
|
3
|
+
} from "./chunk-MLRJWAQH.mjs";
|
|
4
|
+
|
|
5
|
+
// src/hooks/useAudioFile.ts
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
|
+
import { scheduleTask } from "@dxos/async";
|
|
8
|
+
import { Context } from "@dxos/context";
|
|
9
|
+
import { log } from "@dxos/log";
|
|
10
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/hooks/useAudioFile.ts";
|
|
11
|
+
var useAudioFile = (audioUrl, constraints) => {
|
|
12
|
+
const [{ audio, stream, track }, setStream] = useState({});
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const ctx = new Context(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 11 });
|
|
15
|
+
scheduleTask(ctx, async () => {
|
|
16
|
+
try {
|
|
17
|
+
const response = await fetch(audioUrl);
|
|
18
|
+
const blob = await response.blob();
|
|
19
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
20
|
+
ctx.onDispose(() => {
|
|
21
|
+
URL.revokeObjectURL(objectUrl);
|
|
22
|
+
});
|
|
23
|
+
const audio2 = new Audio();
|
|
24
|
+
audio2.src = objectUrl;
|
|
25
|
+
await new Promise((resolve, reject) => {
|
|
26
|
+
audio2.addEventListener("error", (err) => {
|
|
27
|
+
log.error("error", {
|
|
28
|
+
err
|
|
29
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 25, S: void 0 });
|
|
30
|
+
reject(err);
|
|
31
|
+
}, {
|
|
32
|
+
once: true
|
|
33
|
+
});
|
|
34
|
+
audio2.addEventListener("canplay", async () => {
|
|
35
|
+
resolve();
|
|
36
|
+
}, {
|
|
37
|
+
once: true
|
|
38
|
+
});
|
|
39
|
+
audio2.load();
|
|
40
|
+
});
|
|
41
|
+
const audioCtx = new AudioContext();
|
|
42
|
+
if (audioCtx.state === "suspended") {
|
|
43
|
+
await audioCtx.resume();
|
|
44
|
+
}
|
|
45
|
+
const destination = audioCtx.createMediaStreamDestination();
|
|
46
|
+
destination.channelCount = 1;
|
|
47
|
+
const source = audioCtx.createMediaElementSource(audio2);
|
|
48
|
+
source.connect(destination);
|
|
49
|
+
const track2 = destination.stream.getAudioTracks()[0];
|
|
50
|
+
if (constraints) {
|
|
51
|
+
await track2.applyConstraints(constraints).catch((err) => log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 50, S: void 0 }));
|
|
52
|
+
}
|
|
53
|
+
setStream({
|
|
54
|
+
audio: audio2,
|
|
55
|
+
stream: destination.stream,
|
|
56
|
+
track: destination.stream.getAudioTracks()[0]
|
|
57
|
+
});
|
|
58
|
+
} catch (err) {
|
|
59
|
+
log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 59, S: void 0 });
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return () => {
|
|
63
|
+
void ctx.dispose();
|
|
64
|
+
};
|
|
65
|
+
}, [
|
|
66
|
+
audioUrl
|
|
67
|
+
]);
|
|
68
|
+
return {
|
|
69
|
+
audio,
|
|
70
|
+
stream,
|
|
71
|
+
track
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// src/hooks/useAudioTrack.ts
|
|
76
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
77
|
+
var useAudioTrack = (active, constraints) => {
|
|
78
|
+
const [track, setTrack] = useState2();
|
|
79
|
+
useEffect2(() => {
|
|
80
|
+
if (!active) {
|
|
81
|
+
track?.stop();
|
|
82
|
+
setTrack(void 0);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const initAudio = async () => {
|
|
86
|
+
const audio = new Audio();
|
|
87
|
+
audio.srcObject = await navigator.mediaDevices.getUserMedia({
|
|
88
|
+
audio: constraints ?? true
|
|
89
|
+
});
|
|
90
|
+
const [track2] = audio.srcObject.getAudioTracks();
|
|
91
|
+
if (track2) {
|
|
92
|
+
setTrack(track2);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
if (active) {
|
|
96
|
+
void initAudio();
|
|
97
|
+
}
|
|
98
|
+
}, [
|
|
99
|
+
active
|
|
100
|
+
]);
|
|
101
|
+
return track;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// src/hooks/useQueueModelAdapter.ts
|
|
105
|
+
import { useEffect as useEffect3, useMemo, useState as useState3 } from "react";
|
|
106
|
+
var useQueueModelAdapter = (renderer, queue, initialChunks = []) => {
|
|
107
|
+
const model = useMemo(() => new SerializationModel(renderer, initialChunks), [
|
|
108
|
+
queue
|
|
109
|
+
]);
|
|
110
|
+
const [loaded, setLoaded] = useState3(false);
|
|
111
|
+
useEffect3(() => {
|
|
112
|
+
if (!queue) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const update = () => {
|
|
116
|
+
for (const block of queue?.objects ?? []) {
|
|
117
|
+
model.appendChunk(block);
|
|
118
|
+
}
|
|
119
|
+
setLoaded(true);
|
|
120
|
+
};
|
|
121
|
+
let i;
|
|
122
|
+
if (queue.isLoading) {
|
|
123
|
+
i = setInterval(() => {
|
|
124
|
+
if (!queue?.isLoading) {
|
|
125
|
+
clearInterval(i);
|
|
126
|
+
update();
|
|
127
|
+
}
|
|
128
|
+
}, 1e3);
|
|
129
|
+
} else {
|
|
130
|
+
update();
|
|
131
|
+
}
|
|
132
|
+
return () => clearTimeout(i);
|
|
133
|
+
}, [
|
|
134
|
+
model,
|
|
135
|
+
queue
|
|
136
|
+
]);
|
|
137
|
+
useEffect3(() => {
|
|
138
|
+
if (!loaded || !queue || model.chunks.length === queue.objects.length) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const chunk = queue.objects.at(-1);
|
|
142
|
+
if (chunk) {
|
|
143
|
+
model.appendChunk(chunk);
|
|
144
|
+
}
|
|
145
|
+
}, [
|
|
146
|
+
model,
|
|
147
|
+
loaded,
|
|
148
|
+
queue?.objects.length
|
|
149
|
+
]);
|
|
150
|
+
return model;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// src/hooks/useTranscriber.ts
|
|
154
|
+
import { useEffect as useEffect4, useMemo as useMemo2 } from "react";
|
|
155
|
+
import { useCapabilities } from "@dxos/app-framework/ui";
|
|
156
|
+
import { TranscriptionCapabilities } from "#types";
|
|
157
|
+
var useTranscriber = ({ audioStreamTrack, recorderConfig, transcriberConfig, onSegments, transcribe }) => {
|
|
158
|
+
const [getTranscriber] = useCapabilities(TranscriptionCapabilities.Transcriber);
|
|
159
|
+
const transcriber = useMemo2(() => {
|
|
160
|
+
if (!getTranscriber || !audioStreamTrack || !onSegments) {
|
|
161
|
+
return void 0;
|
|
162
|
+
}
|
|
163
|
+
return getTranscriber({
|
|
164
|
+
audioStreamTrack,
|
|
165
|
+
recorderConfig,
|
|
166
|
+
transcriberConfig,
|
|
167
|
+
onSegments,
|
|
168
|
+
transcribe
|
|
169
|
+
});
|
|
170
|
+
}, [
|
|
171
|
+
getTranscriber,
|
|
172
|
+
audioStreamTrack,
|
|
173
|
+
recorderConfig,
|
|
174
|
+
transcriberConfig,
|
|
175
|
+
onSegments,
|
|
176
|
+
transcribe
|
|
177
|
+
]);
|
|
178
|
+
useEffect4(() => {
|
|
179
|
+
return () => {
|
|
180
|
+
void transcriber?.close();
|
|
181
|
+
};
|
|
182
|
+
}, [
|
|
183
|
+
transcriber
|
|
184
|
+
]);
|
|
185
|
+
return transcriber;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// src/hooks/useVoiceInput.ts
|
|
189
|
+
import { useCallback, useEffect as useEffect5, useState as useState4 } from "react";
|
|
190
|
+
import { scheduleMicroTask } from "@dxos/async";
|
|
191
|
+
import { Context as Context2 } from "@dxos/context";
|
|
192
|
+
import { log as log2 } from "@dxos/log";
|
|
193
|
+
import { useSoundEffect } from "@dxos/react-ui-sfx";
|
|
194
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/hooks/useVoiceInput.ts";
|
|
195
|
+
var useVoiceInput = ({ active, onUpdate }) => {
|
|
196
|
+
const soundStart = useSoundEffect("StartRecording");
|
|
197
|
+
const soundStop = useSoundEffect("StopRecording");
|
|
198
|
+
const handleSegments = useCallback(async (segments) => {
|
|
199
|
+
const text = segments.map((str) => str.text.trim().replace(/[^\w\s]/g, "")).join(" ");
|
|
200
|
+
onUpdate(text);
|
|
201
|
+
}, []);
|
|
202
|
+
const [recording, setRecording] = useState4(false);
|
|
203
|
+
const track = useAudioTrack(active);
|
|
204
|
+
const transcriber = useTranscriber({
|
|
205
|
+
audioStreamTrack: track,
|
|
206
|
+
onSegments: handleSegments
|
|
207
|
+
});
|
|
208
|
+
useEffect5(() => {
|
|
209
|
+
const ctx = new Context2(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 29 });
|
|
210
|
+
scheduleMicroTask(ctx, async () => {
|
|
211
|
+
if (active && transcriber) {
|
|
212
|
+
await transcriber.open();
|
|
213
|
+
log2.info("starting...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 33, S: void 0 });
|
|
214
|
+
setRecording(true);
|
|
215
|
+
void soundStart.play();
|
|
216
|
+
transcriber.startChunksRecording();
|
|
217
|
+
} else if (!active && transcriber?.isOpen) {
|
|
218
|
+
transcriber?.stopChunksRecording();
|
|
219
|
+
await transcriber?.close();
|
|
220
|
+
log2.info("stopped", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 40, S: void 0 });
|
|
221
|
+
setRecording(false);
|
|
222
|
+
void soundStop.play();
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
return () => {
|
|
226
|
+
void ctx.dispose();
|
|
227
|
+
};
|
|
228
|
+
}, [
|
|
229
|
+
active,
|
|
230
|
+
transcriber
|
|
231
|
+
]);
|
|
232
|
+
return {
|
|
233
|
+
recording
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export {
|
|
238
|
+
useAudioFile,
|
|
239
|
+
useAudioTrack,
|
|
240
|
+
useQueueModelAdapter,
|
|
241
|
+
useTranscriber,
|
|
242
|
+
useVoiceInput
|
|
243
|
+
};
|
|
244
|
+
//# sourceMappingURL=chunk-NQQK7UZQ.mjs.map
|