@dxos/plugin-transcription 0.8.2-main.fbd8ed0 → 0.8.2-staging.4d6ad0f

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.
Files changed (243) hide show
  1. package/dist/lib/browser/TranscriptContainer-PFKLKRPQ.mjs +11 -0
  2. package/dist/lib/browser/{chunk-3TKXI6TQ.mjs → chunk-4KCUYW2F.mjs} +43 -26
  3. package/dist/lib/browser/chunk-4KCUYW2F.mjs.map +7 -0
  4. package/dist/lib/browser/{chunk-6ZR5MDK3.mjs → chunk-GOF7MJNV.mjs} +3 -3
  5. package/dist/lib/browser/{chunk-6ZR5MDK3.mjs.map → chunk-GOF7MJNV.mjs.map} +1 -1
  6. package/dist/lib/browser/chunk-IGEKO7ZU.mjs +8 -0
  7. package/dist/lib/browser/chunk-IGEKO7ZU.mjs.map +7 -0
  8. package/dist/lib/browser/{chunk-JHWEZRWC.mjs → chunk-NODIXNQP.mjs} +6 -15
  9. package/dist/lib/browser/chunk-NODIXNQP.mjs.map +7 -0
  10. package/dist/lib/browser/{chunk-K2LS2QOM.mjs → chunk-TJPJBE45.mjs} +136 -92
  11. package/dist/lib/browser/chunk-TJPJBE45.mjs.map +7 -0
  12. package/dist/lib/browser/{chunk-LTIQFX4W.mjs → chunk-W2KNYJD6.mjs} +4 -4
  13. package/dist/lib/browser/chunk-W2KNYJD6.mjs.map +7 -0
  14. package/dist/lib/browser/index.mjs +8 -31
  15. package/dist/lib/browser/index.mjs.map +3 -3
  16. package/dist/lib/browser/{intent-resolver-DZ62CJPC.mjs → intent-resolver-I2LJSQDR.mjs} +4 -8
  17. package/dist/lib/browser/intent-resolver-I2LJSQDR.mjs.map +7 -0
  18. package/dist/lib/browser/meta.json +1 -1
  19. package/dist/lib/browser/react-surface-ID2MLJHZ.mjs +34 -0
  20. package/dist/lib/browser/react-surface-ID2MLJHZ.mjs.map +7 -0
  21. package/dist/lib/browser/transcriber-NA7CIFIT.mjs +56 -0
  22. package/dist/lib/browser/transcriber-NA7CIFIT.mjs.map +7 -0
  23. package/dist/lib/browser/types/index.mjs +4 -8
  24. package/dist/lib/node/{TranscriptContainer-SSJVLRM6.cjs → TranscriptContainer-LHMC7553.cjs} +9 -9
  25. package/dist/lib/node/{TranscriptContainer-SSJVLRM6.cjs.map → TranscriptContainer-LHMC7553.cjs.map} +2 -2
  26. package/dist/lib/node/{chunk-EVE3H46F.cjs → chunk-3GS5UNO5.cjs} +141 -100
  27. package/dist/lib/node/chunk-3GS5UNO5.cjs.map +7 -0
  28. package/dist/lib/node/{chunk-L27AK6FQ.cjs → chunk-5J3FBCON.cjs} +8 -23
  29. package/dist/lib/node/chunk-5J3FBCON.cjs.map +7 -0
  30. package/dist/lib/node/{chunk-NVZWGFJL.cjs → chunk-AFUZI63A.cjs} +6 -6
  31. package/dist/lib/node/{chunk-NVZWGFJL.cjs.map → chunk-AFUZI63A.cjs.map} +1 -1
  32. package/dist/lib/node/{chunk-EJWB53WK.cjs → chunk-EIMUQYCZ.cjs} +10 -21
  33. package/dist/lib/node/chunk-EIMUQYCZ.cjs.map +7 -0
  34. package/dist/lib/node/{chunk-JUGOXWES.cjs → chunk-FKDJNJ57.cjs} +8 -8
  35. package/dist/lib/node/chunk-FKDJNJ57.cjs.map +7 -0
  36. package/dist/lib/node/{chunk-WKZLGVEJ.cjs → chunk-ZFTXJZXH.cjs} +44 -29
  37. package/dist/lib/node/chunk-ZFTXJZXH.cjs.map +7 -0
  38. package/dist/lib/node/index.cjs +36 -56
  39. package/dist/lib/node/index.cjs.map +3 -3
  40. package/dist/lib/node/{intent-resolver-TRBKI24D.cjs → intent-resolver-LLMGF5I5.cjs} +9 -11
  41. package/dist/lib/node/intent-resolver-LLMGF5I5.cjs.map +7 -0
  42. package/dist/lib/node/meta.json +1 -1
  43. package/dist/lib/node/{react-surface-SZAMHCX7.cjs → react-surface-SEQLEL4K.cjs} +13 -21
  44. package/dist/lib/node/react-surface-SEQLEL4K.cjs.map +7 -0
  45. package/dist/lib/node/transcriber-RKKN7LDU.cjs +68 -0
  46. package/dist/lib/node/transcriber-RKKN7LDU.cjs.map +7 -0
  47. package/dist/lib/node/types/index.cjs +7 -11
  48. package/dist/lib/node/types/index.cjs.map +2 -2
  49. package/dist/lib/node-esm/{TranscriptContainer-M53LI2TX.mjs → TranscriptContainer-DLNRFVTA.mjs} +4 -4
  50. package/dist/lib/node-esm/{chunk-QYG2FOXA.mjs → chunk-BRPFVRAD.mjs} +6 -15
  51. package/dist/lib/node-esm/chunk-BRPFVRAD.mjs.map +7 -0
  52. package/dist/lib/node-esm/{chunk-V5IWBPYO.mjs → chunk-EFIWBQDF.mjs} +43 -26
  53. package/dist/lib/node-esm/chunk-EFIWBQDF.mjs.map +7 -0
  54. package/dist/lib/node-esm/chunk-KUWWHMOA.mjs +10 -0
  55. package/dist/lib/node-esm/chunk-KUWWHMOA.mjs.map +7 -0
  56. package/dist/lib/node-esm/{chunk-5E2MR5XK.mjs → chunk-MFJPEIVB.mjs} +4 -4
  57. package/dist/lib/node-esm/chunk-MFJPEIVB.mjs.map +7 -0
  58. package/dist/lib/node-esm/{chunk-4KC3E5T4.mjs → chunk-PR7EYODX.mjs} +136 -92
  59. package/dist/lib/node-esm/chunk-PR7EYODX.mjs.map +7 -0
  60. package/dist/lib/node-esm/{chunk-X4DDJIVL.mjs → chunk-TXMDLLBR.mjs} +3 -3
  61. package/dist/lib/node-esm/{chunk-X4DDJIVL.mjs.map → chunk-TXMDLLBR.mjs.map} +1 -1
  62. package/dist/lib/node-esm/index.mjs +8 -31
  63. package/dist/lib/node-esm/index.mjs.map +3 -3
  64. package/dist/lib/node-esm/{intent-resolver-HFVAL274.mjs → intent-resolver-WOZKOEBW.mjs} +4 -8
  65. package/dist/lib/node-esm/intent-resolver-WOZKOEBW.mjs.map +7 -0
  66. package/dist/lib/node-esm/meta.json +1 -1
  67. package/dist/lib/node-esm/{react-surface-UEJELL7I.mjs → react-surface-7MXUUTAL.mjs} +9 -19
  68. package/dist/lib/node-esm/react-surface-7MXUUTAL.mjs.map +7 -0
  69. package/dist/lib/node-esm/transcriber-5WSI6DYK.mjs +57 -0
  70. package/dist/lib/node-esm/transcriber-5WSI6DYK.mjs.map +7 -0
  71. package/dist/lib/node-esm/types/index.mjs +4 -8
  72. package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
  73. package/dist/types/src/capabilities/capabilities.d.ts +8 -8
  74. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
  75. package/dist/types/src/capabilities/index.d.ts +1 -4
  76. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  77. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  78. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  79. package/dist/types/src/capabilities/transcriber.d.ts +2 -1
  80. package/dist/types/src/capabilities/transcriber.d.ts.map +1 -1
  81. package/dist/types/src/components/index.d.ts +0 -1
  82. package/dist/types/src/components/index.d.ts.map +1 -1
  83. package/dist/types/src/components/stories/FileTranscription.stories.d.ts +17 -0
  84. package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +1 -0
  85. package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts +10 -0
  86. package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts.map +1 -0
  87. package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts +19 -0
  88. package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +1 -0
  89. package/dist/types/src/components/stories/TranscriptionStory.d.ts +11 -0
  90. package/dist/types/src/components/stories/TranscriptionStory.d.ts.map +1 -0
  91. package/dist/types/src/components/stories/useIsSpeaking.d.ts +3 -0
  92. package/dist/types/src/components/stories/useIsSpeaking.d.ts.map +1 -0
  93. package/dist/types/src/hooks/useAudioFile.d.ts +1 -1
  94. package/dist/types/src/hooks/useAudioFile.d.ts.map +1 -1
  95. package/dist/types/src/hooks/useAudioTrack.d.ts +1 -1
  96. package/dist/types/src/hooks/useAudioTrack.d.ts.map +1 -1
  97. package/dist/types/src/hooks/useQueueModelAdapter.d.ts.map +1 -1
  98. package/dist/types/src/hooks/useTranscriber.d.ts +1 -1
  99. package/dist/types/src/hooks/useTranscriber.d.ts.map +1 -1
  100. package/dist/types/src/model/model.d.ts.map +1 -1
  101. package/dist/types/src/segments-normalization/index.d.ts +4 -0
  102. package/dist/types/src/segments-normalization/index.d.ts.map +1 -0
  103. package/dist/types/src/segments-normalization/message-normalizer.d.ts +26 -0
  104. package/dist/types/src/segments-normalization/message-normalizer.d.ts.map +1 -0
  105. package/dist/types/src/segments-normalization/normalization.d.ts +520 -0
  106. package/dist/types/src/segments-normalization/normalization.d.ts.map +1 -0
  107. package/dist/types/src/segments-normalization/normalization.test.d.ts +2 -0
  108. package/dist/types/src/segments-normalization/normalization.test.d.ts.map +1 -0
  109. package/dist/types/src/segments-normalization/utils.d.ts +3 -0
  110. package/dist/types/src/segments-normalization/utils.d.ts.map +1 -0
  111. package/dist/types/src/testing/testing.d.ts.map +1 -1
  112. package/dist/types/src/transcriber/media-stream-recorder.d.ts +8 -5
  113. package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
  114. package/dist/types/src/transcriber/transcriber.d.ts +4 -0
  115. package/dist/types/src/transcriber/transcriber.d.ts.map +1 -1
  116. package/dist/types/src/transcriber/transcription-manager.d.ts +2 -0
  117. package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
  118. package/dist/types/src/translations.d.ts +0 -2
  119. package/dist/types/src/translations.d.ts.map +1 -1
  120. package/dist/types/src/types/schema.d.ts +0 -3
  121. package/dist/types/src/types/schema.d.ts.map +1 -1
  122. package/dist/types/src/types/types.d.ts +1 -5
  123. package/dist/types/src/types/types.d.ts.map +1 -1
  124. package/package.json +54 -50
  125. package/src/TranscriptionPlugin.tsx +2 -24
  126. package/src/capabilities/capabilities.ts +15 -9
  127. package/src/capabilities/index.ts +0 -3
  128. package/src/capabilities/intent-resolver.ts +0 -2
  129. package/src/capabilities/react-surface.tsx +4 -11
  130. package/src/capabilities/transcriber.ts +34 -7
  131. package/src/components/Transcript/deprecated/OldTranscript.tsx +1 -1
  132. package/src/components/Transcript/transcript-extension.ts +2 -2
  133. package/src/components/index.ts +0 -1
  134. package/src/components/stories/FileTranscription.stories.tsx +240 -0
  135. package/src/components/stories/KeyWordRecognition.stories.tsx +128 -0
  136. package/src/components/stories/MicrophoneTranscription.stories.tsx +274 -0
  137. package/src/components/stories/TranscriptionStory.tsx +41 -0
  138. package/src/components/stories/useIsSpeaking.tsx +40 -0
  139. package/src/hooks/useAudioFile.ts +39 -9
  140. package/src/hooks/useAudioTrack.ts +2 -2
  141. package/src/hooks/useQueueModelAdapter.ts +7 -5
  142. package/src/hooks/useTranscriber.ts +4 -3
  143. package/src/meta.ts +2 -2
  144. package/src/model/model.ts +1 -1
  145. package/src/segments-normalization/index.ts +7 -0
  146. package/src/segments-normalization/message-normalizer.ts +108 -0
  147. package/src/segments-normalization/normalization.test.ts +142 -0
  148. package/src/segments-normalization/normalization.ts +103 -0
  149. package/src/segments-normalization/utils.ts +9 -0
  150. package/src/testing/testing.ts +17 -17
  151. package/src/transcriber/media-stream-recorder.ts +14 -7
  152. package/src/transcriber/transcriber.browser.test.ts +4 -4
  153. package/src/transcriber/transcriber.ts +13 -9
  154. package/src/transcriber/transcription-manager.ts +21 -14
  155. package/src/translations.ts +0 -3
  156. package/src/types/schema.ts +1 -2
  157. package/src/types/types.ts +1 -15
  158. package/dist/lib/browser/TranscriptContainer-CXA4ZBHW.mjs +0 -11
  159. package/dist/lib/browser/app-graph-builder-REQZ5SC5.mjs +0 -351
  160. package/dist/lib/browser/app-graph-builder-REQZ5SC5.mjs.map +0 -7
  161. package/dist/lib/browser/chunk-3TKXI6TQ.mjs.map +0 -7
  162. package/dist/lib/browser/chunk-JHWEZRWC.mjs.map +0 -7
  163. package/dist/lib/browser/chunk-K2LS2QOM.mjs.map +0 -7
  164. package/dist/lib/browser/chunk-KLD7O5GJ.mjs +0 -25
  165. package/dist/lib/browser/chunk-KLD7O5GJ.mjs.map +0 -7
  166. package/dist/lib/browser/chunk-LCTMCTYY.mjs +0 -27
  167. package/dist/lib/browser/chunk-LCTMCTYY.mjs.map +0 -7
  168. package/dist/lib/browser/chunk-LTIQFX4W.mjs.map +0 -7
  169. package/dist/lib/browser/intent-resolver-DZ62CJPC.mjs.map +0 -7
  170. package/dist/lib/browser/meeting-transcription-state-MNA2XROE.mjs +0 -18
  171. package/dist/lib/browser/meeting-transcription-state-MNA2XROE.mjs.map +0 -7
  172. package/dist/lib/browser/react-surface-PUXZNAZL.mjs +0 -44
  173. package/dist/lib/browser/react-surface-PUXZNAZL.mjs.map +0 -7
  174. package/dist/lib/browser/settings-JWDS4J3F.mjs +0 -24
  175. package/dist/lib/browser/settings-JWDS4J3F.mjs.map +0 -7
  176. package/dist/lib/browser/transcriber-YWWIV6KP.mjs +0 -37
  177. package/dist/lib/browser/transcriber-YWWIV6KP.mjs.map +0 -7
  178. package/dist/lib/node/app-graph-builder-OAPU4GDH.cjs +0 -352
  179. package/dist/lib/node/app-graph-builder-OAPU4GDH.cjs.map +0 -7
  180. package/dist/lib/node/chunk-EJWB53WK.cjs.map +0 -7
  181. package/dist/lib/node/chunk-EVE3H46F.cjs.map +0 -7
  182. package/dist/lib/node/chunk-J72PUQ3C.cjs +0 -46
  183. package/dist/lib/node/chunk-J72PUQ3C.cjs.map +0 -7
  184. package/dist/lib/node/chunk-JUGOXWES.cjs.map +0 -7
  185. package/dist/lib/node/chunk-L27AK6FQ.cjs.map +0 -7
  186. package/dist/lib/node/chunk-WKZLGVEJ.cjs.map +0 -7
  187. package/dist/lib/node/intent-resolver-TRBKI24D.cjs.map +0 -7
  188. package/dist/lib/node/meeting-transcription-state-5XLTMWPA.cjs +0 -34
  189. package/dist/lib/node/meeting-transcription-state-5XLTMWPA.cjs.map +0 -7
  190. package/dist/lib/node/react-surface-SZAMHCX7.cjs.map +0 -7
  191. package/dist/lib/node/settings-AWWMOSCV.cjs +0 -38
  192. package/dist/lib/node/settings-AWWMOSCV.cjs.map +0 -7
  193. package/dist/lib/node/transcriber-AFUXFHCR.cjs +0 -50
  194. package/dist/lib/node/transcriber-AFUXFHCR.cjs.map +0 -7
  195. package/dist/lib/node-esm/app-graph-builder-UBP6EOBR.mjs +0 -352
  196. package/dist/lib/node-esm/app-graph-builder-UBP6EOBR.mjs.map +0 -7
  197. package/dist/lib/node-esm/chunk-4KC3E5T4.mjs.map +0 -7
  198. package/dist/lib/node-esm/chunk-5E2MR5XK.mjs.map +0 -7
  199. package/dist/lib/node-esm/chunk-MHQP2PAF.mjs +0 -28
  200. package/dist/lib/node-esm/chunk-MHQP2PAF.mjs.map +0 -7
  201. package/dist/lib/node-esm/chunk-QMHMEKB3.mjs +0 -27
  202. package/dist/lib/node-esm/chunk-QMHMEKB3.mjs.map +0 -7
  203. package/dist/lib/node-esm/chunk-QYG2FOXA.mjs.map +0 -7
  204. package/dist/lib/node-esm/chunk-V5IWBPYO.mjs.map +0 -7
  205. package/dist/lib/node-esm/intent-resolver-HFVAL274.mjs.map +0 -7
  206. package/dist/lib/node-esm/meeting-transcription-state-3WOZ52BQ.mjs +0 -19
  207. package/dist/lib/node-esm/meeting-transcription-state-3WOZ52BQ.mjs.map +0 -7
  208. package/dist/lib/node-esm/react-surface-UEJELL7I.mjs.map +0 -7
  209. package/dist/lib/node-esm/settings-QFNFGFJ5.mjs +0 -25
  210. package/dist/lib/node-esm/settings-QFNFGFJ5.mjs.map +0 -7
  211. package/dist/lib/node-esm/transcriber-7RJEFPDI.mjs +0 -38
  212. package/dist/lib/node-esm/transcriber-7RJEFPDI.mjs.map +0 -7
  213. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  214. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  215. package/dist/types/src/capabilities/meeting-transcription-state.d.ts +0 -4
  216. package/dist/types/src/capabilities/meeting-transcription-state.d.ts.map +0 -1
  217. package/dist/types/src/capabilities/settings.d.ts +0 -4
  218. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  219. package/dist/types/src/components/TranscriptionSettings/TranscriptionSettings.d.ts +0 -6
  220. package/dist/types/src/components/TranscriptionSettings/TranscriptionSettings.d.ts.map +0 -1
  221. package/dist/types/src/components/TranscriptionSettings/index.d.ts +0 -2
  222. package/dist/types/src/components/TranscriptionSettings/index.d.ts.map +0 -1
  223. package/dist/types/src/components/transcription.stories.d.ts +0 -18
  224. package/dist/types/src/components/transcription.stories.d.ts.map +0 -1
  225. package/dist/types/src/entity-extraction/entity-extraction.d.ts +0 -42
  226. package/dist/types/src/entity-extraction/entity-extraction.d.ts.map +0 -1
  227. package/dist/types/src/entity-extraction/entity-extraction.test.d.ts +0 -2
  228. package/dist/types/src/entity-extraction/entity-extraction.test.d.ts.map +0 -1
  229. package/dist/types/src/entity-extraction/index.d.ts +0 -2
  230. package/dist/types/src/entity-extraction/index.d.ts.map +0 -1
  231. package/src/capabilities/app-graph-builder.ts +0 -233
  232. package/src/capabilities/meeting-transcription-state.ts +0 -16
  233. package/src/capabilities/settings.ts +0 -20
  234. package/src/components/TranscriptionSettings/TranscriptionSettings.tsx +0 -26
  235. package/src/components/TranscriptionSettings/index.ts +0 -5
  236. package/src/components/transcription.stories.tsx +0 -295
  237. package/src/entity-extraction/entity-extraction.test.ts +0 -97
  238. package/src/entity-extraction/entity-extraction.ts +0 -149
  239. package/src/entity-extraction/index.ts +0 -5
  240. package/src/entity-extraction/system-prompt.tpl +0 -38
  241. package/src/entity-extraction/types.d.ts +0 -8
  242. /package/dist/lib/browser/{TranscriptContainer-CXA4ZBHW.mjs.map → TranscriptContainer-PFKLKRPQ.mjs.map} +0 -0
  243. /package/dist/lib/node-esm/{TranscriptContainer-M53LI2TX.mjs.map → TranscriptContainer-DLNRFVTA.mjs.map} +0 -0
@@ -1,295 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import '@dxos-theme';
6
-
7
- import { type Meta, type StoryObj } from '@storybook/react';
8
- import React, {
9
- type Dispatch,
10
- type FC,
11
- type SetStateAction,
12
- useCallback,
13
- useEffect,
14
- useMemo,
15
- useRef,
16
- useState,
17
- } from 'react';
18
-
19
- import { Events, IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
20
- import { withPluginManager } from '@dxos/app-framework/testing';
21
- import { AIServiceEdgeClient } from '@dxos/assistant';
22
- import { AI_SERVICE_ENDPOINT } from '@dxos/assistant/testing';
23
- import { Filter, MemoryQueue } from '@dxos/echo-db';
24
- import { create, createQueueDxn } from '@dxos/echo-schema';
25
- import { type DXN } from '@dxos/keys';
26
- import { log } from '@dxos/log';
27
- import { ClientPlugin } from '@dxos/plugin-client';
28
- import { PreviewPlugin } from '@dxos/plugin-preview';
29
- import { SpacePlugin } from '@dxos/plugin-space';
30
- import { StorybookLayoutPlugin } from '@dxos/plugin-storybook-layout';
31
- import { ThemePlugin } from '@dxos/plugin-theme';
32
- import { useQueue, useSpace } from '@dxos/react-client/echo';
33
- import { IconButton, Toolbar } from '@dxos/react-ui';
34
- import { ScrollContainer } from '@dxos/react-ui-components';
35
- import { defaultTx } from '@dxos/react-ui-theme';
36
- import { DataType } from '@dxos/schema';
37
- import { seedTestData, Testing } from '@dxos/schema/testing';
38
- import { withLayout, withTheme } from '@dxos/storybook-utils';
39
-
40
- import { renderMarkdown, Transcript } from './Transcript';
41
- import { TranscriptionPlugin } from '../TranscriptionPlugin';
42
- import { processTranscriptMessage } from '../entity-extraction';
43
- import { useAudioFile, useAudioTrack, useQueueModelAdapter, useTranscriber } from '../hooks';
44
- import { type SerializationModel } from '../model';
45
- import { TestItem } from '../testing';
46
- import { type TranscriberParams } from '../transcriber';
47
-
48
- const TranscriptionStory: FC<{
49
- model: SerializationModel<DataType.Message>;
50
- running: boolean;
51
- onRunningChange: Dispatch<SetStateAction<boolean>>;
52
- }> = ({ model, running, onRunningChange }) => {
53
- const space = useSpace();
54
-
55
- return (
56
- <div className='flex flex-col w-[30rem]'>
57
- <Toolbar.Root>
58
- <IconButton
59
- iconOnly
60
- icon={running ? 'ph--pause--regular' : 'ph--play--regular'}
61
- label={running ? 'Pause' : 'Play'}
62
- onClick={() => onRunningChange((running) => !running)}
63
- />
64
- </Toolbar.Root>
65
- <ScrollContainer>
66
- <Transcript space={space} model={model} attendableId='story' />
67
- </ScrollContainer>
68
- </div>
69
- );
70
- };
71
-
72
- const aiService = new AIServiceEdgeClient({
73
- endpoint: AI_SERVICE_ENDPOINT.REMOTE,
74
- });
75
-
76
- const Microphone = ({ entityExtraction }: { entityExtraction?: boolean }) => {
77
- const [running, setRunning] = useState(false);
78
-
79
- // Audio.
80
- const track = useAudioTrack(running);
81
-
82
- // Queue.
83
- const queueDxn = useMemo(() => createQueueDxn(), []);
84
- const queue = useMemo(() => new MemoryQueue<DataType.Message>(queueDxn), [queueDxn]);
85
- const model = useQueueModelAdapter(renderMarkdown([]), queue);
86
- const space = useSpace();
87
-
88
- // Transcriber.
89
- const handleSegments = useCallback<TranscriberParams['onSegments']>(
90
- async (blocks) => {
91
- const message = create(DataType.Message, { sender: { name: 'You' }, created: new Date().toISOString(), blocks });
92
-
93
- if (entityExtraction) {
94
- if (!space) {
95
- log.warn('no space');
96
- return;
97
- }
98
- // TODO(dmaretskyi): Move to vector search index.
99
- const { objects } = await space.db
100
- .query(
101
- Filter.or(
102
- Filter.type(DataType.Person),
103
- Filter.type(DataType.Organization),
104
- Filter.type(Testing.DocumentType),
105
- ),
106
- )
107
- .run();
108
-
109
- log.info('context', { objects });
110
-
111
- const result = await processTranscriptMessage({
112
- message,
113
- aiService,
114
- context: {
115
- objects,
116
- },
117
- options: {
118
- fallbackToRaw: true,
119
- },
120
- });
121
- void queue.append([result.message]);
122
- } else {
123
- void queue.append([message]);
124
- }
125
- },
126
- [queue, space],
127
- );
128
-
129
- const config = useRef<TranscriberParams['config']>({
130
- transcribeAfterChunksAmount: 20,
131
- prefixBufferChunksAmount: 5,
132
- });
133
-
134
- const transcriber = useTranscriber({
135
- audioStreamTrack: track,
136
- onSegments: handleSegments,
137
- config: config.current,
138
- });
139
- const [isOpen, setIsOpen] = useState(false);
140
- useEffect(() => {
141
- void transcriber?.open().then(() => setIsOpen(true));
142
- return () => {
143
- void transcriber?.close().then(() => setIsOpen(false));
144
- };
145
- }, [transcriber]);
146
-
147
- // Manage transcription state.
148
- useEffect(() => {
149
- if (running && transcriber?.isOpen) {
150
- transcriber?.startChunksRecording();
151
- } else if (!running) {
152
- transcriber?.stopChunksRecording();
153
- }
154
- }, [transcriber, running, isOpen]);
155
-
156
- return <TranscriptionStory model={model} running={running} onRunningChange={setRunning} />;
157
- };
158
-
159
- const AudioFile = ({ queueDxn, audioUrl }: { queueDxn: DXN; audioUrl: string; transcriptUrl: string }) => {
160
- const [running, setRunning] = useState(false);
161
-
162
- // Audio.
163
- const audioElement = useRef<HTMLAudioElement>(null);
164
- const { audio, stream, track } = useAudioFile(audioUrl);
165
- useEffect(() => {
166
- if (stream && audioElement.current) {
167
- audioElement.current.srcObject = stream;
168
- }
169
- }, [stream, audioElement.current]);
170
-
171
- useEffect(() => {
172
- if (!audio) {
173
- log.warn('no audio');
174
- return;
175
- }
176
-
177
- if (running) {
178
- void audio.play();
179
- } else {
180
- void audio.pause();
181
- }
182
- }, [audio, running]);
183
-
184
- // Transcriber.
185
- const queue = useQueue<DataType.Message>(queueDxn, { pollInterval: 500 });
186
- const model = useQueueModelAdapter(renderMarkdown([]), queue);
187
- const handleSegments = useCallback<TranscriberParams['onSegments']>(
188
- async (blocks) => {
189
- const message = create(DataType.Message, { sender: { name: 'You' }, created: new Date().toISOString(), blocks });
190
- void queue?.append([message]);
191
- },
192
- [queue],
193
- );
194
-
195
- const transcriber = useTranscriber({
196
- audioStreamTrack: track,
197
- onSegments: handleSegments,
198
- });
199
-
200
- useEffect(() => {
201
- if (transcriber && running) {
202
- void transcriber.open().then(manageChunkRecording);
203
- } else if (!running) {
204
- transcriber?.stopChunksRecording();
205
- void transcriber?.close();
206
- }
207
- }, [transcriber, running]);
208
-
209
- const manageChunkRecording = () => {
210
- if (track?.readyState === 'live' && transcriber?.isOpen) {
211
- log.info('starting transcription');
212
- transcriber.startChunksRecording();
213
- } else if (track?.readyState !== 'live' && transcriber) {
214
- log.info('stopping transcription');
215
- transcriber.stopChunksRecording();
216
- }
217
- };
218
- useEffect(() => {
219
- manageChunkRecording();
220
- }, [transcriber, track?.readyState, transcriber?.isOpen]);
221
-
222
- return <TranscriptionStory model={model} running={running} onRunningChange={setRunning} />;
223
- };
224
-
225
- const meta: Meta<typeof AudioFile> = {
226
- title: 'plugins/plugin-transcription/transcription',
227
- decorators: [
228
- withPluginManager({
229
- plugins: [
230
- ThemePlugin({ tx: defaultTx }),
231
- StorybookLayoutPlugin(),
232
- ClientPlugin({
233
- types: [TestItem, DataType.Person, DataType.Organization, Testing.DocumentType],
234
- onClientInitialized: async (_, client) => {
235
- await client.halo.createIdentity();
236
- await client.spaces.waitUntilReady();
237
- await client.spaces.default.waitUntilReady();
238
- await seedTestData(client.spaces.default);
239
- },
240
- }),
241
- SpacePlugin(),
242
- SettingsPlugin(),
243
- PreviewPlugin(),
244
- IntentPlugin(),
245
- TranscriptionPlugin(),
246
- ],
247
- fireEvents: [Events.SetupAppGraph],
248
- // capabilities: [
249
- // contributes(
250
- // Capabilities.ReactSurface,
251
- // createSurface({
252
- // id: 'preview-test',
253
- // role: 'preview',
254
- // component: ({ data }) => {
255
- // const schema = getSchema(data);
256
- // if (!schema) {
257
- // return null;
258
- // }
259
-
260
- // return <Form schema={schema} values={data} />;
261
- // },
262
- // }),
263
- // ),
264
- // ],
265
- }),
266
- withTheme,
267
- withLayout({ fullscreen: true, classNames: 'justify-center' }),
268
- ],
269
- };
270
-
271
- export default meta;
272
-
273
- export const Default: StoryObj<typeof Microphone> = {
274
- render: Microphone,
275
- args: {
276
- entityExtraction: false,
277
- },
278
- };
279
-
280
- export const EntityExtraction: StoryObj<typeof Microphone> = {
281
- render: Microphone,
282
- args: {
283
- entityExtraction: true,
284
- },
285
- };
286
-
287
- export const File: StoryObj<typeof AudioFile> = {
288
- render: AudioFile,
289
- args: {
290
- queueDxn: createQueueDxn(),
291
- // https://learnenglish.britishcouncil.org/general-english/audio-zone/living-london
292
- transcriptUrl: 'https://dxos.network/audio-london.txt',
293
- audioUrl: 'https://dxos.network/audio-london.m4a',
294
- },
295
- };
@@ -1,97 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { describe, test, expect } from 'vitest';
6
-
7
- import { AIServiceEdgeClient } from '@dxos/assistant';
8
- import { AI_SERVICE_ENDPOINT } from '@dxos/assistant/testing';
9
- import { log } from '@dxos/log';
10
- import { createTestData } from '@dxos/schema/testing';
11
- import { range } from '@dxos/util';
12
-
13
- import { processTranscriptMessage, postprocessText } from './entity-extraction';
14
-
15
- const aiService = new AIServiceEdgeClient({
16
- endpoint: AI_SERVICE_ENDPOINT.REMOTE,
17
- });
18
-
19
- describe.skip('EntityExtraction', { timeout: 180_000 }, () => {
20
- test.skip('should process a transcript block', async () => {
21
- const { transcriptMessages, documents, contacts } = await createTestData();
22
-
23
- log.info('context', { documents, contacts });
24
-
25
- for (const message of transcriptMessages) {
26
- log.info('input', message);
27
- const { message: enhancedMessage } = await processTranscriptMessage({
28
- message,
29
- aiService,
30
- context: {
31
- objects: [...documents, ...Object.values(contacts)],
32
- },
33
- });
34
- log.info('output', enhancedMessage);
35
- }
36
- });
37
-
38
- test.only('computational irreducibility', async () => {
39
- const { transcriptWoflram, documents, contacts } = await createTestData();
40
-
41
- log.info('context', { documents, contacts });
42
- const message = transcriptWoflram[0];
43
- log.info('input', message);
44
-
45
- await Promise.all(
46
- range(10).map(async () => {
47
- const { message: enhancedMessage, timeElapsed } = await processTranscriptMessage({
48
- message,
49
- aiService,
50
- context: {
51
- objects: [...documents, ...Object.values(contacts)],
52
- },
53
- });
54
- log.info('output', { message: enhancedMessage.blocks[0], timeElapsed });
55
- }),
56
- );
57
- });
58
-
59
- test('org and document linking', async () => {
60
- const { transcriptJosiah, documents, contacts, organizations } = await createTestData();
61
-
62
- log.info('context', { contacts, organizations, documents });
63
-
64
- for (const message of transcriptJosiah) {
65
- log.info('input', message);
66
-
67
- const { message: enhancedMessage } = await processTranscriptMessage({
68
- message,
69
- aiService,
70
- context: {
71
- objects: [...documents, ...Object.values(contacts), ...Object.values(organizations)],
72
- },
73
- });
74
- log.info('output', enhancedMessage);
75
- }
76
- });
77
- });
78
-
79
- describe('postprocessText', () => {
80
- test('should replace quotes with DXN references', () => {
81
- const quotes = {
82
- references: [{ quote: 'computational irreducibility', id: '01JTG9JW11XGWJZ32AW8ET93D1' }],
83
- };
84
-
85
- expect(postprocessText('This is a computational irreducibility test.', quotes)).toBe(
86
- 'This is a [computational irreducibility][dxn:echo:@:01JTG9JW11XGWJZ32AW8ET93D1] test.',
87
- );
88
- expect(
89
- postprocessText(
90
- "And what I'd like to talk today about is Steven Wolfram's concept of a computational irreducibility.",
91
- quotes,
92
- ),
93
- ).toBe(
94
- "And what I'd like to talk today about is Steven Wolfram's concept of a [computational irreducibility][dxn:echo:@:01JTG9JW11XGWJZ32AW8ET93D1].",
95
- );
96
- });
97
- });
@@ -1,149 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Schema } from 'effect';
6
-
7
- import { createTemplate, Message, structuredOutputParser } from '@dxos/artifact';
8
- import type { AIServiceClient } from '@dxos/assistant';
9
- import { MixedStreamParser } from '@dxos/assistant';
10
- import { asyncTimeout } from '@dxos/async';
11
- import { type BaseEchoObject, create, ObjectId } from '@dxos/echo-schema';
12
- import { DXN } from '@dxos/keys';
13
- import { log } from '@dxos/log';
14
- import { DataType } from '@dxos/schema';
15
-
16
- import SYSTEM_PROMPT from './system-prompt.tpl?raw';
17
-
18
- type ProcessTranscriptMessageParams = {
19
- message: DataType.Message;
20
- aiService: AIServiceClient;
21
- context: {
22
- objects?: BaseEchoObject[];
23
- };
24
-
25
- options?: {
26
- /**
27
- * Timeout for the entity extraction.
28
- */
29
- timeout?: number;
30
-
31
- /**
32
- * Fallback to raw text if the entity extraction fails.
33
- * Otherwise the function will throw an error.
34
- * @default false
35
- */
36
- fallbackToRaw?: boolean;
37
- };
38
- };
39
-
40
- type ProcessTranscriptMessageResult = {
41
- message: DataType.Message;
42
- timeElapsed: number;
43
- };
44
-
45
- /**
46
- * Process Handlebars template.
47
- */
48
- const createSystemPrompt = (): string => {
49
- const template = createTemplate(SYSTEM_PROMPT);
50
- return template({});
51
- };
52
-
53
- const ReferencedQuotes = Schema.Struct({
54
- references: Schema.Array(
55
- Schema.Struct({
56
- quote: Schema.String,
57
- id: Schema.String,
58
- }),
59
- ).annotations({
60
- description:
61
- 'The references to the context objects that are mentioned in the transcript. quote should match the original transcript text exactly, while id is the id of the context object.',
62
- }),
63
- });
64
- interface ReferencedQuotes extends Schema.Schema.Type<typeof ReferencedQuotes> {}
65
-
66
- // TODO(dmaretskyi): Move context to a vector search index.
67
- export const processTranscriptMessage = async (
68
- params: ProcessTranscriptMessageParams,
69
- ): Promise<ProcessTranscriptMessageResult> => {
70
- try {
71
- const outputParser = structuredOutputParser(ReferencedQuotes);
72
- const runParser = async (): Promise<ProcessTranscriptMessageResult> => {
73
- const startTime = performance.now();
74
- const result = outputParser.getResult(
75
- await new MixedStreamParser().parse(
76
- await params.aiService.execStream({
77
- model: '@anthropic/claude-3-5-haiku-20241022',
78
- systemPrompt: createSystemPrompt(),
79
- history: [
80
- create(Message, {
81
- role: 'user',
82
- content: [
83
- {
84
- type: 'text',
85
- text: `<context>${JSON.stringify(params.context.objects)}</context>`,
86
- },
87
- {
88
- type: 'text',
89
- text: `<transcript>${JSON.stringify(params.message.blocks)}</transcript>`,
90
- },
91
- ],
92
- }),
93
- ],
94
- tools: [outputParser.tool],
95
- }),
96
- ),
97
- );
98
- log.info('entity extraction result', { refs: result.references });
99
-
100
- return {
101
- message: create(DataType.Message, {
102
- ...params.message,
103
- blocks: params.message.blocks.map((block, i) =>
104
- block.type !== 'transcription'
105
- ? block
106
- : {
107
- ...block,
108
- text: postprocessText(block.text, result),
109
- },
110
- ),
111
- }),
112
- timeElapsed: performance.now() - startTime,
113
- };
114
- };
115
-
116
- if (params.options?.timeout && params.options.timeout > 0) {
117
- return await asyncTimeout(runParser(), params.options.timeout);
118
- } else {
119
- return await runParser();
120
- }
121
- } catch (error) {
122
- if (params.options?.fallbackToRaw) {
123
- log.warn('failed to process transcript message, falling back to raw text', { error });
124
- return {
125
- message: params.message,
126
- timeElapsed: 0,
127
- };
128
- } else {
129
- throw error;
130
- }
131
- }
132
- };
133
-
134
- /**
135
- * Finds and replaces all quotes with DXNs references.
136
- */
137
- // TODO(dmaretskyi): Lookup and verifiy ids from provided context.
138
- export const postprocessText = (text: string, quotes: ReferencedQuotes) => {
139
- for (const quote of quotes.references) {
140
- if (!ObjectId.isValid(quote.id)) {
141
- continue;
142
- }
143
-
144
- // Use a case-insensitive regular expression to replace the quote
145
- const regex = new RegExp(quote.quote.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'gi');
146
- text = text.replace(regex, `[${quote.quote}][${DXN.fromLocalObjectId(quote.id).toString()}]`);
147
- }
148
- return text;
149
- };
@@ -1,5 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- export * from './entity-extraction';
@@ -1,38 +0,0 @@
1
- You are an AI assistant specialized in processing and enhancing transcripts with contextual information.
2
- Your task is to analyze a given transcript and extract references to the context objects.
3
-
4
- The context and transcript are provided in the user message in `context` and `transcript` XML tags.
5
-
6
- Here are your instructions:
7
-
8
- 1. Read the transcript and context information provided above.
9
-
10
- 2. Process each segment of the transcript separately.
11
-
12
- 3. For each segment:
13
- a. Analyze the content and identify relevant information from the context.
14
- b. Extract a number of references to the context objects that are mentioned in the segment.
15
- c. Output the references in the format `{ "quote": "earnings report", "id": "01JT0JP9AX0XKGZX4MV4B69VT6" }`.
16
- d. If there are no references, just output an empty array.
17
-
18
- 4. Maintain the exact order and structure of the original transcript segments.
19
-
20
- Output Format:
21
- The final output should be a JSON array of references.
22
-
23
- Example output structure:
24
- ```json
25
- {
26
- "references": [
27
- { "quote": "earnings report", "id": "01JT0JP9AX0XKGZX4MV4B69VT6" },
28
- { "quote": "John", "id": "01JT0VM0VN3ZKN7GDBM8CV9BA7" }
29
- ]
30
- }
31
- ```
32
-
33
- Remember:
34
- - Only quote the text that is in the transcript.
35
- - Analyze each segment carefully before processing it.
36
- - Only reference objects that appear in the context and exactly by their id, If the object is not in the context, do not insert a reference.
37
-
38
- Now, process the transcript and context provided below according to these instructions.
@@ -1,8 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- declare module '*.tpl?raw' {
6
- const content: string;
7
- export default content;
8
- }