@omnimedia/omnitool 1.0.0 → 1.1.0-10

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 (324) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +120 -2
  3. package/package.json +59 -27
  4. package/s/_archive/types.ts +107 -0
  5. package/s/context.ts +7 -0
  6. package/s/demo/demo.bundle.ts +68 -0
  7. package/s/demo/demo.css +59 -0
  8. package/s/demo/routines/filmstrip-test.ts +68 -0
  9. package/s/demo/routines/load-video.ts +7 -0
  10. package/s/demo/routines/transcode-test.ts +46 -0
  11. package/s/demo/routines/transcriber-test.ts +34 -0
  12. package/s/demo/routines/transitions-test.ts +43 -0
  13. package/s/demo/routines/waveform-test.ts +12 -0
  14. package/s/driver/driver.test.ts +15 -0
  15. package/s/driver/driver.ts +124 -0
  16. package/s/driver/driver.worker.bundle.ts +7 -0
  17. package/s/driver/fns/host.ts +13 -0
  18. package/s/driver/fns/schematic.ts +106 -0
  19. package/s/driver/fns/work.ts +249 -0
  20. package/s/driver/parts/constants.ts +17 -0
  21. package/s/driver/parts/machina.ts +27 -0
  22. package/s/driver/utils/load-decoder-source.ts +12 -0
  23. package/s/driver/utils/sleep.ts +3 -0
  24. package/s/features/speech/transcribe/default-spec.ts +11 -0
  25. package/s/features/speech/transcribe/parts/load-pipe.ts +19 -0
  26. package/s/features/speech/transcribe/parts/prep-audio.ts +23 -0
  27. package/s/features/speech/transcribe/parts/transcribe.ts +70 -0
  28. package/s/features/speech/transcribe/transcriber.ts +46 -0
  29. package/s/features/speech/transcribe/types.ts +82 -0
  30. package/s/features/speech/transcribe/worker.bundle.ts +40 -0
  31. package/s/features/transition/parts/fragment.ts +24 -0
  32. package/s/features/transition/parts/types.ts +94 -0
  33. package/s/features/transition/parts/uniforms.ts +29 -0
  34. package/s/features/transition/parts/vertex.ts +31 -0
  35. package/s/features/transition/transition.ts +60 -0
  36. package/s/index.html.ts +58 -0
  37. package/s/index.ts +2 -39
  38. package/s/tests.test.ts +8 -0
  39. package/s/timeline/index.ts +15 -0
  40. package/s/timeline/parts/basics.ts +17 -0
  41. package/s/timeline/parts/compositor/export.ts +77 -0
  42. package/s/timeline/parts/compositor/parts/html-tree.ts +37 -0
  43. package/s/timeline/parts/compositor/parts/schedulers.ts +85 -0
  44. package/s/timeline/parts/compositor/parts/tree-builder.ts +184 -0
  45. package/s/timeline/parts/compositor/parts/webcodecs-tree.ts +30 -0
  46. package/s/timeline/parts/compositor/playback.ts +81 -0
  47. package/s/timeline/parts/compositor/samplers/html.ts +115 -0
  48. package/s/timeline/parts/compositor/samplers/webcodecs.ts +60 -0
  49. package/s/timeline/parts/filmstrip.ts +159 -0
  50. package/s/timeline/parts/item.ts +90 -0
  51. package/s/timeline/parts/media.ts +35 -0
  52. package/s/timeline/parts/resource-pool.ts +27 -0
  53. package/s/timeline/parts/resource.ts +11 -0
  54. package/s/timeline/parts/waveform.ts +62 -0
  55. package/s/timeline/sugar/builders.ts +102 -0
  56. package/s/timeline/sugar/o.ts +150 -0
  57. package/s/timeline/sugar/omni-test.ts +38 -0
  58. package/s/timeline/sugar/omni.ts +40 -0
  59. package/s/timeline/types.ts +29 -0
  60. package/s/timeline/utils/audio-stream.ts +15 -0
  61. package/s/timeline/utils/checksum.ts +20 -0
  62. package/s/timeline/utils/datafile.ts +21 -0
  63. package/s/timeline/utils/dummy-data.ts +7 -0
  64. package/s/timeline/utils/matrix.ts +33 -0
  65. package/s/timeline/utils/video-cursor.ts +40 -0
  66. package/s/tools/common/loader.ts +26 -0
  67. package/s/tools/common/transformer-pipeline.ts +26 -0
  68. package/s/tools/speech-recognition/common/model.ts +26 -0
  69. package/s/tools/speech-recognition/whisper/fns/host.ts +25 -0
  70. package/s/tools/speech-recognition/whisper/fns/schematic.ts +23 -0
  71. package/s/tools/speech-recognition/whisper/fns/work.ts +91 -0
  72. package/s/tools/speech-recognition/whisper/parts/types.ts +38 -0
  73. package/s/tools/speech-recognition/whisper/parts/worker.bundle.ts +7 -0
  74. package/s/tools/speech-recognition/whisper/tool.ts +70 -0
  75. package/x/context.d.ts +4 -0
  76. package/x/context.js +6 -0
  77. package/x/context.js.map +1 -0
  78. package/x/demo/demo.bundle.d.ts +1 -0
  79. package/x/demo/demo.bundle.js +55 -0
  80. package/x/demo/demo.bundle.js.map +1 -0
  81. package/x/demo/demo.bundle.min.js +120 -0
  82. package/x/demo/demo.bundle.min.js.map +7 -0
  83. package/x/demo/demo.css +59 -0
  84. package/x/demo/routines/filmstrip-test.d.ts +1 -0
  85. package/x/demo/routines/filmstrip-test.js +62 -0
  86. package/x/demo/routines/filmstrip-test.js.map +1 -0
  87. package/x/demo/routines/load-video.d.ts +1 -0
  88. package/x/demo/routines/load-video.js +6 -0
  89. package/x/demo/routines/load-video.js.map +1 -0
  90. package/x/demo/routines/transcode-test.d.ts +6 -0
  91. package/x/demo/routines/transcode-test.js +40 -0
  92. package/x/demo/routines/transcode-test.js.map +1 -0
  93. package/x/demo/routines/transcriber-test.d.ts +4 -0
  94. package/x/demo/routines/transcriber-test.js +33 -0
  95. package/x/demo/routines/transcriber-test.js.map +1 -0
  96. package/x/demo/routines/transitions-test.d.ts +5 -0
  97. package/x/demo/routines/transitions-test.js +35 -0
  98. package/x/demo/routines/transitions-test.js.map +1 -0
  99. package/x/demo/routines/waveform-test.d.ts +1 -0
  100. package/x/demo/routines/waveform-test.js +11 -0
  101. package/x/demo/routines/waveform-test.js.map +1 -0
  102. package/x/driver/driver.d.ts +20 -0
  103. package/x/driver/driver.js +104 -0
  104. package/x/driver/driver.js.map +1 -0
  105. package/x/driver/driver.test.d.ts +5 -0
  106. package/x/driver/driver.test.js +12 -0
  107. package/x/driver/driver.test.js.map +1 -0
  108. package/x/driver/driver.worker.bundle.d.ts +1 -0
  109. package/x/driver/driver.worker.bundle.js +4 -0
  110. package/x/driver/driver.worker.bundle.js.map +1 -0
  111. package/x/driver/driver.worker.bundle.min.js +3537 -0
  112. package/x/driver/driver.worker.bundle.min.js.map +7 -0
  113. package/x/driver/fns/host.d.ts +25 -0
  114. package/x/driver/fns/host.js +7 -0
  115. package/x/driver/fns/host.js.map +1 -0
  116. package/x/driver/fns/schematic.d.ts +84 -0
  117. package/x/driver/fns/schematic.js +2 -0
  118. package/x/driver/fns/schematic.js.map +1 -0
  119. package/x/driver/fns/work.d.ts +26 -0
  120. package/x/driver/fns/work.js +201 -0
  121. package/x/driver/fns/work.js.map +1 -0
  122. package/x/driver/parts/constants.d.ts +2 -0
  123. package/x/driver/parts/constants.js +17 -0
  124. package/x/driver/parts/constants.js.map +1 -0
  125. package/x/driver/parts/machina.d.ts +23 -0
  126. package/x/driver/parts/machina.js +14 -0
  127. package/x/driver/parts/machina.js.map +1 -0
  128. package/x/driver/utils/load-decoder-source.d.ts +3 -0
  129. package/x/driver/utils/load-decoder-source.js +11 -0
  130. package/x/driver/utils/load-decoder-source.js.map +1 -0
  131. package/x/driver/utils/sleep.d.ts +1 -0
  132. package/x/driver/utils/sleep.js +4 -0
  133. package/x/driver/utils/sleep.js.map +1 -0
  134. package/x/features/speech/transcribe/default-spec.d.ts +2 -0
  135. package/x/features/speech/transcribe/default-spec.js +8 -0
  136. package/x/features/speech/transcribe/default-spec.js.map +1 -0
  137. package/x/features/speech/transcribe/parts/load-pipe.d.ts +2 -0
  138. package/x/features/speech/transcribe/parts/load-pipe.js +13 -0
  139. package/x/features/speech/transcribe/parts/load-pipe.js.map +1 -0
  140. package/x/features/speech/transcribe/parts/prep-audio.d.ts +5 -0
  141. package/x/features/speech/transcribe/parts/prep-audio.js +21 -0
  142. package/x/features/speech/transcribe/parts/prep-audio.js.map +1 -0
  143. package/x/features/speech/transcribe/parts/transcribe.d.ts +5 -0
  144. package/x/features/speech/transcribe/parts/transcribe.js +56 -0
  145. package/x/features/speech/transcribe/parts/transcribe.js.map +1 -0
  146. package/x/features/speech/transcribe/transcriber.d.ts +5 -0
  147. package/x/features/speech/transcribe/transcriber.js +33 -0
  148. package/x/features/speech/transcribe/transcriber.js.map +1 -0
  149. package/x/features/speech/transcribe/types.d.ts +66 -0
  150. package/x/features/speech/transcribe/types.js.map +1 -0
  151. package/x/features/speech/transcribe/worker.bundle.d.ts +1 -0
  152. package/x/features/speech/transcribe/worker.bundle.js +33 -0
  153. package/x/features/speech/transcribe/worker.bundle.js.map +1 -0
  154. package/x/features/speech/transcribe/worker.bundle.min.js +2916 -0
  155. package/x/features/speech/transcribe/worker.bundle.min.js.map +7 -0
  156. package/x/features/transition/parts/fragment.d.ts +1 -0
  157. package/x/features/transition/parts/fragment.js +25 -0
  158. package/x/features/transition/parts/fragment.js.map +1 -0
  159. package/x/features/transition/parts/types.d.ts +23 -0
  160. package/x/features/transition/parts/types.js +2 -0
  161. package/x/features/transition/parts/types.js.map +1 -0
  162. package/x/features/transition/parts/uniforms.d.ts +31 -0
  163. package/x/features/transition/parts/uniforms.js +27 -0
  164. package/x/features/transition/parts/uniforms.js.map +1 -0
  165. package/x/features/transition/parts/vertex.d.ts +1 -0
  166. package/x/features/transition/parts/vertex.js +32 -0
  167. package/x/features/transition/parts/vertex.js.map +1 -0
  168. package/x/features/transition/transition.d.ts +5 -0
  169. package/x/features/transition/transition.js +50 -0
  170. package/x/features/transition/transition.js.map +1 -0
  171. package/x/index.d.ts +2 -9
  172. package/x/index.html +115 -0
  173. package/x/index.html.d.ts +2 -0
  174. package/x/index.html.js +52 -0
  175. package/x/index.html.js.map +1 -0
  176. package/x/index.js +2 -29
  177. package/x/index.js.map +1 -1
  178. package/x/tests.test.d.ts +1 -0
  179. package/x/tests.test.js +6 -0
  180. package/x/tests.test.js.map +1 -0
  181. package/x/timeline/index.d.ts +11 -0
  182. package/x/timeline/index.js +12 -0
  183. package/x/timeline/index.js.map +1 -0
  184. package/x/timeline/parts/basics.d.ts +12 -0
  185. package/x/timeline/parts/basics.js +2 -0
  186. package/x/timeline/parts/basics.js.map +1 -0
  187. package/x/timeline/parts/compositor/export.d.ts +9 -0
  188. package/x/timeline/parts/compositor/export.js +64 -0
  189. package/x/timeline/parts/compositor/export.js.map +1 -0
  190. package/x/timeline/parts/compositor/parts/html-tree.d.ts +3 -0
  191. package/x/timeline/parts/compositor/parts/html-tree.js +40 -0
  192. package/x/timeline/parts/compositor/parts/html-tree.js.map +1 -0
  193. package/x/timeline/parts/compositor/parts/schedulers.d.ts +15 -0
  194. package/x/timeline/parts/compositor/parts/schedulers.js +64 -0
  195. package/x/timeline/parts/compositor/parts/schedulers.js.map +1 -0
  196. package/x/timeline/parts/compositor/parts/tree-builder.d.ts +37 -0
  197. package/x/timeline/parts/compositor/parts/tree-builder.js +147 -0
  198. package/x/timeline/parts/compositor/parts/tree-builder.js.map +1 -0
  199. package/x/timeline/parts/compositor/parts/webcodecs-tree.d.ts +3 -0
  200. package/x/timeline/parts/compositor/parts/webcodecs-tree.js +28 -0
  201. package/x/timeline/parts/compositor/parts/webcodecs-tree.js.map +1 -0
  202. package/x/timeline/parts/compositor/playback.d.ts +19 -0
  203. package/x/timeline/parts/compositor/playback.js +71 -0
  204. package/x/timeline/parts/compositor/playback.js.map +1 -0
  205. package/x/timeline/parts/compositor/samplers/html.d.ts +3 -0
  206. package/x/timeline/parts/compositor/samplers/html.js +106 -0
  207. package/x/timeline/parts/compositor/samplers/html.js.map +1 -0
  208. package/x/timeline/parts/compositor/samplers/webcodecs.d.ts +2 -0
  209. package/x/timeline/parts/compositor/samplers/webcodecs.js +55 -0
  210. package/x/timeline/parts/compositor/samplers/webcodecs.js.map +1 -0
  211. package/x/timeline/parts/filmstrip.d.ts +39 -0
  212. package/x/timeline/parts/filmstrip.js +117 -0
  213. package/x/timeline/parts/filmstrip.js.map +1 -0
  214. package/x/timeline/parts/item.d.ts +68 -0
  215. package/x/timeline/parts/item.js +16 -0
  216. package/x/timeline/parts/item.js.map +1 -0
  217. package/x/timeline/parts/media.d.ts +10 -0
  218. package/x/timeline/parts/media.js +30 -0
  219. package/x/timeline/parts/media.js.map +1 -0
  220. package/x/timeline/parts/resource-pool.d.ts +7 -0
  221. package/x/timeline/parts/resource-pool.js +19 -0
  222. package/x/timeline/parts/resource-pool.js.map +1 -0
  223. package/x/timeline/parts/resource.d.ts +8 -0
  224. package/x/timeline/parts/resource.js +2 -0
  225. package/x/timeline/parts/resource.js.map +1 -0
  226. package/x/timeline/parts/waveform.d.ts +8 -0
  227. package/x/timeline/parts/waveform.js +51 -0
  228. package/x/timeline/parts/waveform.js.map +1 -0
  229. package/x/timeline/sugar/builders.d.ts +1 -0
  230. package/x/timeline/sugar/builders.js +104 -0
  231. package/x/timeline/sugar/builders.js.map +1 -0
  232. package/x/timeline/sugar/o.d.ts +32 -0
  233. package/x/timeline/sugar/o.js +114 -0
  234. package/x/timeline/sugar/o.js.map +1 -0
  235. package/x/timeline/sugar/omni-test.d.ts +1 -0
  236. package/x/timeline/sugar/omni-test.js +22 -0
  237. package/x/timeline/sugar/omni-test.js.map +1 -0
  238. package/x/timeline/sugar/omni.d.ts +14 -0
  239. package/x/timeline/sugar/omni.js +28 -0
  240. package/x/timeline/sugar/omni.js.map +1 -0
  241. package/x/timeline/types.d.ts +24 -0
  242. package/x/timeline/types.js +2 -0
  243. package/x/timeline/types.js.map +1 -0
  244. package/x/timeline/utils/audio-stream.d.ts +6 -0
  245. package/x/timeline/utils/audio-stream.js +17 -0
  246. package/x/timeline/utils/audio-stream.js.map +1 -0
  247. package/x/timeline/utils/checksum.d.ts +8 -0
  248. package/x/timeline/utils/checksum.js +21 -0
  249. package/x/timeline/utils/checksum.js.map +1 -0
  250. package/x/timeline/utils/datafile.d.ts +9 -0
  251. package/x/timeline/utils/datafile.js +20 -0
  252. package/x/timeline/utils/datafile.js.map +1 -0
  253. package/x/timeline/utils/dummy-data.d.ts +2 -0
  254. package/x/timeline/utils/dummy-data.js +3 -0
  255. package/x/timeline/utils/dummy-data.js.map +1 -0
  256. package/x/timeline/utils/matrix.d.ts +8 -0
  257. package/x/timeline/utils/matrix.js +26 -0
  258. package/x/timeline/utils/matrix.js.map +1 -0
  259. package/x/timeline/utils/video-cursor.d.ts +10 -0
  260. package/x/timeline/utils/video-cursor.js +36 -0
  261. package/x/timeline/utils/video-cursor.js.map +1 -0
  262. package/x/tools/common/loader.d.ts +19 -0
  263. package/x/tools/common/loader.js +18 -0
  264. package/x/tools/common/loader.js.map +1 -0
  265. package/x/tools/common/transformer-pipeline.d.ts +8 -0
  266. package/x/tools/common/transformer-pipeline.js +24 -0
  267. package/x/tools/common/transformer-pipeline.js.map +1 -0
  268. package/x/tools/speech-recognition/common/model.d.ts +14 -0
  269. package/x/tools/speech-recognition/common/model.js +16 -0
  270. package/x/tools/speech-recognition/common/model.js.map +1 -0
  271. package/x/tools/speech-recognition/whisper/fns/host.d.ts +13 -0
  272. package/x/tools/speech-recognition/whisper/fns/host.js +19 -0
  273. package/x/tools/speech-recognition/whisper/fns/host.js.map +1 -0
  274. package/x/tools/speech-recognition/whisper/fns/schematic.d.ts +19 -0
  275. package/x/tools/speech-recognition/whisper/fns/schematic.js +2 -0
  276. package/x/tools/speech-recognition/whisper/fns/schematic.js.map +1 -0
  277. package/x/tools/speech-recognition/whisper/fns/work.d.ts +12 -0
  278. package/x/tools/speech-recognition/whisper/fns/work.js +74 -0
  279. package/x/tools/speech-recognition/whisper/fns/work.js.map +1 -0
  280. package/x/tools/speech-recognition/whisper/parts/types.d.ts +31 -0
  281. package/x/tools/speech-recognition/whisper/parts/types.js +2 -0
  282. package/x/tools/speech-recognition/whisper/parts/types.js.map +1 -0
  283. package/x/tools/speech-recognition/whisper/parts/worker.bundle.d.ts +1 -0
  284. package/x/tools/speech-recognition/whisper/parts/worker.bundle.js +4 -0
  285. package/x/tools/speech-recognition/whisper/parts/worker.bundle.js.map +1 -0
  286. package/x/tools/speech-recognition/whisper/parts/worker.bundle.min.js +8 -0
  287. package/x/tools/speech-recognition/whisper/parts/worker.bundle.min.js.map +7 -0
  288. package/x/tools/speech-recognition/whisper/tool.d.ts +12 -0
  289. package/x/tools/speech-recognition/whisper/tool.js +63 -0
  290. package/x/tools/speech-recognition/whisper/tool.js.map +1 -0
  291. package/s/parts/compositor.ts +0 -5
  292. package/s/parts/export.ts +0 -5
  293. package/s/parts/video-decoder.ts +0 -27
  294. package/s/parts/video-encoder.ts +0 -15
  295. package/s/tools/generate-id.ts +0 -7
  296. package/s/tools/mp4boxjs/LICENSE.md +0 -24
  297. package/s/tools/mp4boxjs/demuxer.ts +0 -106
  298. package/s/tools/mp4boxjs/mp4box.adapter.ts +0 -148
  299. package/s/tools/mp4boxjs/mp4box.js +0 -8206
  300. package/s/types.ts +0 -10
  301. package/x/parts/compositor.d.ts +0 -4
  302. package/x/parts/compositor.js +0 -5
  303. package/x/parts/compositor.js.map +0 -1
  304. package/x/parts/export.d.ts +0 -7
  305. package/x/parts/export.js +0 -5
  306. package/x/parts/export.js.map +0 -1
  307. package/x/parts/video-decoder.d.ts +0 -8
  308. package/x/parts/video-decoder.js +0 -20
  309. package/x/parts/video-decoder.js.map +0 -1
  310. package/x/parts/video-encoder.d.ts +0 -6
  311. package/x/parts/video-encoder.js +0 -12
  312. package/x/parts/video-encoder.js.map +0 -1
  313. package/x/tools/generate-id.d.ts +0 -1
  314. package/x/tools/generate-id.js +0 -8
  315. package/x/tools/generate-id.js.map +0 -1
  316. package/x/tools/mp4boxjs/demuxer.d.ts +0 -24
  317. package/x/tools/mp4boxjs/demuxer.js +0 -88
  318. package/x/tools/mp4boxjs/demuxer.js.map +0 -1
  319. package/x/tools/mp4boxjs/mp4box.adapter.d.ts +0 -128
  320. package/x/tools/mp4boxjs/mp4box.adapter.js +0 -11
  321. package/x/tools/mp4boxjs/mp4box.adapter.js.map +0 -1
  322. package/x/types.d.ts +0 -7
  323. package/x/types.js.map +0 -1
  324. /package/x/{types.js → features/speech/transcribe/types.js} +0 -0
@@ -0,0 +1,70 @@
1
+
2
+ import {WhisperTextStreamer} from "@huggingface/transformers"
3
+ import {TranscribeOptions} from "../types.js"
4
+
5
+ export async function transcribe(options: TranscribeOptions) {
6
+ const {pipe, spec, request, callbacks} = options
7
+
8
+ if (!pipe.processor.feature_extractor)
9
+ throw new Error("no feature_extractor")
10
+
11
+ const timePrecision = (
12
+ pipe.processor.feature_extractor?.config.chunk_length /
13
+ // @ts-ignore
14
+ pipe.model.config.max_source_positions
15
+ )
16
+
17
+ let chunkCount = 0
18
+ let startTime: number | null = null
19
+ let tokenCount = 0
20
+ let tokensPerSecond = 0
21
+
22
+ const chunkDuration = spec.chunkLength - spec.strideLength
23
+
24
+ const calculateProgress = () => {
25
+ const audioProgressSeconds = chunkCount * chunkDuration
26
+ return Math.min(audioProgressSeconds / request.duration, 1)
27
+ }
28
+
29
+ // TODO type error on pipe.tokenizer
30
+ const tokenizer = pipe.tokenizer as any
31
+
32
+ const streamer = new WhisperTextStreamer(tokenizer, {
33
+ time_precision: timePrecision,
34
+ token_callback_function: () => {
35
+ startTime ??= performance.now()
36
+ if (++tokenCount > 1) {
37
+ tokensPerSecond = (tokenCount / (performance.now() - startTime)) * 1000
38
+ }
39
+ },
40
+ callback_function: (textChunk: any) => {
41
+ // TODO
42
+ callbacks.onTranscription(textChunk)
43
+ callbacks.onReport({tokensPerSecond, progress: calculateProgress()})
44
+ },
45
+ on_finalize: () => {
46
+ startTime = null
47
+ tokenCount = 0
48
+ chunkCount++
49
+ callbacks.onReport({tokensPerSecond, progress: calculateProgress()})
50
+ },
51
+ })
52
+
53
+ const result = await pipe(new Float32Array(request.audio), {
54
+ top_k: 0,
55
+ do_sample: false,
56
+ chunk_length_s: spec.chunkLength,
57
+ stride_length_s: spec.strideLength,
58
+ language: request.language,
59
+ task: "transcribe",
60
+ return_timestamps: "word", // if using "word" the on_chunk_start & end is not called thus we cant retrieve timestamps, only after whole thing finishes
61
+ force_full_sequences: false,
62
+ streamer,
63
+ })
64
+
65
+ return {
66
+ text: result.text,
67
+ chunks: result.chunks
68
+ }
69
+ }
70
+
@@ -0,0 +1,46 @@
1
+
2
+ import {Comrade} from "@e280/comrade"
3
+ import {coalesce, queue, sub} from "@e280/stz"
4
+
5
+ import {prepAudio} from "./parts/prep-audio.js"
6
+ import {TranscriberOptions, TranscriberSchematic, TranscriptionOptions, TranscriptionReport} from "./types.js"
7
+
8
+ export async function makeTranscriber({driver, spec, workerUrl, onLoading}: TranscriberOptions) {
9
+ const onReport = sub<[report: TranscriptionReport]>()
10
+ const onTranscription = sub<[transcription: string]>()
11
+
12
+ const thread = await Comrade.thread<TranscriberSchematic>({
13
+ label: "OmnitoolSpeechTranscriber",
14
+ workerUrl,
15
+ setupHost: () => ({
16
+ loading: async loading => onLoading(loading),
17
+ deliverReport: async report => onReport.pub(report),
18
+ deliverTranscription: async transcription => onTranscription.pub(transcription),
19
+ }),
20
+ })
21
+
22
+ await thread.work.prepare(spec)
23
+
24
+ return {
25
+ transcribe: queue(async(info: TranscriptionOptions) => {
26
+ const {source, language} = info
27
+ const {audio, duration} = await prepAudio(driver, source)
28
+
29
+ const detachCallbacks = coalesce(
30
+ onReport(info.onReport),
31
+ onTranscription(info.onTranscription),
32
+ )
33
+
34
+ const result = await thread.work.transcribe({
35
+ duration,
36
+ language,
37
+ audio: audio.buffer,
38
+ })
39
+
40
+ detachCallbacks()
41
+ return result
42
+ }),
43
+ dispose: thread.terminate()
44
+ }
45
+ }
46
+
@@ -0,0 +1,82 @@
1
+
2
+ import {AsSchematic} from "@e280/comrade"
3
+ import {DataType, DeviceType, Pipeline} from "@huggingface/transformers"
4
+
5
+ import {Driver} from "../../../driver/driver.js"
6
+
7
+ export type TranscriberSchematic = AsSchematic<{
8
+ work: {
9
+ prepare(spec: TranscriberSpec): Promise<void>
10
+ transcribe(request: TranscriptionRequest): Promise<Transcription>
11
+ },
12
+
13
+ host: {
14
+ loading(load: Loading): Promise<void>
15
+ deliverReport(report: TranscriptionReport): Promise<void>
16
+ deliverTranscription(transcription: string): Promise<void>
17
+ }
18
+ }>
19
+
20
+ export type Loading = {
21
+ total: number
22
+ progress: number
23
+ }
24
+
25
+ export type TranscribeOptions = {
26
+ pipe: Pipeline
27
+ spec: TranscriberSpec
28
+ request: TranscriptionRequest
29
+ callbacks: TranscriptionCallbacks
30
+ }
31
+
32
+ export type TranscriberPipeOptions = {
33
+ spec: TranscriberSpec
34
+ onLoading: (loading: Loading) => void
35
+ }
36
+
37
+ export type SpeechTime = [start: number, end: number]
38
+
39
+ export type Transcription = {
40
+ text: string
41
+ chunks: {
42
+ text: string
43
+ timestamp: SpeechTime
44
+ }[]
45
+ }
46
+
47
+ export type TranscriberSpec = {
48
+ model: string
49
+ dtype: DataType
50
+ device: DeviceType
51
+ chunkLength: number
52
+ strideLength: number
53
+ }
54
+
55
+ export type TranscriptionOptions = {
56
+ source: Blob
57
+ language: string | null
58
+ } & TranscriptionCallbacks
59
+
60
+ export type TranscriptionRequest = {
61
+ audio: ArrayBufferLike
62
+ language: string | null
63
+ duration: number
64
+ }
65
+
66
+ export type TranscriptionReport = {
67
+ progress: number
68
+ tokensPerSecond: number
69
+ }
70
+
71
+ export type TranscriptionCallbacks = {
72
+ onReport: (report: TranscriptionReport) => void
73
+ onTranscription: (transcription: string) => void
74
+ }
75
+
76
+ export type TranscriberOptions = {
77
+ driver: Driver
78
+ spec: TranscriberSpec
79
+ workerUrl: URL | string
80
+ onLoading: (loading: Loading) => void
81
+ }
82
+
@@ -0,0 +1,40 @@
1
+
2
+ import {defer, once} from "@e280/stz"
3
+ import {Comrade, Host} from "@e280/comrade"
4
+ import {Pipeline} from "@huggingface/transformers"
5
+
6
+ import {loadPipe} from "./parts/load-pipe.js"
7
+ import {transcribe} from "./parts/transcribe.js"
8
+ import {TranscriberSchematic, TranscriberSpec} from "./types.js"
9
+
10
+ const deferred = defer<{pipe: Pipeline, spec: TranscriberSpec}>()
11
+
12
+ const makePrepare = (host: Host<TranscriberSchematic>) => once(async(spec: TranscriberSpec) => {
13
+ deferred.resolve({
14
+ spec,
15
+ pipe: await loadPipe({
16
+ spec,
17
+ onLoading: loading => host.loading(loading),
18
+ }),
19
+ })
20
+ })
21
+
22
+ await Comrade.worker<TranscriberSchematic>(shell => {
23
+ const prepare = makePrepare(shell.host)
24
+ return {
25
+ prepare,
26
+ async transcribe(request) {
27
+ const {pipe, spec} = await deferred.promise
28
+ return transcribe({
29
+ pipe,
30
+ spec,
31
+ request,
32
+ callbacks: {
33
+ onReport: report => shell.host.deliverReport(report),
34
+ onTranscription: transcription => shell.host.deliverTranscription(transcription),
35
+ },
36
+ })
37
+ }
38
+ }
39
+ })
40
+
@@ -0,0 +1,24 @@
1
+ export const fragment = (glsl: string) => `
2
+ precision highp float;
3
+ varying vec2 vTextureCoord;
4
+ varying vec2 _uv;
5
+ uniform sampler2D from, to;
6
+ uniform float progress, ratio, _fromR, _toR;
7
+ uniform float customUniform;
8
+
9
+ vec4 getFromColor(vec2 uv){
10
+ return texture2D(from, .5+(uv-.5)*vec2(max(ratio/_fromR,1.), max(_fromR/ratio,1.)));
11
+ }
12
+ vec4 getToColor(vec2 uv){
13
+ return texture2D(to, .5+(uv-.5)*vec2(max(ratio/_toR,1.), max(_toR/ratio,1.)));
14
+ }
15
+
16
+ // gl-transition code here
17
+ ${glsl}
18
+ // gl-transition code end
19
+
20
+ void main(){
21
+ vec2 uv = vTextureCoord.xy;
22
+ gl_FragColor = transition(vTextureCoord);
23
+ }
24
+ `
@@ -0,0 +1,94 @@
1
+ import {Renderer} from "pixi.js"
2
+
3
+ export interface TransitionOptions {
4
+ name: Transition
5
+ renderer: Renderer
6
+ }
7
+
8
+ export interface TransitionRendererOptions {
9
+ from: VideoFrame
10
+ to: VideoFrame
11
+ progress: number
12
+ width: number
13
+ height: number
14
+ }
15
+
16
+ export interface GLTransition {
17
+ author: string
18
+ createdAt: string
19
+ glsl: string
20
+ license: string
21
+ name: Transition
22
+ updatedAt: string
23
+ defaultParams: any
24
+ paramsTypes: any
25
+ }
26
+
27
+ export type Transition =
28
+ | "Bounce"
29
+ | "BowTieHorizontal"
30
+ | "BowTieVertical"
31
+ | "ButterflyWaveScrawler"
32
+ | "CircleCrop"
33
+ | "ColourDistance"
34
+ | "CrazyParametricFun"
35
+ | "CrossZoom"
36
+ | "Directional"
37
+ | "DoomScreenTransition"
38
+ | "Dreamy"
39
+ | "DreamyZoom"
40
+ | "GlitchDisplace"
41
+ | "GlitchMemories"
42
+ | "GridFlip"
43
+ | "InvertedPageCurl"
44
+ | "LinearBlur"
45
+ | "Mosaic"
46
+ | "PolkaDotsCurtain"
47
+ | "Radial"
48
+ | "SimpleZoom"
49
+ | "StereoViewer"
50
+ | "Swirl"
51
+ | "WaterDrop"
52
+ | "ZoomInCircles"
53
+ | "angular"
54
+ | "burn"
55
+ | "cannabisleaf"
56
+ | "circle"
57
+ | "circleopen"
58
+ | "colorphase"
59
+ | "crosshatch"
60
+ | "crosswarp"
61
+ | "cube"
62
+ | "directionalwarp"
63
+ | "directionalwipe"
64
+ | "displacement"
65
+ | "doorway"
66
+ | "fade"
67
+ | "fadecolor"
68
+ | "fadegrayscale"
69
+ | "flyeye"
70
+ | "heart"
71
+ | "hexagonalize"
72
+ | "kaleidoscope"
73
+ | "luma"
74
+ | "luminance_melt"
75
+ | "morph"
76
+ | "multiply_blend"
77
+ | "perlin"
78
+ | "pinwheel"
79
+ | "pixelize"
80
+ | "polar_function"
81
+ | "randomsquares"
82
+ | "ripple"
83
+ | "rotate_scale_fade"
84
+ | "squareswire"
85
+ | "squeeze"
86
+ | "swap"
87
+ | "undulatingBurnOut"
88
+ | "wind"
89
+ | "windowblinds"
90
+ | "windowslice"
91
+ | "wipeDown"
92
+ | "wipeLeft"
93
+ | "wipeRight"
94
+ | "wipeUp"
@@ -0,0 +1,29 @@
1
+ import {GLTransition} from "./types.js"
2
+
3
+ export const uniforms = {
4
+ custom: (transition: GLTransition) => Object.fromEntries(
5
+ Object.entries(transition.defaultParams).map(([name, value]) => [
6
+ name,
7
+ {
8
+ value,
9
+ type: getUniformType(transition.paramsTypes[name])
10
+ }
11
+ ])
12
+ ),
13
+ basics: {
14
+ _fromR: {value: 1, type: "f32"},
15
+ _toR: {value: 1, type: "f32"},
16
+ ratio: {value: 1, type: "f32"},
17
+ progress: {value: 0, type: "f32"},
18
+ customUniform: {value: 0, type: "f32"},
19
+ }
20
+ }
21
+
22
+ const getUniformType = (type: string) => {
23
+ if(type === "f32" || type === "i32") {
24
+ return type
25
+ } else if(type === "float") {
26
+ return "f32"
27
+ }
28
+ else return `${type}<f32>`
29
+ }
@@ -0,0 +1,31 @@
1
+ export const vertex = `
2
+ in vec2 aPosition;
3
+ varying vec2 _uv; // gl-transition
4
+ uniform mat3 projectionMatrix;
5
+ uniform vec4 uInputSize;
6
+ uniform vec4 uOutputFrame;
7
+ out vec2 vTextureCoord;
8
+ uniform vec4 uOutputTexture;
9
+
10
+ vec4 filterVertexPosition( void )
11
+ {
12
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
13
+
14
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
15
+ position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
16
+
17
+ return vec4(position, 0.0, 1.0);
18
+ }
19
+
20
+ vec2 filterTextureCoord( void )
21
+ {
22
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
23
+ }
24
+
25
+ void main(void)
26
+ {
27
+ gl_Position = filterVertexPosition();
28
+ vTextureCoord = filterTextureCoord();
29
+ _uv = vec2(0.5, 0.5) * (aPosition +vec2(1.0, 1.0)); // gl-transition
30
+ }
31
+ `
@@ -0,0 +1,60 @@
1
+ //@ts-ignore
2
+ import transitions from "gl-transitions"
3
+ import {Filter, GlProgram, Sprite, Texture, ImageSource} from "pixi.js"
4
+
5
+ import {vertex} from "./parts/vertex.js"
6
+ import {uniforms} from "./parts/uniforms.js"
7
+ import {fragment} from "./parts/fragment.js"
8
+ import {GLTransition, TransitionOptions, TransitionRendererOptions} from "./parts/types.js"
9
+
10
+ export function makeTransition({name, renderer}: TransitionOptions) {
11
+ const transition = transitions.find((t: GLTransition) => t.name === name) as GLTransition
12
+ const transitionSprite = new Sprite()
13
+ const transitionTexture = new Texture()
14
+ const sourceFrom = new ImageSource({})
15
+ const sourceTo = new ImageSource({})
16
+
17
+ const filter = new Filter({
18
+ glProgram: new GlProgram({
19
+ vertex,
20
+ fragment: fragment(transition.glsl),
21
+ }),
22
+ resources: {
23
+ from: sourceFrom,
24
+ to: sourceTo,
25
+ uniforms: {
26
+ ...uniforms.basics,
27
+ ...uniforms.custom(transition)
28
+ }
29
+ }
30
+ })
31
+
32
+ transitionSprite.filters = [filter]
33
+
34
+ return {
35
+ render({width, height, from, to, progress}: TransitionRendererOptions) {
36
+ if(transitionSprite.width !== width || transitionSprite.height !== height) {
37
+ transitionSprite.setSize({width, height})
38
+ transitionTexture.source.resize(width, height)
39
+ }
40
+
41
+ sourceFrom.resource = from
42
+ sourceTo.resource = to
43
+ sourceFrom.update()
44
+ sourceTo.update()
45
+
46
+ filter.resources.uniforms.uniforms.progress = progress
47
+
48
+ renderer.render({
49
+ container: transitionSprite,
50
+ target: transitionTexture,
51
+ clear: false,
52
+ width,
53
+ height
54
+ })
55
+
56
+ return transitionTexture
57
+ }
58
+ }
59
+ }
60
+
@@ -0,0 +1,58 @@
1
+
2
+ import {ssg, html} from "@e280/scute"
3
+
4
+ const title = "omnitool"
5
+ const domain = "omnitool.omniclip.app"
6
+ const favicon = "/assets/favicon.png"
7
+
8
+ export default ssg.page(import.meta.url, async orb => ({
9
+ title,
10
+ // favicon,
11
+ dark: true,
12
+ css: "demo/demo.css",
13
+ js: "demo/demo.bundle.min.js",
14
+
15
+ head: html`
16
+ <link rel="preconnect" href="https://fonts.googleapis.com">
17
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
18
+ <link href="https://fonts.googleapis.com/css2?family=Share+Tech&display=swap" rel="stylesheet">
19
+ `,
20
+
21
+ socialCard: {
22
+ title,
23
+ description: "video processing toolkit",
24
+ themeColor: "#3cff9c",
25
+ siteName: domain,
26
+ image: `https://${domain}${favicon}`,
27
+ },
28
+
29
+ body: html`
30
+ <section>
31
+ <h1>Omnitool <small>v${orb.packageVersion()}</small></h1>
32
+ <button class=fetch>fetch</button>
33
+ <input type="file" class="file-input">
34
+ <div class=results></div>
35
+ <div class=filmstrip-demo>
36
+ <label for="viewable-range">viewable range:</label>
37
+ <input type="range" min="0" max="100" step="1" value="10" class="range" id="viewable-range" name="viewable-range">
38
+ <div class="range-view"></div>
39
+ <label for="range-size">viewable range size:</label>
40
+ <input type="range" class="range-size" min="0.1" max="10" step="0.1" value="0.5" id="range-size" name="range-size">
41
+ <label for="frequency">frequency:</label>
42
+ <input type="range" class="frequency" min="0.1" max="120" step="0.1" value="10" id="frequency" name="frequency">
43
+ <div class="frequency-view">10 (fps)</div>
44
+ <div id=filmstrip></div>
45
+ </div>
46
+ <div class=waveform-demo>
47
+ <label for="width">width:</label>
48
+ <input class="width" id="width" name="width" type="range" min="100" max="1000000" value="1000" />
49
+ </div>
50
+ <div class=player>
51
+ <input class="seek" type="number" min="0">
52
+ <button class=play>play</button>
53
+ <button class=stop>stop</button>
54
+ </div>
55
+ </section>
56
+ `,
57
+ }))
58
+
package/s/index.ts CHANGED
@@ -1,41 +1,4 @@
1
- import {MP4Demuxer} from "./tools/mp4boxjs/demuxer.js"
2
-
3
- import {Clip, LoadedVideoClip} from "./types.js"
4
- import {generateId} from "./tools/generate-id.js"
5
- import { OmniVideoDecoder } from "./parts/video-decoder.js"
6
-
7
- export class OmniTool {
8
- #clips: Map<Clip, LoadedVideoClip> = new Map()
9
- #getLoadedClip = (clip: Clip) => this.#clips.get(clip)
10
-
11
- videoDecoder = new OmniVideoDecoder(this.#getLoadedClip)
12
-
13
- // ffmpeg node or web version
14
- constructor(ffmpeg) {}
15
-
16
-
17
- load(file: File): Promise<Clip> {
18
- return new Promise((resolve) => {
19
- const demuxer = new MP4Demuxer(file, {
20
- onChunk: () => {},
21
- onConfig: () => {},
22
- framesCount: () => {},
23
- setStatus: () => {},
24
- OnReady: () => {
25
- const demuxed = {id: generateId(), demuxer}
26
- this.#clips.set(demuxed, demuxed)
27
- resolve(demuxed)
28
- }
29
- })
30
- })
31
-
32
- }
33
-
34
- async getFramesCount() {}
35
- }
36
-
37
- const tool = new OmniTool('ffmpeg')
38
- // const file = tool.load()
39
- // tool.videoDecoder.decode(file)
40
1
 
2
+ export * from "./driver/driver.js"
3
+ export * from "./timeline/index.js"
41
4
 
@@ -0,0 +1,8 @@
1
+
2
+ import {Science} from "@e280/science"
3
+ import driver from "./driver/driver.test.js"
4
+
5
+ await Science.run({
6
+ driver,
7
+ })
8
+
@@ -0,0 +1,15 @@
1
+
2
+ export * from "./parts/basics.js"
3
+ export * from "./parts/item.js"
4
+ export * from "./parts/media.js"
5
+ export * from "./parts/resource-pool.js"
6
+ export * from "./parts/resource.js"
7
+ export * from "./parts/filmstrip.js"
8
+ export * from "./parts/compositor/playback.js"
9
+
10
+ export * from "./sugar/o.js"
11
+ export * from "./sugar/omni.js"
12
+
13
+ export * from "./utils/checksum.js"
14
+ export * from "./utils/datafile.js"
15
+
@@ -0,0 +1,17 @@
1
+
2
+ import {Item} from "./item.js"
3
+
4
+ /** sha256 hash */
5
+ export type Hash = string
6
+
7
+ /** item identifier */
8
+ export type Id = number
9
+
10
+ export type TimelineFile = {
11
+ info: "https://omniclip.app/"
12
+ format: "timeline"
13
+ version: number
14
+ rootId: Id
15
+ items: Item.Any[]
16
+ }
17
+