@dxos/plugin-transcription 0.8.4-main.fcfe5033a5 → 0.8.4-staging.60fe92afc8

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 (319) hide show
  1. package/LICENSE +102 -5
  2. package/PLUGIN.mdl +401 -0
  3. package/README.md +1 -1
  4. package/dist/lib/neutral/TranscriptionArticle-L6XANBH5.mjs +54 -0
  5. package/dist/lib/neutral/TranscriptionArticle-L6XANBH5.mjs.map +7 -0
  6. package/dist/lib/neutral/TranscriptionPlugin.mjs +46 -0
  7. package/dist/lib/neutral/TranscriptionPlugin.mjs.map +7 -0
  8. package/dist/lib/neutral/TranscriptionPlugin.node.mjs +25 -0
  9. package/dist/lib/neutral/TranscriptionPlugin.node.mjs.map +7 -0
  10. package/dist/lib/neutral/TranscriptionPlugin.workerd.mjs +21 -0
  11. package/dist/lib/neutral/TranscriptionPlugin.workerd.mjs.map +7 -0
  12. package/dist/lib/neutral/blueprint-definition-DA4QFRYJ.mjs +15 -0
  13. package/dist/lib/neutral/blueprint-definition-DA4QFRYJ.mjs.map +7 -0
  14. package/dist/lib/neutral/blueprints/index.mjs +8 -0
  15. package/dist/lib/neutral/capabilities/index.mjs +17 -0
  16. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  17. package/dist/lib/neutral/chunk-FHNI26QW.mjs +45 -0
  18. package/dist/lib/neutral/chunk-FHNI26QW.mjs.map +7 -0
  19. package/dist/lib/{browser/chunk-HOOPZ7EM.mjs → neutral/chunk-KAEXRX3Y.mjs} +1 -1
  20. package/dist/lib/{browser/chunk-KOX4WNAR.mjs → neutral/chunk-KMT3BMMQ.mjs} +35 -22
  21. package/dist/lib/neutral/chunk-KMT3BMMQ.mjs.map +7 -0
  22. package/dist/lib/neutral/chunk-KXJZEYS7.mjs +8 -0
  23. package/dist/lib/neutral/chunk-KXJZEYS7.mjs.map +7 -0
  24. package/dist/lib/neutral/chunk-MLRJWAQH.mjs +179 -0
  25. package/dist/lib/neutral/chunk-MLRJWAQH.mjs.map +7 -0
  26. package/dist/lib/neutral/chunk-TO77KAQK.mjs +298 -0
  27. package/dist/lib/neutral/chunk-TO77KAQK.mjs.map +7 -0
  28. package/dist/lib/neutral/chunk-TX3NQISZ.mjs +435 -0
  29. package/dist/lib/neutral/chunk-TX3NQISZ.mjs.map +7 -0
  30. package/dist/lib/{browser/blueprints/index.mjs → neutral/chunk-ZR4BH4QQ.mjs} +5 -6
  31. package/dist/lib/neutral/chunk-ZR4BH4QQ.mjs.map +7 -0
  32. package/dist/lib/neutral/components/index.mjs +269 -0
  33. package/dist/lib/neutral/components/index.mjs.map +7 -0
  34. package/dist/lib/neutral/containers/index.mjs +9 -0
  35. package/dist/lib/neutral/containers/index.mjs.map +7 -0
  36. package/dist/lib/{browser/create-BTWYQ6IM.mjs → neutral/create-RVR7VC33.mjs} +5 -5
  37. package/dist/lib/neutral/create-RVR7VC33.mjs.map +7 -0
  38. package/dist/lib/neutral/hooks/index.mjs +19 -0
  39. package/dist/lib/neutral/index.mjs +44 -0
  40. package/dist/lib/neutral/meta.json +1 -0
  41. package/dist/lib/neutral/meta.mjs +8 -0
  42. package/dist/lib/neutral/meta.mjs.map +7 -0
  43. package/dist/lib/{browser/open-CYRYIEZI.mjs → neutral/open-A5KXKRH4.mjs} +7 -7
  44. package/dist/lib/neutral/open-A5KXKRH4.mjs.map +7 -0
  45. package/dist/lib/neutral/operation-handler-NXMOAXFP.mjs +13 -0
  46. package/dist/lib/neutral/operation-handler-NXMOAXFP.mjs.map +7 -0
  47. package/dist/lib/neutral/operations/index.mjs +8 -0
  48. package/dist/lib/neutral/operations/index.mjs.map +7 -0
  49. package/dist/lib/neutral/plugin.mjs +16 -0
  50. package/dist/lib/neutral/plugin.mjs.map +7 -0
  51. package/dist/lib/neutral/react-surface-YMZRO242.mjs +26 -0
  52. package/dist/lib/neutral/react-surface-YMZRO242.mjs.map +7 -0
  53. package/dist/lib/{browser/summarize-X2ZYTN7S.mjs → neutral/summarize-5XPPMVTE.mjs} +9 -11
  54. package/dist/lib/neutral/summarize-5XPPMVTE.mjs.map +7 -0
  55. package/dist/lib/neutral/text-content-KBB37HSM.mjs +30 -0
  56. package/dist/lib/neutral/text-content-KBB37HSM.mjs.map +7 -0
  57. package/dist/lib/neutral/transcriber-OGSF3XO5.mjs +59 -0
  58. package/dist/lib/neutral/transcriber-OGSF3XO5.mjs.map +7 -0
  59. package/dist/lib/neutral/translations.mjs +24 -0
  60. package/dist/lib/neutral/translations.mjs.map +7 -0
  61. package/dist/lib/neutral/types/index.mjs +10 -0
  62. package/dist/lib/neutral/types/index.mjs.map +7 -0
  63. package/dist/types/src/TranscriptionPlugin.d.ts +1 -0
  64. package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
  65. package/dist/types/src/TranscriptionPlugin.node.d.ts +4 -0
  66. package/dist/types/src/TranscriptionPlugin.node.d.ts.map +1 -0
  67. package/dist/types/src/TranscriptionPlugin.test.d.ts +2 -0
  68. package/dist/types/src/TranscriptionPlugin.test.d.ts.map +1 -0
  69. package/dist/types/src/TranscriptionPlugin.workerd.d.ts +4 -0
  70. package/dist/types/src/TranscriptionPlugin.workerd.d.ts.map +1 -0
  71. package/dist/types/src/blueprints/transcription-blueprint.d.ts +2 -2
  72. package/dist/types/src/blueprints/transcription-blueprint.d.ts.map +1 -1
  73. package/dist/types/src/capabilities/blueprint-definition.d.ts +1 -1
  74. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
  75. package/dist/types/src/capabilities/index.d.ts +8 -3
  76. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  77. package/dist/types/src/capabilities/operation-handler.d.ts +1 -1
  78. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -1
  79. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  80. package/dist/types/src/capabilities/text-content.d.ts +8 -0
  81. package/dist/types/src/capabilities/text-content.d.ts.map +1 -0
  82. package/dist/types/src/capabilities/transcriber.d.ts +1 -1
  83. package/dist/types/src/capabilities/transcriber.d.ts.map +1 -1
  84. package/dist/types/src/components/Oracle/Oracle.d.ts +24 -0
  85. package/dist/types/src/components/Oracle/Oracle.d.ts.map +1 -0
  86. package/dist/types/src/components/Oracle/Oracle.stories.d.ts +32 -0
  87. package/dist/types/src/components/Oracle/Oracle.stories.d.ts.map +1 -0
  88. package/dist/types/src/components/Oracle/index.d.ts +2 -0
  89. package/dist/types/src/components/Oracle/index.d.ts.map +1 -0
  90. package/dist/types/src/components/Transcription/Transcription.d.ts +1 -8
  91. package/dist/types/src/components/Transcription/Transcription.d.ts.map +1 -1
  92. package/dist/types/src/components/Transcription/Transcription.stories.d.ts +20 -23
  93. package/dist/types/src/components/Transcription/Transcription.stories.d.ts.map +1 -1
  94. package/dist/types/src/components/Transcription/transcription-extension.d.ts.map +1 -1
  95. package/dist/types/src/components/index.d.ts +1 -0
  96. package/dist/types/src/components/index.d.ts.map +1 -1
  97. package/dist/types/src/containers/TranscriptionArticle/TranscriptionArticle.d.ts +6 -0
  98. package/dist/types/src/containers/TranscriptionArticle/TranscriptionArticle.d.ts.map +1 -0
  99. package/dist/types/src/containers/TranscriptionArticle/TranscriptionArticle.stories.d.ts +28 -0
  100. package/dist/types/src/containers/TranscriptionArticle/TranscriptionArticle.stories.d.ts.map +1 -0
  101. package/dist/types/src/containers/TranscriptionArticle/index.d.ts +2 -0
  102. package/dist/types/src/containers/TranscriptionArticle/index.d.ts.map +1 -0
  103. package/dist/types/src/containers/index.d.ts +1 -1
  104. package/dist/types/src/containers/index.d.ts.map +1 -1
  105. package/dist/types/src/enrichment/conversation.test.d.ts +2 -0
  106. package/dist/types/src/enrichment/conversation.test.d.ts.map +1 -0
  107. package/dist/types/src/enrichment/operations.d.ts +200 -0
  108. package/dist/types/src/enrichment/operations.d.ts.map +1 -0
  109. package/dist/types/src/enrichment/parser.d.ts +26 -0
  110. package/dist/types/src/enrichment/parser.d.ts.map +1 -0
  111. package/dist/types/src/enrichment/stream-simulator.d.ts +38 -0
  112. package/dist/types/src/enrichment/stream-simulator.d.ts.map +1 -0
  113. package/dist/types/src/hooks/index.d.ts +2 -1
  114. package/dist/types/src/hooks/index.d.ts.map +1 -1
  115. package/dist/types/src/hooks/useAudioFile.d.ts.map +1 -1
  116. package/dist/types/src/hooks/useAudioTrack.d.ts.map +1 -1
  117. package/dist/types/src/hooks/useFeedModelAdapter.d.ts +12 -0
  118. package/dist/types/src/hooks/useFeedModelAdapter.d.ts.map +1 -0
  119. package/dist/types/src/hooks/useTranscriber.d.ts +1 -1
  120. package/dist/types/src/hooks/useTranscriber.d.ts.map +1 -1
  121. package/dist/types/src/hooks/useTranscriptionRecording.d.ts +12 -0
  122. package/dist/types/src/hooks/useTranscriptionRecording.d.ts.map +1 -0
  123. package/dist/types/src/hooks/useVoiceInput.d.ts.map +1 -1
  124. package/dist/types/src/index.d.ts +2 -3
  125. package/dist/types/src/index.d.ts.map +1 -1
  126. package/dist/types/src/meta.d.ts +1 -1
  127. package/dist/types/src/meta.d.ts.map +1 -1
  128. package/dist/types/src/model/model.d.ts +2 -2
  129. package/dist/types/src/model/model.d.ts.map +1 -1
  130. package/dist/types/src/{segments-normalization → normalization}/index.d.ts +1 -1
  131. package/dist/types/src/normalization/index.d.ts.map +1 -0
  132. package/dist/types/src/{segments-normalization → normalization}/message-normalizer.d.ts +7 -5
  133. package/dist/types/src/normalization/message-normalizer.d.ts.map +1 -0
  134. package/dist/types/src/{operations/definitions.d.ts → normalization/normalization.d.ts} +464 -547
  135. package/dist/types/src/normalization/normalization.d.ts.map +1 -0
  136. package/dist/types/src/normalization/normalization.test.d.ts.map +1 -0
  137. package/dist/types/src/normalization/utils.d.ts.map +1 -0
  138. package/dist/types/src/operations/create.d.ts +3 -3
  139. package/dist/types/src/operations/create.d.ts.map +1 -1
  140. package/dist/types/src/operations/index.d.ts +1 -2
  141. package/dist/types/src/operations/index.d.ts.map +1 -1
  142. package/dist/types/src/operations/open.d.ts +3 -3
  143. package/dist/types/src/operations/open.d.ts.map +1 -1
  144. package/dist/types/src/operations/summarize.d.ts +3 -3
  145. package/dist/types/src/operations/summarize.d.ts.map +1 -1
  146. package/dist/types/src/plugin.d.ts +4 -0
  147. package/dist/types/src/plugin.d.ts.map +1 -0
  148. package/dist/types/src/stories/FileTranscription.stories.d.ts +20 -0
  149. package/dist/types/src/stories/FileTranscription.stories.d.ts.map +1 -0
  150. package/dist/types/src/stories/KeyWordRecognition.stories.d.ts.map +1 -0
  151. package/dist/types/src/{components/stories/MicrophoneTranscription.stories.d.ts → stories/LiveTranscription.stories.d.ts} +5 -5
  152. package/dist/types/src/stories/LiveTranscription.stories.d.ts.map +1 -0
  153. package/dist/types/src/stories/TranscriptionStory.d.ts +21 -0
  154. package/dist/types/src/stories/TranscriptionStory.d.ts.map +1 -0
  155. package/dist/types/src/stories/common.d.ts +248 -0
  156. package/dist/types/src/stories/common.d.ts.map +1 -0
  157. package/dist/types/src/testing/testing.d.ts +5 -6
  158. package/dist/types/src/testing/testing.d.ts.map +1 -1
  159. package/dist/types/src/transcriber/index.d.ts +1 -1
  160. package/dist/types/src/transcriber/index.d.ts.map +1 -1
  161. package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
  162. package/dist/types/src/transcriber/transcriber.d.ts +58 -3
  163. package/dist/types/src/transcriber/transcriber.d.ts.map +1 -1
  164. package/dist/types/src/transcriber/transcriber.test.d.ts +2 -0
  165. package/dist/types/src/transcriber/transcriber.test.d.ts.map +1 -0
  166. package/dist/types/src/transcriber/transcription-manager.d.ts +6 -4
  167. package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
  168. package/dist/types/src/translations.d.ts +9 -8
  169. package/dist/types/src/translations.d.ts.map +1 -1
  170. package/dist/types/src/types/TranscriptOperation.d.ts +1670 -0
  171. package/dist/types/src/types/TranscriptOperation.d.ts.map +1 -0
  172. package/dist/types/src/types/TranscriptionCapabilities.d.ts +17 -0
  173. package/dist/types/src/types/TranscriptionCapabilities.d.ts.map +1 -0
  174. package/dist/types/src/types/index.d.ts +2 -2
  175. package/dist/types/src/types/index.d.ts.map +1 -1
  176. package/dist/types/src/util/array.d.ts.map +1 -1
  177. package/dist/types/src/util/get-time-str.d.ts.map +1 -1
  178. package/dist/types/src/util/monitor-audio-level.d.ts.map +1 -1
  179. package/dist/types/src/util/render-byline.d.ts.map +1 -1
  180. package/dist/types/tsconfig.tsbuildinfo +1 -1
  181. package/package.json +136 -102
  182. package/src/TranscriptionPlugin.node.ts +20 -0
  183. package/src/TranscriptionPlugin.test.ts +31 -0
  184. package/src/TranscriptionPlugin.tsx +11 -31
  185. package/src/TranscriptionPlugin.workerd.ts +18 -0
  186. package/src/blueprints/transcription-blueprint.ts +3 -4
  187. package/src/capabilities/blueprint-definition.ts +6 -4
  188. package/src/capabilities/index.ts +9 -2
  189. package/src/capabilities/operation-handler.ts +1 -1
  190. package/src/capabilities/react-surface.tsx +2 -2
  191. package/src/capabilities/text-content.ts +33 -0
  192. package/src/capabilities/transcriber.ts +9 -5
  193. package/src/components/Oracle/Oracle.stories.tsx +147 -0
  194. package/src/components/Oracle/Oracle.tsx +142 -0
  195. package/src/components/Oracle/index.ts +5 -0
  196. package/src/components/Transcription/Transcription.stories.tsx +117 -153
  197. package/src/components/Transcription/Transcription.tsx +8 -17
  198. package/src/components/index.ts +1 -0
  199. package/src/containers/TranscriptionArticle/TranscriptionArticle.stories.tsx +61 -0
  200. package/src/containers/TranscriptionArticle/TranscriptionArticle.tsx +62 -0
  201. package/src/containers/TranscriptionArticle/index.ts +5 -0
  202. package/src/containers/index.ts +1 -1
  203. package/src/enrichment/conversation.test.ts +162 -0
  204. package/src/enrichment/conversation.txt +23 -0
  205. package/src/enrichment/operations.ts +271 -0
  206. package/src/enrichment/parser.ts +101 -0
  207. package/src/enrichment/stream-simulator.ts +125 -0
  208. package/src/hooks/index.ts +2 -1
  209. package/src/hooks/useAudioTrack.ts +1 -1
  210. package/src/hooks/useFeedModelAdapter.ts +46 -0
  211. package/src/hooks/useTranscriber.ts +7 -5
  212. package/src/hooks/useTranscriptionRecording.ts +87 -0
  213. package/src/hooks/useVoiceInput.ts +1 -1
  214. package/src/index.ts +4 -5
  215. package/src/meta.ts +28 -6
  216. package/src/model/model.test.ts +5 -5
  217. package/src/model/model.ts +3 -3
  218. package/src/{segments-normalization → normalization}/message-normalizer.ts +25 -17
  219. package/src/{segments-normalization → normalization}/normalization.test.ts +4 -38
  220. package/src/{segments-normalization → normalization}/normalization.ts +8 -9
  221. package/src/operations/create.ts +3 -3
  222. package/src/operations/index.ts +1 -3
  223. package/src/operations/open.ts +3 -3
  224. package/src/operations/summarize.ts +7 -7
  225. package/src/plugin.ts +11 -0
  226. package/src/stories/FileTranscription.stories.tsx +143 -0
  227. package/src/{components/stories → stories}/KeyWordRecognition.stories.tsx +36 -36
  228. package/src/stories/LiveTranscription.stories.tsx +153 -0
  229. package/src/stories/TranscriptionStory.tsx +101 -0
  230. package/src/stories/common.ts +233 -0
  231. package/src/testing/testing.ts +22 -34
  232. package/src/transcriber/index.ts +1 -1
  233. package/src/transcriber/transcriber.test.ts +104 -0
  234. package/src/transcriber/transcriber.ts +100 -55
  235. package/src/transcriber/transcription-manager.ts +14 -9
  236. package/src/translations.ts +3 -0
  237. package/src/{operations/definitions.ts → types/TranscriptOperation.ts} +14 -9
  238. package/src/types/TranscriptionCapabilities.ts +39 -0
  239. package/src/types/index.ts +2 -2
  240. package/src/vite-env.d.ts +10 -0
  241. package/dist/lib/browser/blueprints/index.mjs.map +0 -7
  242. package/dist/lib/browser/chunk-5LWSJZTZ.mjs +0 -17
  243. package/dist/lib/browser/chunk-5LWSJZTZ.mjs.map +0 -7
  244. package/dist/lib/browser/chunk-KOX4WNAR.mjs.map +0 -7
  245. package/dist/lib/browser/create-BTWYQ6IM.mjs.map +0 -7
  246. package/dist/lib/browser/index.mjs +0 -1213
  247. package/dist/lib/browser/index.mjs.map +0 -7
  248. package/dist/lib/browser/meta.json +0 -1
  249. package/dist/lib/browser/open-CYRYIEZI.mjs.map +0 -7
  250. package/dist/lib/browser/operations/index.mjs +0 -13
  251. package/dist/lib/browser/operations/index.mjs.map +0 -7
  252. package/dist/lib/browser/summarize-X2ZYTN7S.mjs.map +0 -7
  253. package/dist/lib/browser/types/index.mjs +0 -10
  254. package/dist/lib/node-esm/blueprints/index.mjs +0 -32
  255. package/dist/lib/node-esm/blueprints/index.mjs.map +0 -7
  256. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
  257. package/dist/lib/node-esm/chunk-MT5I4NH5.mjs +0 -112
  258. package/dist/lib/node-esm/chunk-MT5I4NH5.mjs.map +0 -7
  259. package/dist/lib/node-esm/chunk-NVM2QUMX.mjs +0 -37
  260. package/dist/lib/node-esm/chunk-NVM2QUMX.mjs.map +0 -7
  261. package/dist/lib/node-esm/chunk-X74WYCCE.mjs +0 -19
  262. package/dist/lib/node-esm/chunk-X74WYCCE.mjs.map +0 -7
  263. package/dist/lib/node-esm/create-MLUFPST2.mjs +0 -22
  264. package/dist/lib/node-esm/create-MLUFPST2.mjs.map +0 -7
  265. package/dist/lib/node-esm/index.mjs +0 -1214
  266. package/dist/lib/node-esm/index.mjs.map +0 -7
  267. package/dist/lib/node-esm/meta.json +0 -1
  268. package/dist/lib/node-esm/open-5IOC2U4Z.mjs +0 -28
  269. package/dist/lib/node-esm/open-5IOC2U4Z.mjs.map +0 -7
  270. package/dist/lib/node-esm/operations/index.mjs +0 -14
  271. package/dist/lib/node-esm/operations/index.mjs.map +0 -7
  272. package/dist/lib/node-esm/summarize-IORITU7T.mjs +0 -80
  273. package/dist/lib/node-esm/summarize-IORITU7T.mjs.map +0 -7
  274. package/dist/lib/node-esm/types/index.mjs +0 -11
  275. package/dist/types/src/components/stories/FileTranscription.stories.d.ts +0 -18
  276. package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +0 -1
  277. package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts.map +0 -1
  278. package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +0 -1
  279. package/dist/types/src/components/stories/TranscriptionStory.d.ts +0 -12
  280. package/dist/types/src/components/stories/TranscriptionStory.d.ts.map +0 -1
  281. package/dist/types/src/components/stories/useIsSpeaking.d.ts +0 -3
  282. package/dist/types/src/components/stories/useIsSpeaking.d.ts.map +0 -1
  283. package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts +0 -6
  284. package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts.map +0 -1
  285. package/dist/types/src/containers/TranscriptionContainer/index.d.ts +0 -2
  286. package/dist/types/src/containers/TranscriptionContainer/index.d.ts.map +0 -1
  287. package/dist/types/src/hooks/useQueueModelAdapter.d.ts +0 -8
  288. package/dist/types/src/hooks/useQueueModelAdapter.d.ts.map +0 -1
  289. package/dist/types/src/operations/definitions.d.ts.map +0 -1
  290. package/dist/types/src/segments-normalization/index.d.ts.map +0 -1
  291. package/dist/types/src/segments-normalization/message-normalizer.d.ts.map +0 -1
  292. package/dist/types/src/segments-normalization/normalization.d.ts +0 -364
  293. package/dist/types/src/segments-normalization/normalization.d.ts.map +0 -1
  294. package/dist/types/src/segments-normalization/normalization.test.d.ts.map +0 -1
  295. package/dist/types/src/segments-normalization/utils.d.ts.map +0 -1
  296. package/dist/types/src/types/capabilities.d.ts +0 -18
  297. package/dist/types/src/types/capabilities.d.ts.map +0 -1
  298. package/dist/types/src/types/types.d.ts +0 -5
  299. package/dist/types/src/types/types.d.ts.map +0 -1
  300. package/src/components/stories/FileTranscription.stories.tsx +0 -250
  301. package/src/components/stories/MicrophoneTranscription.stories.tsx +0 -264
  302. package/src/components/stories/TranscriptionStory.tsx +0 -43
  303. package/src/components/stories/useIsSpeaking.tsx +0 -40
  304. package/src/containers/TranscriptionContainer/TranscriptionContainer.tsx +0 -35
  305. package/src/containers/TranscriptionContainer/index.ts +0 -5
  306. package/src/hooks/useQueueModelAdapter.ts +0 -66
  307. package/src/types/capabilities.ts +0 -34
  308. package/src/types/types.ts +0 -9
  309. package/dist/lib/{browser/types → neutral/blueprints}/index.mjs.map +0 -0
  310. package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
  311. package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
  312. package/dist/lib/{browser/chunk-HOOPZ7EM.mjs.map → neutral/chunk-KAEXRX3Y.mjs.map} +0 -0
  313. package/dist/lib/{node-esm/types → neutral/hooks}/index.mjs.map +0 -0
  314. package/dist/lib/{node-esm/chunk-HSLMI22Q.mjs.map → neutral/index.mjs.map} +0 -0
  315. package/dist/types/src/{segments-normalization → normalization}/normalization.test.d.ts +0 -0
  316. package/dist/types/src/{segments-normalization → normalization}/utils.d.ts +0 -0
  317. package/dist/types/src/{components/stories → stories}/KeyWordRecognition.stories.d.ts +0 -0
  318. package/src/{segments-normalization → normalization}/index.ts +1 -1
  319. /package/src/{segments-normalization → normalization}/utils.ts +0 -0
@@ -4,18 +4,12 @@
4
4
 
5
5
  import { describe, test } from 'vitest';
6
6
 
7
- import { scheduleTaskInterval } from '@dxos/async';
8
- import { Context } from '@dxos/context';
9
7
  import { Obj } from '@dxos/echo';
10
- import { MemoryQueue } from '@dxos/echo-db';
11
- import { createQueueDXN } from '@dxos/echo/internal';
12
8
  import { FunctionExecutor, ServiceContainer } from '@dxos/functions-runtime';
13
9
  import { log } from '@dxos/log';
14
10
  import { type Actor, Message } from '@dxos/types';
15
11
 
16
- import { MessageNormalizer } from './message-normalizer';
17
12
  import { type MessageWithRangeId, sentenceNormalization } from './normalization';
18
- import { getActorId } from './utils';
19
13
 
20
14
  const sender: Actor.Actor = {
21
15
  identityDid: 'did:key:123',
@@ -65,7 +59,7 @@ describe.skip('SentenceNormalization', () => {
65
59
  // ? new Edge AiServiceClient({
66
60
  // endpoint: AI_SERVICE_ENDPOINT.REMOTE,
67
61
  // defaultGenerationOptions: {
68
- // model: '@anthropic/claude-3-5-sonnet-20241022',
62
+ // model: 'ai.claude.model.claude-3-5-sonnet-20241022',
69
63
  // },
70
64
  // })
71
65
  // : new Ollama AiServiceClient({
@@ -104,35 +98,7 @@ describe.skip('SentenceNormalization', () => {
104
98
  throw new Error('test');
105
99
  });
106
100
 
107
- test.only('queue', { timeout: 120_000 }, async () => {
108
- // Create queue.
109
- // TODO(dmaretskyi): Use space.queues.create() instead.
110
- const queue = new MemoryQueue<Message.Message>(createQueueDXN());
111
- const ctx = new Context();
112
- let idx = 0;
113
- scheduleTaskInterval(
114
- ctx,
115
- async () => {
116
- if (idx >= messages.length) {
117
- void ctx.dispose();
118
- return;
119
- }
120
- await queue.append([messages[idx]]);
121
- idx++;
122
- },
123
- 2_000,
124
- );
125
-
126
- // Create normalizer.
127
- const normalizer = new MessageNormalizer({
128
- functionExecutor: getExecutor(),
129
- queue,
130
- startingCursor: { actorId: getActorId(sender), timestamp: '0' },
131
- });
132
-
133
- // Start normalizer.
134
- await normalizer.open();
135
-
136
- await new Promise(() => {});
137
- });
101
+ // TODO(burdon): Restore a Feed-based version once `MessageNormalizer` has a
102
+ // space-backed test fixture available; the previous `MemoryQueue`-based
103
+ // test was incompatible with the `Feed.Feed` + `FeedService` refactor.
138
104
  });
@@ -5,16 +5,15 @@
5
5
  import * as Effect from 'effect/Effect';
6
6
  import * as Schema from 'effect/Schema';
7
7
 
8
+ import { Operation } from '@dxos/compute';
8
9
  import { log } from '@dxos/log';
9
- import { Operation } from '@dxos/operation';
10
10
  import { trim } from '@dxos/util';
11
11
 
12
- import {
13
- SentenceNormalization,
14
- SentenceNormalizationOutput,
15
- type MessageWithRangeIdType,
16
- type SentenceNormalizationInputType,
17
- } from '../operations/definitions';
12
+ import { TranscriptOperation } from '../types';
13
+
14
+ type MessageWithRangeIdType = TranscriptOperation.MessageWithRangeIdType;
15
+ type SentenceNormalizationInputType = TranscriptOperation.SentenceNormalizationInputType;
16
+ const { SentenceNormalization, SentenceNormalizationOutput } = TranscriptOperation;
18
17
 
19
18
  export type MessageWithRangeId = MessageWithRangeIdType;
20
19
 
@@ -35,14 +34,14 @@ export const sentenceNormalization = SentenceNormalization.pipe(
35
34
  // TODO(dmaretskyi): runStructured was removed from AiRequest. Reimplement using new API.
36
35
  return yield* Effect.die(
37
36
  new Error(
38
- 'Sentence normalization needs to be reimplemented - runStructured was removed from AiRequest. Use AiRequest.run or LanguageModel.generateObject.',
37
+ 'Sentence normalization needs to be reimplemented - runStructured was removed from AiRequest.Request. Use AiRequest.run or LanguageModel.generateObject.',
39
38
  ),
40
39
  );
41
40
  }),
42
41
  ),
43
42
  );
44
43
 
45
- const _unusedPrompt = trim`
44
+ const _unused = trim`
46
45
  You are observing a real-time transcript of a single person speaking.
47
46
  The transcription is delivered in chunks of 10 seconds or less. As a result, individual sentences may be split across multiple messages, or multiple sentences may appear within a single message. Additionally, because this is real-time transcription, punctuation and capitalization may be incorrect or missing.
48
47
 
@@ -4,13 +4,13 @@
4
4
 
5
5
  import * as Effect from 'effect/Effect';
6
6
 
7
+ import { Operation } from '@dxos/compute';
7
8
  import { Feed, Ref } from '@dxos/echo';
8
- import { Operation } from '@dxos/operation';
9
9
  import { Transcript } from '@dxos/types';
10
10
 
11
- import { Create } from './definitions';
11
+ import { TranscriptOperation } from '../types';
12
12
 
13
- const handler: Operation.WithHandler<typeof Create> = Create.pipe(
13
+ const handler: Operation.WithHandler<typeof TranscriptOperation.Create> = TranscriptOperation.Create.pipe(
14
14
  Operation.withHandler(
15
15
  Effect.fn(function* ({ space }) {
16
16
  const feed = space.db.add(Feed.make());
@@ -2,9 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { OperationHandlerSet } from '@dxos/operation';
6
-
7
- export * as TranscriptOperation from './definitions';
5
+ import { OperationHandlerSet } from '@dxos/compute';
8
6
 
9
7
  export const TranscriptionOperationHandlerSet = OperationHandlerSet.lazy(
10
8
  () => import('./create'),
@@ -4,14 +4,14 @@
4
4
 
5
5
  import * as Effect from 'effect/Effect';
6
6
 
7
+ import { Operation } from '@dxos/compute';
7
8
  import { Database, Feed, Filter } from '@dxos/echo';
8
- import { Operation } from '@dxos/operation';
9
9
  import { Message } from '@dxos/types';
10
10
 
11
+ import { TranscriptOperation } from '../types';
11
12
  import { renderByline } from '../util';
12
- import { Open } from './definitions';
13
13
 
14
- const handler: Operation.WithHandler<typeof Open> = Open.pipe(
14
+ const handler: Operation.WithHandler<typeof TranscriptOperation.Open> = TranscriptOperation.Open.pipe(
15
15
  Operation.withHandler(
16
16
  Effect.fn(function* ({ transcript }) {
17
17
  const transcriptObj = yield* Database.load(transcript);
@@ -10,21 +10,21 @@ import * as Option from 'effect/Option';
10
10
 
11
11
  import { AiService, ConsolePrinter, ToolExecutionService, ToolResolverService } from '@dxos/ai';
12
12
  import { AiRequest, GenerationObserver } from '@dxos/assistant';
13
+ import { Trace, Operation } from '@dxos/compute';
13
14
  import { Database } from '@dxos/echo';
14
- import * as Trace from '@dxos/functions/Trace';
15
- import { Operation, OperationRegistry } from '@dxos/operation';
15
+ import { registryLayerNoop } from '@dxos/echo/testing';
16
16
  import { trim } from '@dxos/util';
17
17
 
18
- import { Summarize } from './definitions';
18
+ import { TranscriptOperation } from '../types';
19
19
 
20
20
  /**
21
21
  * Summarize a transcript of a meeting.
22
22
  */
23
- const handler: Operation.WithHandler<typeof Summarize> = Summarize.pipe(
23
+ const handler: Operation.WithHandler<typeof TranscriptOperation.Summarize> = TranscriptOperation.Summarize.pipe(
24
24
  Operation.withHandler(
25
25
  Effect.fnUntraced(
26
26
  function* ({ transcript, notes }) {
27
- const result = yield* new AiRequest({
27
+ const result = yield* new AiRequest.Request({
28
28
  observer: GenerationObserver.fromPrinter(new ConsolePrinter({ tag: 'summarize' })),
29
29
  }).run({
30
30
  prompt: `Transcript: ${transcript}\n\nNotes: ${notes}`,
@@ -49,7 +49,7 @@ const handler: Operation.WithHandler<typeof Summarize> = Summarize.pipe(
49
49
  },
50
50
  Effect.provide(
51
51
  Layer.mergeAll(
52
- AiService.model('@anthropic/claude-sonnet-4-0'),
52
+ AiService.model('ai.claude.model.claude-sonnet-4-0'),
53
53
  ToolResolverService.layerEmpty,
54
54
  ToolExecutionService.layerEmpty,
55
55
  Trace.writerLayerNoop,
@@ -59,7 +59,7 @@ const handler: Operation.WithHandler<typeof Summarize> = Summarize.pipe(
59
59
  schedule: () => Effect.die('Not available.'),
60
60
  invokePromise: async () => ({ error: new Error('Not available.') }),
61
61
  } as any),
62
- Layer.succeed(OperationRegistry.Service, { resolve: () => Effect.succeed(undefined) } as any),
62
+ registryLayerNoop,
63
63
  ),
64
64
  ),
65
65
  ),
package/src/plugin.ts ADDED
@@ -0,0 +1,11 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Plugin } from '@dxos/app-framework';
6
+
7
+ import { meta } from './meta';
8
+
9
+ export const TranscriptionPlugin = Plugin.lazy(meta, () => import('#plugin'));
10
+
11
+ export { TranscriptionOperationHandlerSet } from './operations';
@@ -0,0 +1,143 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
7
+
8
+ import { useAudioFile } from '#hooks';
9
+
10
+ import { type MediaStreamRecorderProps, type TranscriberProps } from '../transcriber';
11
+ import {
12
+ useIsSpeaking,
13
+ createStoryDecorators,
14
+ useStoryAppendSegments,
15
+ useStoryMessageModel,
16
+ useStoryTranscriber,
17
+ } from './common';
18
+ import { TranscriptionStory } from './TranscriptionStory';
19
+
20
+ const DEFAULT_TRANSCRIBER_CONFIG = {
21
+ transcribeAfterChunksAmount: 100,
22
+ prefixBufferChunksAmount: 50,
23
+ normalizeSentences: true,
24
+ };
25
+
26
+ const DEFAULT_RECORDER_CONFIG = {
27
+ interval: 200,
28
+ };
29
+
30
+ type DefaultStoryProps = {
31
+ detectSpeaking?: boolean;
32
+ normalizeSentences?: boolean;
33
+ audioUrl: string;
34
+ transcriberConfig?: TranscriberProps['config'];
35
+ recorderConfig?: MediaStreamRecorderProps['config'];
36
+ audioConstraints?: MediaTrackConstraints;
37
+ };
38
+
39
+ const DefaultStory = ({
40
+ detectSpeaking,
41
+ audioUrl,
42
+ normalizeSentences,
43
+ transcriberConfig = DEFAULT_TRANSCRIBER_CONFIG,
44
+ recorderConfig = DEFAULT_RECORDER_CONFIG,
45
+ audioConstraints,
46
+ }: DefaultStoryProps) => {
47
+ const [running, setRunning] = useState(false);
48
+
49
+ // Optional uploaded file overrides the default URL; revoke the previous URL on change/unmount.
50
+ const [uploadedUrl, setUploadedUrl] = useState<string>();
51
+ useEffect(() => {
52
+ return () => {
53
+ if (uploadedUrl) {
54
+ URL.revokeObjectURL(uploadedUrl);
55
+ }
56
+ };
57
+ }, [uploadedUrl]);
58
+
59
+ const handleUpload = useCallback((file: File) => {
60
+ setRunning(false);
61
+ setUploadedUrl(URL.createObjectURL(file));
62
+ }, []);
63
+
64
+ const sourceUrl = uploadedUrl ?? audioUrl;
65
+ const { audio, track, stream } = useAudioFile(sourceUrl, audioConstraints);
66
+ const isSpeaking = detectSpeaking ? useIsSpeaking(track) : true;
67
+
68
+ // Pipe the decoded stream into the <audio> element so the user hears playback.
69
+ const ref = useRef<HTMLAudioElement>(null);
70
+ useEffect(() => {
71
+ if (ref.current && stream) {
72
+ ref.current.srcObject = stream;
73
+ }
74
+ }, [stream]);
75
+
76
+ // Mirror the toolbar's running flag to the underlying HTMLAudioElement.
77
+ useEffect(() => {
78
+ if (!audio) {
79
+ return;
80
+ }
81
+
82
+ if (running) {
83
+ void audio.play();
84
+ } else {
85
+ void audio.pause();
86
+ }
87
+ }, [audio, running]);
88
+
89
+ const { model, appendMessage } = useStoryMessageModel();
90
+ const handleSegments = useStoryAppendSegments(appendMessage);
91
+
92
+ useStoryTranscriber({
93
+ audioStreamTrack: track,
94
+ running,
95
+ isSpeaking,
96
+ transcriberConfig,
97
+ recorderConfig,
98
+ onSegments: handleSegments,
99
+ });
100
+
101
+ // TODO(burdon): Sentence normalization moved to require a real space-backed Feed + FeedService runtime.
102
+ // Re-enable here once the story has access to one.
103
+ void normalizeSentences;
104
+
105
+ return (
106
+ <TranscriptionStory
107
+ audioRef={ref}
108
+ disabled={!stream}
109
+ model={model}
110
+ running={running}
111
+ onRunningChange={setRunning}
112
+ onUpload={handleUpload}
113
+ />
114
+ );
115
+ };
116
+
117
+ const meta = {
118
+ title: 'plugins/plugin-transcription/stories/FileTranscription',
119
+ render: DefaultStory,
120
+ decorators: createStoryDecorators(),
121
+ } satisfies Meta<DefaultStoryProps>;
122
+
123
+ export default meta;
124
+
125
+ type Story = StoryObj<typeof meta>;
126
+
127
+ export const Default: Story = {
128
+ args: {
129
+ detectSpeaking: true,
130
+ // https://learnenglish.britishcouncil.org/general-english/audio-zone/living-london
131
+ audioUrl: 'https://dxos.network/audio-london.m4a',
132
+ // textUrl: 'https://dxos.network/audio-london.txt',
133
+ },
134
+ };
135
+
136
+ // TODO(mykola): Fix sentence normalization.
137
+ // export const WithSentenceNormalization: StoryObj<typeof AudioFile> = {
138
+ // args: {
139
+ // detectSpeaking: true,
140
+ // normalizeSentences: true,
141
+ // audioUrl: 'https://dxos.network/audio-london.m4a',
142
+ // },
143
+ // };
@@ -6,7 +6,7 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
  import React, { useEffect, useMemo, useState } from 'react';
7
7
 
8
8
  import { log } from '@dxos/log';
9
- import { Toolbar } from '@dxos/react-ui';
9
+ import { Panel, Toolbar } from '@dxos/react-ui';
10
10
  import { withLayout, withTheme } from '@dxos/react-ui/testing';
11
11
  import { mx } from '@dxos/ui-theme';
12
12
 
@@ -23,7 +23,6 @@ const DefaultStory = ({ keywords }: DefaultStoryProps) => {
23
23
  const [running, setRunning] = useState(false);
24
24
  const [matchingWords, setMatchingWords] = useState<Word[]>(keywords.map((word) => ({ text: word, matched: false })));
25
25
 
26
- const [transcript, setTranscript] = useState('');
27
26
  const recognition = useMemo(() => {
28
27
  // TODO(mykola): Fix types
29
28
  const SpeechRecognition = (window as any).SpeechRecognition || (window as any).webkitSpeechRecognition;
@@ -38,16 +37,16 @@ const DefaultStory = ({ keywords }: DefaultStoryProps) => {
38
37
  recognition.interimResults = true;
39
38
  recognition.lang = 'en-US';
40
39
  recognition.maxAlternatives = 1;
41
- // Add this line to enable punctuation
40
+ // Add this line to enable punctuation.
42
41
  recognition.grammars = new SpeechGrammarList();
43
42
 
44
- // TODO(mykola): Fix types
43
+ // TODO(mykola): Fix types.
45
44
  recognition.onresult = (event: any) => {
46
45
  log.info('recognition result', { event });
47
46
  const current = event.resultIndex;
48
47
  const transcript = event.results[current][0].transcript;
49
48
 
50
- // Remove punctuation and normalize whitespace for comparison
49
+ // Remove punctuation and normalize whitespace for comparison.
51
50
  const normalizeText = (text: string) =>
52
51
  text
53
52
  .toLowerCase()
@@ -57,7 +56,7 @@ const DefaultStory = ({ keywords }: DefaultStoryProps) => {
57
56
 
58
57
  const normalizedTranscript = normalizeText(transcript);
59
58
 
60
- // Check each keyword and update matching words
59
+ // Check each keyword and update matching words.
61
60
  const updatedWords = matchingWords.map((word) => {
62
61
  const normalizedKeyword = normalizeText(word.text);
63
62
  const matched = normalizedTranscript.includes(normalizedKeyword);
@@ -65,10 +64,9 @@ const DefaultStory = ({ keywords }: DefaultStoryProps) => {
65
64
  });
66
65
 
67
66
  setMatchingWords(updatedWords);
68
- setTranscript(transcript);
69
67
  };
70
68
 
71
- // TODO(mykola): Fix types
69
+ // TODO(mykola): Fix types.
72
70
  recognition.onerror = (event: any) => {
73
71
  log.error('Speech recognition error:', { error: event.error });
74
72
  setRunning(false);
@@ -86,37 +84,39 @@ const DefaultStory = ({ keywords }: DefaultStoryProps) => {
86
84
  }, [running, recognition]);
87
85
 
88
86
  return (
89
- <div className={mx('flex flex-col gap-2 w-[30rem]')}>
90
- <Toolbar.Root>
91
- <Toolbar.IconButton
92
- iconOnly
93
- icon={running ? 'ph--pause--regular' : 'ph--play--regular'}
94
- label={running ? 'Pause' : 'Play'}
95
- onClick={() => setRunning((running) => !running)}
96
- />
97
- </Toolbar.Root>
98
-
99
- <div className='flex flex-wrap'>
100
- {matchingWords.map((word, index) => (
101
- <span
102
- key={index}
103
- className={mx(
104
- 'px-3 py-1 m-2 rounded-sm border',
105
- word.matched ? 'bg-red-200 text-red-800 border-red-300' : 'bg-gray-200 text-gray-600 border-gray-300',
106
- )}
107
- >
108
- {word.text}
109
- </span>
110
- ))}
111
- </div>
112
-
113
- <span>{transcript || (running ? 'Listening...' : 'Click play to start speech recognition')}</span>
114
- </div>
87
+ <Panel.Root>
88
+ <Panel.Toolbar asChild>
89
+ <Toolbar.Root>
90
+ <Toolbar.IconButton
91
+ iconOnly
92
+ icon={running ? 'ph--pause--regular' : 'ph--play--regular'}
93
+ label={running ? 'Pause' : 'Play'}
94
+ onClick={() => setRunning((running) => !running)}
95
+ />
96
+ </Toolbar.Root>
97
+ </Panel.Toolbar>
98
+
99
+ <Panel.Content>
100
+ <div className='p-2 grid grid-cols-[repeat(auto-fill,minmax(6rem,1fr))] gap-2'>
101
+ {matchingWords.map((word, index) => (
102
+ <span
103
+ key={index}
104
+ className={mx(
105
+ 'grid place-items-center p-2 aspect-square rounded-sm border border-separator',
106
+ word.matched && 'border-red-300',
107
+ )}
108
+ >
109
+ {word.text}
110
+ </span>
111
+ ))}
112
+ </div>
113
+ </Panel.Content>
114
+ </Panel.Root>
115
115
  );
116
116
  };
117
117
 
118
118
  const meta = {
119
- title: 'plugins/plugin-transcription/components/KeyWordDetection',
119
+ title: 'plugins/plugin-transcription/stories/KeyWordDetection',
120
120
  render: DefaultStory,
121
121
  decorators: [withTheme(), withLayout({ layout: 'column' })],
122
122
  } satisfies Meta<typeof DefaultStory>;
@@ -127,6 +127,6 @@ type Story = StoryObj<typeof meta>;
127
127
 
128
128
  export const SpeechRecognitionAPI: Story = {
129
129
  args: {
130
- keywords: ['kai', 'computer', 'hello'],
130
+ keywords: ['kai', 'computer', 'hello', 'dxos'],
131
131
  },
132
132
  };
@@ -0,0 +1,153 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
+ import React, { useCallback, useMemo, useState } from 'react';
7
+
8
+ import {
9
+ type ExtractionFunction,
10
+ extractionAnthropicFunction,
11
+ extractionNerFunction,
12
+ getNer,
13
+ processTranscriptMessage,
14
+ } from '@dxos/assistant/extraction';
15
+ import { Filter, type Obj } from '@dxos/echo';
16
+ import { invariant } from '@dxos/invariant';
17
+ import { useSpaces } from '@dxos/react-client/echo';
18
+ import { Message, Organization, Person } from '@dxos/types';
19
+
20
+ import { useAudioTrack } from '#hooks';
21
+
22
+ import { type MediaStreamRecorderProps, type TranscriberProps } from '../transcriber';
23
+ import { useIsSpeaking, createStoryDecorators, useStoryMessageModel, useStoryTranscriber } from './common';
24
+ import { TranscriptionStory } from './TranscriptionStory';
25
+
26
+ const DEFAULT_TRANSCRIBER_CONFIG = {
27
+ transcribeAfterChunksAmount: 50,
28
+ prefixBufferChunksAmount: 10,
29
+ };
30
+
31
+ const DEFAULT_RECORDER_CONFIG = {
32
+ interval: 200,
33
+ };
34
+
35
+ type DefaultStoryProps = {
36
+ detectSpeaking?: boolean;
37
+ transcriberConfig?: TranscriberProps['config'];
38
+ recorderConfig?: MediaStreamRecorderProps['config'];
39
+ audioConstraints?: MediaTrackConstraints;
40
+ entityExtraction?: 'ner' | 'llm';
41
+ };
42
+
43
+ const DefaultStory = ({
44
+ detectSpeaking,
45
+ entityExtraction,
46
+ transcriberConfig = DEFAULT_TRANSCRIBER_CONFIG,
47
+ recorderConfig = DEFAULT_RECORDER_CONFIG,
48
+ audioConstraints,
49
+ }: DefaultStoryProps) => {
50
+ const [running, setRunning] = useState(false);
51
+ const track = useAudioTrack(running, audioConstraints);
52
+ const isSpeaking = detectSpeaking ? useIsSpeaking(track) : true;
53
+ const { model, appendMessage } = useStoryMessageModel();
54
+ const [space] = useSpaces();
55
+
56
+ // Resolve the entity-extraction function + nearby objects once per `entityExtraction` toggle.
57
+ const { extractionFunction, objects } = useMemo(() => {
58
+ if (!space || !entityExtraction) {
59
+ return {};
60
+ }
61
+
62
+ let extractionFunction: ExtractionFunction | undefined;
63
+ let objects: Promise<Obj.Unknown[]> | undefined;
64
+ if (entityExtraction === 'ner') {
65
+ void getNer(); // Init model loading. Takes time.
66
+ extractionFunction = extractionNerFunction;
67
+ } else if (entityExtraction === 'llm') {
68
+ extractionFunction = extractionAnthropicFunction;
69
+ objects = space.db.query(Filter.or(Filter.type(Person.Person), Filter.type(Organization.Organization))).run();
70
+ }
71
+ return { extractionFunction, objects };
72
+ }, [entityExtraction, space]);
73
+
74
+ // Build a Message from each transcribed batch; optionally enrich via entity extraction.
75
+ const handleSegments = useCallback<TranscriberProps['onSegments']>(
76
+ async (blocks) => {
77
+ const message = Message.make({
78
+ sender: { name: 'You' },
79
+ created: new Date().toISOString(),
80
+ blocks,
81
+ });
82
+
83
+ if (entityExtraction && space) {
84
+ invariant(extractionFunction, 'extractionFunction is required');
85
+ const result = await processTranscriptMessage({
86
+ function: extractionFunction,
87
+ input: { message, objects: await objects },
88
+ options: { fallbackToRaw: true, timeout: 30_000 },
89
+ });
90
+ appendMessage(result.message);
91
+ } else {
92
+ appendMessage(message);
93
+ }
94
+ },
95
+ [appendMessage, space, entityExtraction, extractionFunction, objects],
96
+ );
97
+
98
+ useStoryTranscriber({
99
+ audioStreamTrack: track,
100
+ running,
101
+ isSpeaking,
102
+ transcriberConfig,
103
+ recorderConfig,
104
+ onSegments: handleSegments,
105
+ });
106
+
107
+ return <TranscriptionStory model={model} running={running} onRunningChange={setRunning} />;
108
+ };
109
+
110
+ const meta = {
111
+ title: 'plugins/plugin-transcription/stories/LiveTranscription',
112
+ render: DefaultStory,
113
+ decorators: createStoryDecorators({ enableVectorIndex: true }),
114
+ } satisfies Meta<typeof DefaultStory>;
115
+
116
+ export default meta;
117
+
118
+ type Story = StoryObj<typeof meta>;
119
+
120
+ export const Default: Story = {
121
+ args: {
122
+ detectSpeaking: false,
123
+ audioConstraints: {
124
+ echoCancellation: false,
125
+ noiseSuppression: false,
126
+ autoGainControl: false,
127
+ },
128
+ },
129
+ };
130
+
131
+ export const SpeechDetection: Story = {
132
+ args: {
133
+ detectSpeaking: true,
134
+ audioConstraints: {
135
+ echoCancellation: true,
136
+ noiseSuppression: true,
137
+ autoGainControl: true,
138
+ },
139
+ },
140
+ };
141
+
142
+ // TODO(mykola): Fix hugging face quota issues.
143
+ // export const EntityExtraction: Story = {
144
+ // args: {
145
+ // detectSpeaking: true,
146
+ // entityExtraction: 'ner',
147
+ // audioConstraints: {
148
+ // echoCancellation: true,
149
+ // noiseSuppression: true,
150
+ // autoGainControl: true,
151
+ // },
152
+ // },
153
+ // };