hyperframes 0.9.5 → 0.9.7

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 (231) hide show
  1. package/dist/{add-XI5CW2YO.js → add-WLXYFHMC.js} +12 -12
  2. package/dist/{agentPromptGenerator-EEP7CJRK.js → agentPromptGenerator-2SMADJAL.js} +6 -6
  3. package/dist/{animatedGifPrep-3VKPC32B.js → animatedGifPrep-4WCFONEJ.js} +6 -6
  4. package/dist/api.d.ts +2 -0
  5. package/dist/api.js +25 -25
  6. package/dist/{asset-RYVHIREA.js → asset-UQBTWAMJ.js} +2 -2
  7. package/dist/{assetCataloger-MG3GSWNQ.js → assetCataloger-GOUD7VDG.js} +7 -7
  8. package/dist/{audio-CNKU2KQR.js → audio-LDVXMRHU.js} +506 -147
  9. package/dist/{auth-MX2SGZQH.js → auth-6LVATNTF.js} +6 -6
  10. package/dist/{autoUpdate-MB3SWOXG.js → autoUpdate-X6KZRI5E.js} +2 -2
  11. package/dist/{backgroundChecks-TYCDOGQX.js → backgroundChecks-3HGGWYLY.js} +3 -3
  12. package/dist/backgroundChecksWorker.js +3 -3
  13. package/dist/{batchRender-PHXZBVEA.js → batchRender-4ISYYVPQ.js} +3 -3
  14. package/dist/{beats-5SXSGNUM.js → beats-WN2KYIK3.js} +9 -9
  15. package/dist/{benchmark-V5Y5OQ3W.js → benchmark-HZPGQ2MP.js} +9 -9
  16. package/dist/{billing-FFWAEIQ6.js → billing-3Q2EAZFJ.js} +4 -4
  17. package/dist/{browser-CJ2HDBEC.js → browser-6XC7MTQL.js} +4 -4
  18. package/dist/{bundleWithLocalizedFonts-2FPP3MMD.js → bundleWithLocalizedFonts-ZZ6Y4CEO.js} +2 -2
  19. package/dist/{capture-KE3474CJ.js → capture-46LJ2VU2.js} +3 -3
  20. package/dist/{capture-424KH55L.js → capture-FCLAEX5L.js} +19 -19
  21. package/dist/{captureCompositionFrame-ZPZCQTYL.js → captureCompositionFrame-SMUDCZ2L.js} +11 -11
  22. package/dist/{catalog-3S4LAGZH.js → catalog-72AEDDEG.js} +12 -12
  23. package/dist/{catch-up-7ZLNBOG4.js → catch-up-6WIX7SWV.js} +5 -5
  24. package/dist/{check-6OCBPXX5.js → check-R2G5OYIA.js} +37 -37
  25. package/dist/{checkAudio-O5RDEOEX.js → checkAudio-2RP7BNQ3.js} +9 -9
  26. package/dist/{checkBrowser-DJPH634D.js → checkBrowser-OWLF2BT4.js} +31 -31
  27. package/dist/{chunk-T46SP3UD.js → chunk-2BARV2ZU.js} +48 -8
  28. package/dist/{chunk-DRXVRDUX.js → chunk-2X43RFKM.js} +1 -1
  29. package/dist/{chunk-6U4EV64B.js → chunk-3AH6KE6F.js} +39 -11
  30. package/dist/{chunk-ZDQEVQHB.js → chunk-3LHJHMFK.js} +1 -1
  31. package/dist/{chunk-ZFQ4N6D2.js → chunk-3Q7UFKFN.js} +3 -3
  32. package/dist/{chunk-TWIPYH4G.js → chunk-3YJB4QVS.js} +1 -1
  33. package/dist/{chunk-M56MEMPF.js → chunk-46HMQ4I3.js} +1 -1
  34. package/dist/{chunk-HMMHCSSN.js → chunk-6IW2HWYI.js} +7 -8
  35. package/dist/{chunk-OHWVSTNO.js → chunk-74VSOKKS.js} +6 -4
  36. package/dist/{chunk-JX5GUEFA.js → chunk-7LCZBNX7.js} +1 -1
  37. package/dist/{chunk-QIFINY2N.js → chunk-7XRS2NDR.js} +7 -7
  38. package/dist/{chunk-5FAU3XAO.js → chunk-AWQE37H3.js} +2 -2
  39. package/dist/{chunk-NASVSJQK.js → chunk-BGMMC352.js} +19 -7
  40. package/dist/{chunk-6NJVSTSY.js → chunk-BVAPHHMQ.js} +7 -3
  41. package/dist/{chunk-CRDXU4IX.js → chunk-C3FKYBZ4.js} +10 -10
  42. package/dist/{chunk-NVPB37H4.js → chunk-C7XW5WPZ.js} +2 -2
  43. package/dist/{chunk-YK6ERJTN.js → chunk-CTPYBHF3.js} +2 -2
  44. package/dist/{chunk-JZJ3LLIO.js → chunk-CUCDUPTA.js} +1 -1
  45. package/dist/{chunk-MNW4FTAJ.js → chunk-CX6MGY2B.js} +13 -13
  46. package/dist/{chunk-BXE6GDIL.js → chunk-DOS6S7HW.js} +1 -1
  47. package/dist/{chunk-MBOZUQFZ.js → chunk-DZNJD7BH.js} +1 -1
  48. package/dist/{chunk-YPBGUVLY.js → chunk-E3IBPTX7.js} +1 -1
  49. package/dist/{chunk-7FERR4YN.js → chunk-E4XS2M2E.js} +1 -1
  50. package/dist/{chunk-44IJ426Z.js → chunk-EG7FZSEF.js} +1 -1
  51. package/dist/{chunk-GOPJLAMZ.js → chunk-ETYQYG6Q.js} +78 -19
  52. package/dist/chunk-FLDSZTHP.js +134 -0
  53. package/dist/{chunk-S5SVW6ZY.js → chunk-FYDFHW22.js} +13 -13
  54. package/dist/{chunk-JD7MLLJD.js → chunk-FYR2GKAA.js} +4 -4
  55. package/dist/{chunk-WAQX3AYB.js → chunk-GBEGZOP3.js} +1 -1
  56. package/dist/{chunk-4W2ZN4HT.js → chunk-GK3OROLS.js} +1 -1
  57. package/dist/{chunk-Y6TDJUHR.js → chunk-HBCY63DS.js} +2 -2
  58. package/dist/{chunk-5TBRPDH3.js → chunk-HRSZOW3U.js} +55 -16
  59. package/dist/{chunk-MX7NW3QW.js → chunk-HZG42ZYW.js} +3 -3
  60. package/dist/{chunk-RTUQDHKE.js → chunk-IAZ2A7D6.js} +97 -11
  61. package/dist/{chunk-KLJEGC6M.js → chunk-IOECRDWX.js} +1 -1
  62. package/dist/{chunk-CGXL36FR.js → chunk-IX3R4BKU.js} +1 -1
  63. package/dist/{chunk-SXKFFBN3.js → chunk-IXGZ6YFZ.js} +85 -9
  64. package/dist/{chunk-TI4JPSFS.js → chunk-KD22R2UE.js} +3 -3
  65. package/dist/{chunk-JDT5PZWS.js → chunk-KDTOB4TD.js} +1 -1
  66. package/dist/{chunk-RUZ63CJF.js → chunk-LAZREIJF.js} +1 -1
  67. package/dist/{chunk-PYOEIKGI.js → chunk-LCDXHXYH.js} +2 -2
  68. package/dist/{chunk-2RLI5ISA.js → chunk-LFDPOL45.js} +3 -3
  69. package/dist/{chunk-YGSQABOD.js → chunk-LIA4GZ4F.js} +2 -2
  70. package/dist/{chunk-HWIGWPIG.js → chunk-N6O2RQLQ.js} +3 -1
  71. package/dist/{chunk-MYTROPEC.js → chunk-NEI65CWG.js} +2 -2
  72. package/dist/{chunk-MGXQXY4C.js → chunk-NFNYH6VQ.js} +2 -2
  73. package/dist/{chunk-FZM6E4S4.js → chunk-OJTXXFYO.js} +2 -2
  74. package/dist/{chunk-JAYAOI3W.js → chunk-OO7U23BR.js} +1 -1
  75. package/dist/chunk-OUZSRPKC.js +5035 -0
  76. package/dist/{chunk-XXFWK5Y7.js → chunk-P73MHFBX.js} +1 -1
  77. package/dist/{chunk-46DXV7OQ.js → chunk-P7CVKVPD.js} +2 -2
  78. package/dist/{chunk-C555UZ5B.js → chunk-PG356QHK.js} +2 -2
  79. package/dist/{chunk-EG2ESF6S.js → chunk-PPNA6EBI.js} +1 -1
  80. package/dist/{chunk-5FFHLOVF.js → chunk-PUMQDN2T.js} +1 -1
  81. package/dist/{chunk-64OUBJSX.js → chunk-PYWJGSWO.js} +1 -1
  82. package/dist/{chunk-JAJ6PAR6.js → chunk-QXUDHDJU.js} +7 -7
  83. package/dist/{chunk-WTUIK6Y4.js → chunk-QXVW22VM.js} +3 -1
  84. package/dist/{chunk-ARNCWQNR.js → chunk-RJ6LXDUC.js} +1 -1
  85. package/dist/{chunk-WAK6IPMP.js → chunk-RWHCRVZV.js} +5 -5
  86. package/dist/{chunk-7XCGHD55.js → chunk-RY7Z6KFS.js} +4 -4
  87. package/dist/{chunk-HZMM3D6P.js → chunk-SE6O4APZ.js} +2 -2
  88. package/dist/{chunk-K4SINZFP.js → chunk-SEJ7UBR2.js} +2 -2
  89. package/dist/{chunk-VPVO5COM.js → chunk-SIJYH7XM.js} +1 -1
  90. package/dist/{chunk-CS6UO5NC.js → chunk-SXGXJAA7.js} +1 -1
  91. package/dist/{chunk-UL3SKAZB.js → chunk-T252SG67.js} +2 -2
  92. package/dist/{chunk-NRO2PLEC.js → chunk-TBCRTIXP.js} +2 -2
  93. package/dist/{chunk-5T2D2XYR.js → chunk-TSCO4XR4.js} +1 -1
  94. package/dist/{chunk-QEQEKBL7.js → chunk-TSQZ3DSC.js} +20 -5
  95. package/dist/{chunk-3B3LGZ36.js → chunk-UDY3FS6G.js} +9 -9
  96. package/dist/{chunk-ALBHEVJJ.js → chunk-ULH6TLE3.js} +1 -1
  97. package/dist/{chunk-Q2LWMJAQ.js → chunk-UQH3MOES.js} +2 -2
  98. package/dist/{chunk-HDKRDALC.js → chunk-V6MZZEA7.js} +5 -5
  99. package/dist/{chunk-H7KAHDJJ.js → chunk-WAURLEUO.js} +3 -3
  100. package/dist/{chunk-6447ORC2.js → chunk-WZGVBZY6.js} +1 -1
  101. package/dist/{chunk-NUGADGXQ.js → chunk-X2PPRHKO.js} +1 -1
  102. package/dist/{chunk-RW4DTMPK.js → chunk-X3DTUYKZ.js} +7 -7
  103. package/dist/{chunk-PMQ65BTY.js → chunk-X4K7Q5PT.js} +1 -1
  104. package/dist/{chunk-KW2ZREKY.js → chunk-XEP7PGXS.js} +1 -1
  105. package/dist/{chunk-6PLIPRVQ.js → chunk-XFA6NPMP.js} +3 -3
  106. package/dist/{chunk-GC2GKCRQ.js → chunk-XKTLYF4N.js} +18 -18
  107. package/dist/{chunk-HZDSKYTV.js → chunk-XXEOJXXY.js} +2 -2
  108. package/dist/{chunk-MCROAQ7A.js → chunk-Y2R4N6HQ.js} +9 -9
  109. package/dist/{chunk-FEC4UQK2.js → chunk-YHO5SKUR.js} +5 -5
  110. package/dist/{chunk-IWMVCOUX.js → chunk-YTWTG67C.js} +7 -7
  111. package/dist/{chunk-SBPDYU34.js → chunk-ZVERYNYS.js} +1 -1
  112. package/dist/{clean-ZKPZ4HHG.js → clean-52TVJH4U.js} +16 -16
  113. package/dist/cli.js +58 -57
  114. package/dist/{cloud-GQZYBRBI.js → cloud-FEPPMA5F.js} +4 -4
  115. package/dist/{cloudrun-TWSNNKIV.js → cloudrun-DFWQ7ZJW.js} +4 -4
  116. package/dist/{compare-3IXL3WVG.js → compare-UBQUKWOB.js} +28 -28
  117. package/dist/{compiler-SKQTN3EA.js → compiler-UCJ4KC75.js} +3 -3
  118. package/dist/{component-RV72K74J.js → component-6YUQ2XAM.js} +3 -3
  119. package/dist/{compositions-W2IKF36U.js → compositions-KGZO4UYR.js} +11 -11
  120. package/dist/{curve-TRCKVHYB.js → curve-VISYHZKL.js} +10 -10
  121. package/dist/{cuts-SRXTGX33.js → cuts-HCWYCBI2.js} +11 -11
  122. package/dist/{delete-7PZLZFBE.js → delete-CNKHLEDS.js} +6 -6
  123. package/dist/{deploy-GORJQIPX.js → deploy-TS3R7DTD.js} +4 -4
  124. package/dist/{describeProject-ZIFVZUSV.js → describeProject-6TNE4FY4.js} +7 -7
  125. package/dist/{diff-PHRMVJMC.js → diff-YRBYR56R.js} +25 -25
  126. package/dist/{dist-IHPMKRYN.js → dist-H4C7ZCFU.js} +1 -1
  127. package/dist/{dist-4KKPG6A5.js → dist-T57O7KXT.js} +4 -2
  128. package/dist/{doctor-C6Q2FECX.js → doctor-PLA77GFC.js} +10 -10
  129. package/dist/{energy-CNXVSSE6.js → energy-7BTNGNR7.js} +11 -11
  130. package/dist/{events-FSUH46NR.js → events-25FIG2O6.js} +13 -13
  131. package/dist/{events-27C4TXPP.js → events-IMWCEFSZ.js} +4 -4
  132. package/dist/{events-UG3LC2PB.js → events-QTM2OEFB.js} +3 -3
  133. package/dist/{extract-GLPADLLV.js → extract-C66C5A22.js} +11 -11
  134. package/dist/{face-TTOHRJEY.js → face-MDOI2JO5.js} +11 -11
  135. package/dist/{feedback-BYONPSSM.js → feedback-26OSAZF3.js} +11 -11
  136. package/dist/{ffmpeg-WAM27CD6.js → ffmpeg-R5ND25AV.js} +6 -6
  137. package/dist/{figma-Y4UR2EDE.js → figma-276JAPS4.js} +3 -3
  138. package/dist/fontLocalizeCli.js +9 -9
  139. package/dist/{frames-CNQUJEUV.js → frames-AMLBNI5B.js} +12 -12
  140. package/dist/{generate-BPYDIEPB.js → generate-YIZS4JFA.js} +17 -17
  141. package/dist/{get-4LY5VJW2.js → get-HFEFIRAJ.js} +6 -6
  142. package/dist/{gpuPolicy-OUHJ7GVX.js → gpuPolicy-7JA66MJG.js} +6 -6
  143. package/dist/{grade-compare-WEZBE3WM.js → grade-compare-7NH6XYIY.js} +29 -29
  144. package/dist/{heifImagePrep-7L4HH33F.js → heifImagePrep-WCL36MHY.js} +7 -7
  145. package/dist/{help-QKNWJOBV.js → help-HHIAUMBQ.js} +2 -1
  146. package/dist/{history-XQEWP2IW.js → history-SLWPRU6Q.js} +7 -7
  147. package/dist/hyperframe.manifest.json +1 -1
  148. package/dist/hyperframe.runtime.iife.js +64 -64
  149. package/dist/hyperframes-player.global.js +90 -3
  150. package/dist/{info-AMRQ5R4N.js → info-MIPROXSM.js} +8 -8
  151. package/dist/{init-4VTMKZSQ.js → init-T56UGI6Z.js} +32 -29
  152. package/dist/{ink-KB3LZMJY.js → ink-TY7CKC6Q.js} +11 -11
  153. package/dist/{inspect-ZWN2DVO4.js → inspect-TIF7YHGN.js} +29 -29
  154. package/dist/{installer-2NUMLKHQ.js → installer-72QUKTPE.js} +4 -4
  155. package/dist/{keyframes-I456RFGP.js → keyframes-I4JRA37J.js} +7 -7
  156. package/dist/{lambda-2QKB4BJM.js → lambda-VGFSEG56.js} +10 -10
  157. package/dist/{layout-WPHWXQCM.js → layout-K776Z2IS.js} +29 -29
  158. package/dist/{lint-EO5DXJ36.js → lint-XLTSC66T.js} +8 -8
  159. package/dist/{lintProject-SG4KRUAV.js → lintProject-NZADSVSU.js} +1 -1
  160. package/dist/{list-LZOUUJBY.js → list-6V3IKLXF.js} +6 -6
  161. package/dist/{localPage-SZWQWWJ7.js → localPage-RM6EXBBT.js} +6 -6
  162. package/dist/{login-IEWPNTGD.js → login-HD47X3JE.js} +12 -13
  163. package/dist/{logout-B6H5F5YP.js → logout-UMDA3HDE.js} +3 -3
  164. package/dist/{look-6L3CPY4H.js → look-KUDJYDTK.js} +11 -11
  165. package/dist/{manager-C7677YAV.js → manager-TUKVGY7O.js} +7 -7
  166. package/dist/{measure-TINTS6YY.js → measure-6BRNY3II.js} +11 -11
  167. package/dist/{media-treatment-3BDHM4P6.js → media-treatment-MLME5LNQ.js} +13 -13
  168. package/dist/{media-use-JC2B2JSE.js → media-use-3YTDQKGR.js} +9 -5
  169. package/dist/{models-JMM25YO6.js → models-IUX642FY.js} +10 -10
  170. package/dist/{motionShot-4WB3SH6V.js → motionShot-INNVFSPU.js} +14 -14
  171. package/dist/{normalize-audio-2ZJKR5G3.js → normalize-audio-ZMJIN2OV.js} +9 -9
  172. package/dist/{open-LMYSLYH2.js → open-FDQ3NDSX.js} +12 -12
  173. package/dist/{parakeetRunner-HTQVLX2B.js → parakeetRunner-WZ6JW3QQ.js} +11 -11
  174. package/dist/{pipeline-FMVCPIRU.js → pipeline-V3TOATHS.js} +9 -9
  175. package/dist/{play-GFHBG3NZ.js → play-5WIU4CZL.js} +20 -20
  176. package/dist/{preflight-L5GC6ASI.js → preflight-JXEVL63B.js} +7 -7
  177. package/dist/{present-PW3RWNWF.js → present-UHWGVCP4.js} +16 -16
  178. package/dist/{preview-IRLHPLSD.js → preview-W75P6D7E.js} +18 -18
  179. package/dist/probe-O2ADL5FX.js +69 -0
  180. package/dist/{producer-M6IWCFMK.js → producer-6GQQQT7M.js} +1 -1
  181. package/dist/{projectConfig-IVJE7A42.js → projectConfig-FQ7CAOXL.js} +10 -6
  182. package/dist/{publication-BS2YATIF.js → publication-YRVC6D56.js} +2 -2
  183. package/dist/{publish-OTRA2JWM.js → publish-4IN3WW5G.js} +15 -15
  184. package/dist/{refresh-T6JLFCS4.js → refresh-4FQFQ2SW.js} +3 -3
  185. package/dist/{remove-background-UV37Y7T7.js → remove-background-L4KWXVMH.js} +10 -10
  186. package/dist/{render-3FANM5MO.js → render-73VGDCCH.js} +5 -5
  187. package/dist/{render-XSDVVBEY.js → render-GZ4DBQ5E.js} +41 -31
  188. package/dist/{render-7VBLI4AZ.js → render-IP7KBRD7.js} +32 -32
  189. package/dist/{render-batch-DPWJHKFY.js → render-batch-RX3TJ4NY.js} +5 -5
  190. package/dist/renderSetupWorker.js +1 -1
  191. package/dist/{resolver-VQ32ZH6Y.js → resolver-SNTBG6O2.js} +4 -4
  192. package/dist/reverse-5SHT4TC6.js +32 -0
  193. package/dist/{run-MTGSR5HH.js → run-GV6MEM2M.js} +4 -4
  194. package/dist/{sherpa-BSIBIIIO.js → sherpa-LJJHQNQ6.js} +10 -10
  195. package/dist/skills/hyperframes-cli/references/cloud.md +1 -1
  196. package/dist/skills/media-use/SKILL.md +5 -5
  197. package/dist/skills/media-use/audio/references/requirements.md +7 -7
  198. package/dist/skills/media-use/audio/references/tts.md +7 -6
  199. package/dist/skills/media-use/audio/scripts/lib/heygen.mjs +16 -10
  200. package/dist/skills/media-use/audio/scripts/lib/heygen.test.mjs +32 -0
  201. package/dist/skills/media-use/references/heygen.md +1 -1
  202. package/dist/{skills-S7JNBPZZ.js → skills-NVNRQU7K.js} +6 -6
  203. package/dist/{skillsUpdateCheck-WFEV6VYU.js → skillsUpdateCheck-QNFIPFLX.js} +3 -3
  204. package/dist/{snapshot-NCWXYS2E.js → snapshot-75S4SIRK.js} +173 -66
  205. package/dist/{src-AYBT7IBT.js → src-KS6W3WRC.js} +8 -8
  206. package/dist/{src-7WW3KXOI.js → src-MTLH4YHV.js} +17 -5
  207. package/dist/start-4UCLBL76.js +226 -0
  208. package/dist/{staticProjectServer-VYZV4BSU.js → staticProjectServer-USD7TCZH.js} +17 -17
  209. package/dist/{status-Z5BPMROD.js → status-MPCREDMQ.js} +9 -6
  210. package/dist/studio/assets/hyperframes-player-CQLtM2zB.js +565 -0
  211. package/dist/studio/assets/{index-BohL7wdo.js → index-CKnGNPHF.js} +1 -1
  212. package/dist/studio/assets/{index-CTbhykVD.js → index-CdWK2GVp.js} +101 -101
  213. package/dist/studio/index.html +1 -1
  214. package/dist/{studio-api-OTNMLH4B.js → studio-api-447CJUUM.js} +9 -9
  215. package/dist/{studioServer-AA4B3YP7.js → studioServer-TMPKQRQA.js} +48 -48
  216. package/dist/{sync-3M7VO3UJ.js → sync-V456U5AA.js} +11 -11
  217. package/dist/{telemetry-VJ3A6ZMD.js → telemetry-NK6K3VRH.js} +4 -4
  218. package/dist/{timeline-ZLZ45W7F.js → timeline-M5URP7QS.js} +18 -18
  219. package/dist/{tokens-WXEJNNJV.js → tokens-5OIFB4MD.js} +2 -2
  220. package/dist/{transcribe-XMVXOBHM.js → transcribe-N3E7T7AW.js} +21 -21
  221. package/dist/{transcribe-PPH5H67E.js → transcribe-ON5WTZV3.js} +9 -9
  222. package/dist/{updateCheck-HDLNWLIC.js → updateCheck-JQOAKPNR.js} +2 -2
  223. package/dist/{upgrade-6UXVTJII.js → upgrade-737POFN4.js} +2 -2
  224. package/dist/{urlDownloader-DPN2KRCX.js → urlDownloader-ZIPT6PZC.js} +5 -5
  225. package/dist/{validate-BZOURM4G.js → validate-6IPCQFXI.js} +23 -23
  226. package/dist/{video-BE42DAT2.js → video-BEZHDPH2.js} +7 -7
  227. package/dist/warmCheck.js +37 -37
  228. package/package.json +1 -1
  229. package/dist/chunk-2YQ2XYO5.js +0 -5030
  230. package/dist/probe-FPHFC3SD.js +0 -179
  231. package/dist/studio/assets/hyperframes-player-Cum4k6V2.js +0 -478
@@ -11,7 +11,7 @@ import {
11
11
  runFile,
12
12
  serviceAccess,
13
13
  serviceFailure
14
- } from "./chunk-IWMVCOUX.js";
14
+ } from "./chunk-YTWTG67C.js";
15
15
  import {
16
16
  uploadAssetViaDirectUpload
17
17
  } from "./chunk-CE7EQUBV.js";
@@ -28,7 +28,7 @@ import {
28
28
  } from "./chunk-HBAUU3IK.js";
29
29
  import {
30
30
  describeProject
31
- } from "./chunk-WAK6IPMP.js";
31
+ } from "./chunk-RWHCRVZV.js";
32
32
  import "./chunk-LLMSX6V6.js";
33
33
  import {
34
34
  ensureDOMParser
@@ -36,8 +36,8 @@ import {
36
36
  import {
37
37
  downloadToFile
38
38
  } from "./chunk-NO6F7CLR.js";
39
- import "./chunk-QEQEKBL7.js";
40
- import "./chunk-GOPJLAMZ.js";
39
+ import "./chunk-TSQZ3DSC.js";
40
+ import "./chunk-ETYQYG6Q.js";
41
41
  import {
42
42
  decodeAudio,
43
43
  probeAudio
@@ -47,17 +47,17 @@ import {
47
47
  } from "./chunk-54Q3H2UQ.js";
48
48
  import {
49
49
  resolveProject
50
- } from "./chunk-M56MEMPF.js";
50
+ } from "./chunk-46HMQ4I3.js";
51
51
  import "./chunk-AW3XJY4S.js";
52
- import "./chunk-5T2D2XYR.js";
52
+ import "./chunk-TSCO4XR4.js";
53
53
  import "./chunk-5LOZWO2M.js";
54
54
  import "./chunk-EHZESMRB.js";
55
55
  import "./chunk-A4ZTSQLW.js";
56
- import "./chunk-64OUBJSX.js";
57
- import "./chunk-HZDSKYTV.js";
56
+ import "./chunk-PYWJGSWO.js";
57
+ import "./chunk-XXEOJXXY.js";
58
58
  import "./chunk-PXVQOMKL.js";
59
59
  import "./chunk-MCDNAIFF.js";
60
- import "./chunk-6NJVSTSY.js";
60
+ import "./chunk-BVAPHHMQ.js";
61
61
  import {
62
62
  assertKnownFlags
63
63
  } from "./chunk-BGHKFD3T.js";
@@ -68,15 +68,15 @@ import "./chunk-S3S4TGEH.js";
68
68
  import "./chunk-TABWG4IT.js";
69
69
  import "./chunk-54HJ63Q2.js";
70
70
  import "./chunk-2GICKZ3I.js";
71
- import "./chunk-RTUQDHKE.js";
71
+ import "./chunk-IAZ2A7D6.js";
72
72
  import "./chunk-Z5J67X44.js";
73
73
  import "./chunk-5S7W3TUO.js";
74
74
  import "./chunk-D3MUHMFG.js";
75
- import "./chunk-HZMM3D6P.js";
75
+ import "./chunk-SE6O4APZ.js";
76
76
  import "./chunk-YWRUQ7XZ.js";
77
- import "./chunk-HWIGWPIG.js";
77
+ import "./chunk-N6O2RQLQ.js";
78
78
  import "./chunk-MEJH7VEA.js";
79
- import "./chunk-2YQ2XYO5.js";
79
+ import "./chunk-OUZSRPKC.js";
80
80
  import "./chunk-VC76R6W2.js";
81
81
  import "./chunk-OFQWTKPW.js";
82
82
  import "./chunk-RQVDTPGD.js";
@@ -86,7 +86,7 @@ import "./chunk-FXMKHHPO.js";
86
86
  import "./chunk-LAGZGKKN.js";
87
87
  import "./chunk-K4MJX7SR.js";
88
88
  import "./chunk-WE42NVH7.js";
89
- import "./chunk-NASVSJQK.js";
89
+ import "./chunk-BGMMC352.js";
90
90
  import {
91
91
  findFfBinary
92
92
  } from "./chunk-HYRPH6LL.js";
@@ -106,7 +106,7 @@ import "./chunk-FBN2M2HK.js";
106
106
  import "./chunk-766MOTIZ.js";
107
107
  import {
108
108
  withMeta
109
- } from "./chunk-HMMHCSSN.js";
109
+ } from "./chunk-6IW2HWYI.js";
110
110
  import "./chunk-BR2JQQC5.js";
111
111
  import "./chunk-BLBMPEBX.js";
112
112
  import "./chunk-ISN5GRYI.js";
@@ -116,7 +116,7 @@ import {
116
116
  } from "./chunk-66W5IWLO.js";
117
117
  import "./chunk-J3RXEDR2.js";
118
118
  import "./chunk-QBXDU24O.js";
119
- import "./chunk-UL3SKAZB.js";
119
+ import "./chunk-T252SG67.js";
120
120
  import "./chunk-E63BDV4Z.js";
121
121
  import "./chunk-G7VEYUZ2.js";
122
122
  import "./chunk-XT6MXC7A.js";
@@ -124,7 +124,7 @@ import "./chunk-7KDQAD2W.js";
124
124
  import "./chunk-M2WBOQ2Q.js";
125
125
 
126
126
  // src/commands/audio.ts
127
- import { join as join4, resolve as resolve2 } from "path";
127
+ import { join as join5, resolve as resolve2 } from "path";
128
128
 
129
129
  // src/audio/analysis/targets.ts
130
130
  import { dirname, join, resolve } from "path";
@@ -211,23 +211,23 @@ function sparkline(envelope, width = SPARK_WIDTH) {
211
211
  (v) => BARS[Math.round((Math.max(v, floor) - floor) / (top - floor) * (BARS.length - 1))]
212
212
  ).join("");
213
213
  }
214
- function momentsLine(moments, at) {
215
- return ` onset ${at(moments.onset)} steepest ${at(moments.steepest)} peak ${at(moments.peak)} tail end ${at(moments.tailEnd)}`;
214
+ function momentsLine(moments, at2) {
215
+ return ` onset ${at2(moments.onset)} steepest ${at2(moments.steepest)} peak ${at2(moments.peak)} tail end ${at2(moments.tailEnd)}`;
216
216
  }
217
- function hitsLine(onsets, at) {
217
+ function hitsLine(onsets, at2) {
218
218
  if (!onsets.events.length) return null;
219
- const shown = onsets.events.slice(0, ONSETS_SHOWN).map((e) => `${at(e.t)}(${e.strength.toFixed(2)})`);
219
+ const shown = onsets.events.slice(0, ONSETS_SHOWN).map((e) => `${at2(e.t)}(${e.strength.toFixed(2)})`);
220
220
  const more = onsets.events.length - shown.length;
221
221
  return ` hits ${shown.join(" ")}${more > 0 ? ` +${more}` : ""}`;
222
222
  }
223
- function loudnessLine(loudness2, at) {
223
+ function loudnessLine(loudness2, at2) {
224
224
  const lufs2 = loudness2.lufsIntegrated === null ? "below gate" : `${loudness2.lufsIntegrated} LUFS`;
225
225
  const { count, firstAt } = loudness2.clipping;
226
- const clip = count && firstAt !== null ? `, clips ${count}\xD7 from ${at(firstAt)}` : "";
226
+ const clip = count && firstAt !== null ? `, clips ${count}\xD7 from ${at2(firstAt)}` : "";
227
227
  return ` loudness ${lufs2}, true peak ${loudness2.truePeakDb} dBTP${clip}`;
228
228
  }
229
- function silenceLine(silence, at) {
230
- return silence.length ? ` silent ${silence.map((g) => `${at(g.start)}\u2013${at(g.end)}`).join(" ")}` : null;
229
+ function silenceLine(silence, at2) {
230
+ return silence.length ? ` silent ${silence.map((g) => `${at2(g.start)}\u2013${at2(g.end)}`).join(" ")}` : null;
231
231
  }
232
232
  function snapNote(snap) {
233
233
  if (!snap) return "";
@@ -235,19 +235,19 @@ function snapNote(snap) {
235
235
  const median2 = snap.medianShiftMs === null ? "" : `, median ${snap.medianShiftMs} ms`;
236
236
  return `; ${snap.snapped}/${total} snapped to ${snap.reference}${median2}`;
237
237
  }
238
- var listed = (times, at) => {
239
- const shown = times.slice(0, ONSETS_SHOWN).map(at).join(" ");
238
+ var listed = (times, at2) => {
239
+ const shown = times.slice(0, ONSETS_SHOWN).map(at2).join(" ");
240
240
  return times.length > ONSETS_SHOWN ? `${shown} +${times.length - ONSETS_SHOWN}` : shown;
241
241
  };
242
- function beatsLine(beats, at) {
242
+ function beatsLine(beats, at2) {
243
243
  if (!beats.times.length) return ` beats none${beats.reason ? ` (${beats.reason})` : ""}`;
244
- return ` beats ${beats.times.length}: ${listed(beats.times, at)}${snapNote(beats.snap)}`;
244
+ return ` beats ${beats.times.length}: ${listed(beats.times, at2)}${snapNote(beats.snap)}`;
245
245
  }
246
- function downbeatsLine(downbeats, at) {
246
+ function downbeatsLine(downbeats, at2) {
247
247
  if (!downbeats.times.length) return null;
248
248
  const meter = downbeats.meter ? ` in ${downbeats.meter}` : "";
249
249
  const low = downbeats.confidence === "low" ? ", a guess" : "";
250
- return ` downbeats${meter}${low}: ${listed(downbeats.times, at)}${snapNote(downbeats.snap)}`;
250
+ return ` downbeats${meter}${low}: ${listed(downbeats.times, at2)}${snapNote(downbeats.snap)}`;
251
251
  }
252
252
  function tempoLine(tempo) {
253
253
  if (tempo.value === null) return null;
@@ -255,8 +255,8 @@ function tempoLine(tempo) {
255
255
  const spread = bpms.length && Math.max(...bpms) - Math.min(...bpms) >= 2 ? ` (${Math.min(...bpms)}\u2013${Math.max(...bpms)})` : "";
256
256
  return ` tempo ${tempo.value} BPM${spread}`;
257
257
  }
258
- function sectionsLine(sections, at) {
259
- const spans = sections.spans.map((s3) => `${s3.label} ${at(s3.start)}\u2013${at(s3.end)}`).join(" ");
258
+ function sectionsLine(sections, at2) {
259
+ const spans = sections.spans.map((s3) => `${s3.label} ${at2(s3.start)}\u2013${at2(s3.end)}`).join(" ");
260
260
  return ` sections ${spans}${snapNote(sections.snap)}`;
261
261
  }
262
262
  function describeLine(description) {
@@ -283,11 +283,11 @@ function headline(item, where) {
283
283
  function formatItem(item) {
284
284
  const where = item.ref ? `${item.file} ${item.ref}` : item.file;
285
285
  if (item.error) return [`${where}: ${item.error}`];
286
- const at = (t) => s(item.placement ? filmTime(item.placement, t) : t);
286
+ const at2 = (t) => s(item.placement ? filmTime(item.placement, t) : t);
287
287
  const lines = [headline(item, where)];
288
288
  for (const [capability, line] of LINES) {
289
289
  const value = item[capability];
290
- const text = value ? line(value, at) : null;
290
+ const text = value ? line(value, at2) : null;
291
291
  if (text) lines.push(text);
292
292
  }
293
293
  for (const warning of item.warnings) lines.push(` ! ${warning}`);
@@ -320,6 +320,8 @@ var QUIET_DB = -45;
320
320
  var SILENT_DB = -55;
321
321
  var LEVEL_DB = 0.5;
322
322
  var s2 = (t) => t.toFixed(1);
323
+ var at = (t) => String(Math.round(t * 100) / 100);
324
+ var spanText = (span) => `${at(span.start)}\u2013${at(span.end)}`;
323
325
  var signed = (db) => `${db >= 0 ? "+" : ""}${db} dB`;
324
326
  var dbfs = (db) => `${db} dBFS`;
325
327
  var lufs = (db) => `${Math.round(db)} LUFS`;
@@ -357,8 +359,9 @@ function standing(effect) {
357
359
  return `${peak}, ${signed(effect.riseDb)} over what played before`;
358
360
  }
359
361
  function effectLine(effect, pauses) {
362
+ const from = effect.stem ? `${effect.stem}, ` : "";
360
363
  const parts = [
361
- `${effect.kind}${effect.count > 1 ? ` \xD7${effect.count}` : ""} (${effect.group}): ${effect.band}`,
364
+ `(${from}${effect.group})${effect.count > 1 ? ` \xD7${effect.count}` : ""}: ${effect.band}`,
362
365
  `attack ${effect.attackMs} ms`,
363
366
  `tail ${effect.tail.toFixed(1)} s`,
364
367
  standing(effect)
@@ -373,9 +376,25 @@ var ENTRY = {
373
376
  resumes: ", resumes",
374
377
  returns: ", returns"
375
378
  };
379
+ var EDGE = 0.5;
380
+ function stemsPlaying(segment) {
381
+ const byStem2 = /* @__PURE__ */ new Map();
382
+ for (const span of segment.stems) byStem2.set(span.name, [...byStem2.get(span.name) ?? [], span]);
383
+ return [...byStem2].map(([name, spans]) => {
384
+ const first = spans[0];
385
+ const last = spans[spans.length - 1];
386
+ const fromStart = first.start - segment.start <= EDGE;
387
+ const toEnd = segment.end - last.end <= EDGE;
388
+ if (spans.length === 1 && fromStart && toEnd) return name;
389
+ if (spans.length === 1 && fromStart) return `${name} until ${at(last.end)}`;
390
+ if (spans.length === 1 && toEnd) return `${name} from ${at(first.start)}`;
391
+ return `${name} ${spans.map(spanText).join(", ")}`;
392
+ }).join("; ");
393
+ }
376
394
  function musicLine(segment, analysis) {
377
395
  const piece = analysis.music.pieces.find((p) => p.id === segment.piece);
378
- const about = [piece.instruments.join(", "), segment.bpm ? `${segment.bpm} BPM` : null].filter(Boolean).join(" \xB7 ");
396
+ const playing = segment.stems?.length ? stemsPlaying(segment) : piece.instruments.join(", ");
397
+ const about = [playing, segment.bpm ? `${segment.bpm} BPM` : null].filter(Boolean).join(" \xB7 ");
379
398
  const afterBreak = (segment.entry === "new" || segment.entry === "resumes") && analysis.music.breaks.some((gap) => gap.end === segment.start) ? " after a break" : "";
380
399
  const fade = segment.fadeFrom !== null ? `, fades from ${s2(segment.fadeFrom)}` : "";
381
400
  return {
@@ -387,11 +406,8 @@ function musicLine(segment, analysis) {
387
406
  }
388
407
  function effectsIn(events) {
389
408
  if (!events.length) return null;
390
- const counts = /* @__PURE__ */ new Map();
391
- for (const e of events) counts.set(e.kind, (counts.get(e.kind) ?? 0) + e.count);
392
- const kinds = [...counts].map(([kind, n]) => n > 1 ? `${kind} \xD7${n}` : kind).join(", ");
393
409
  const total = events.reduce((n, e) => n + e.count, 0);
394
- return `${total} ${total === 1 ? "effect" : "effects"} (${kinds})`;
410
+ return `${total} ${total === 1 ? "effect" : "effects"}`;
395
411
  }
396
412
  function pauseLine(pause, analysis) {
397
413
  const inside = (start, end) => start < pause.end && end > pause.start;
@@ -423,25 +439,41 @@ function overlaps(line, range) {
423
439
  if (!range) return true;
424
440
  return line.start < range[1] && (line.end ?? line.start) >= range[0];
425
441
  }
426
- function separation(analysis) {
427
- if (analysis.separation !== "stems") return "not separated";
428
- const heard = analysis.stems.map((stem) => `${stem.name} ${stem.db} dB`).join(", ");
429
- return `stems: ${heard || "all silent"}`;
430
- }
431
442
  function voiceSummary(voice) {
432
443
  const rate = voice.meanRate !== null ? `mean ${voice.meanRate} ${voice.unit}/s` : null;
433
444
  const pitch = voice.medianPitchHz !== null ? `median pitch ${voice.medianPitchHz} Hz` : null;
434
445
  return `voice: ${voice.sentences.length} lines, ${voice.pauses.length} pauses${[rate, pitch].filter(Boolean).map((p) => `, ${p}`).join("")}`;
435
446
  }
436
447
  function effectsSummary(effects) {
437
- const top = effects.groups.slice(0, 6).map((g) => `${g.id} ${g.kind} \xD7${g.count}`).join(", ");
438
- return `effects: ${effects.events.length} in ${effects.groups.length} sounds${top ? ` (${top})` : ""}${effects.drumHits ? `; ${effects.drumHits} drum hits on the beat left out` : ""}`;
448
+ const top = effects.groups.slice(0, 6).map((g) => `${g.id} \xD7${g.count}`).join(", ");
449
+ return `effects: ${effects.events.length} in ${effects.groups.length} sounds${top ? ` (${top})` : ""}${effects.drumHits ? `; ${effects.drumHits} hits of the music's own drums left out` : ""}`;
439
450
  }
440
451
  var musicSummary = (music) => music.pieces.length ? `music: ${music.pieces.length} pieces, ${music.breaks.length} breaks` : "music: none";
452
+ function stemBlock(stem, width) {
453
+ const head = `${stem.name.padEnd(width)} ${stem.db} dB \xB7 ${stem.spans.map(spanText).join(", ")}`;
454
+ return stem.description ? [head, ` ${stem.description}`] : [head];
455
+ }
456
+ var DESCRIPTIONS_NOTE = "(descriptions are a model listening to each stem: what the sound is and what its effects sound like. Their times are approximate; the measured spans above and the timed lines below are exact.)";
457
+ function byStem(analysis) {
458
+ const { description } = analysis;
459
+ const width = Math.max(0, ...analysis.stems.map((stem) => stem.name.length));
460
+ return [
461
+ `${analysis.file} \xB7 ${s2(analysis.duration)} s${analysis.bpm ? ` \xB7 ${analysis.bpm} BPM` : ""}`,
462
+ ...description ? [`overall: ${description.overall}`] : [],
463
+ ...analysis.voiceFreeMix ? [`voice-free mix: ${analysis.voiceFreeMix}`] : [],
464
+ ...analysis.stemsDir ? [`stems: ${analysis.stemsDir}`] : [],
465
+ "",
466
+ ...analysis.stems.length ? analysis.stems.flatMap((stem) => stemBlock(stem, width)) : ["stems: all silent"],
467
+ ...analysis.stems.some((stem) => stem.description) ? [DESCRIPTIONS_NOTE] : [],
468
+ ...description ? ["", `bgm prompt: ${description.bgmPrompt ?? "none, the recording has no music"}`] : [],
469
+ ""
470
+ ];
471
+ }
441
472
  function header(analysis) {
442
473
  const { voice, effects, music, ambience } = analysis;
474
+ const separated2 = analysis.separation === "stems";
443
475
  return [
444
- `${analysis.file} \xB7 ${s2(analysis.duration)} s \xB7 ${separation(analysis)}`,
476
+ ...separated2 ? byStem(analysis) : [`${analysis.file} \xB7 ${s2(analysis.duration)} s \xB7 not separated`],
445
477
  voice && voiceSummary(voice),
446
478
  effects && effectsSummary(effects),
447
479
  music && musicSummary(music),
@@ -473,16 +505,200 @@ function formatRead(analysis, range) {
473
505
  }
474
506
 
475
507
  // src/audio/read/read.ts
476
- import { createHash } from "crypto";
508
+ import { createHash as createHash2 } from "crypto";
477
509
  import {
478
510
  createReadStream,
479
- existsSync as existsSync2,
480
- mkdirSync as mkdirSync2,
481
- readFileSync as readFileSync2,
482
- renameSync,
483
- writeFileSync as writeFileSync2
511
+ existsSync as existsSync3,
512
+ mkdirSync as mkdirSync3,
513
+ readFileSync as readFileSync3,
514
+ renameSync as renameSync2,
515
+ writeFileSync as writeFileSync3
484
516
  } from "fs";
485
- import { basename, extname, join as join3 } from "path";
517
+ import { basename, dirname as dirname2, extname, join as join4, relative } from "path";
518
+
519
+ // src/audio/read/describe.ts
520
+ import { createHash } from "crypto";
521
+ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
522
+ import { mkdtemp, rm } from "fs/promises";
523
+ import { tmpdir } from "os";
524
+ import { join as join2 } from "path";
525
+ var MODEL = "gemini-4-argon";
526
+ var TIMEOUT_MS = 18e4;
527
+ var ATTEMPTS = 2;
528
+ var OVERALL_SCHEMA = {
529
+ type: "object",
530
+ properties: { overall: { type: "string" }, bgm_prompt: { type: ["string", "null"] } },
531
+ required: ["overall", "bgm_prompt"],
532
+ additionalProperties: false
533
+ };
534
+ var describeAccess = () => serviceAccess(null, "/v1/hyperframes/llm/messages", TIMEOUT_MS);
535
+ var seconds = (t) => String(Math.round(t * 100) / 100);
536
+ var spansText = (spans) => spans.map((s3) => `${seconds(s3.start)}\u2013${seconds(s3.end)}`).join(", ") || "never";
537
+ function stemPrompt(name, duration) {
538
+ return [
539
+ `This audio is one stem, "${name}", that an audio separator split out of a ${seconds(duration)} s soundtrack.`,
540
+ "It holds only what the separator put in this stem.",
541
+ "Describe what it holds: instruments or sounds, rhythm or pattern, feel, and how it changes over time, with the second of each change where you can hear it.",
542
+ "If it holds sound effects, describe their sound and roughly when they occur.",
543
+ "Do not list individual beats or notes.",
544
+ "If it is near empty or only bleed from other stems, say so in one sentence.",
545
+ "Plain text, at most five sentences."
546
+ ].join(" ");
547
+ }
548
+ function overallPrompt({ duration, bpm, stems, breaks }) {
549
+ const facts = [
550
+ bpm ? `tempo about ${bpm} BPM` : null,
551
+ ...stems.map((s3) => `${s3.name} heard ${spansText(s3.spans)}`),
552
+ breaks.length ? `music breaks ${spansText(breaks)}` : null
553
+ ].filter(Boolean);
554
+ return [
555
+ `An audio separator split a ${seconds(duration)} s soundtrack into stems, and a listener described each stem alone.`,
556
+ `Measured facts, in seconds; trust these over the descriptions' times: ${facts.join("; ")}.`,
557
+ "The descriptions:",
558
+ ...stems.map((s3) => `${s3.name}: ${s3.description}`),
559
+ "",
560
+ "For overall, describe what the soundtrack holds, the music's style, instruments and feel, and how it is arranged over time, using the measured times. Use at most four sentences.",
561
+ "For bgm_prompt, describe only the music as a prompt for a music generator: style, tempo, instruments, feel, and how it develops from start to end in order. No voice, no sound effects, no seconds or timestamps. Music means instruments or a beat carrying a tune or a groove; sound effects are not music, even when they come in a rhythm. Return null when there is no music."
562
+ ].join("\n");
563
+ }
564
+ function isRecord(value) {
565
+ return value !== null && typeof value === "object" && !Array.isArray(value);
566
+ }
567
+ function requiredText(value) {
568
+ if (typeof value !== "string" || !value.trim())
569
+ throw new Error("the soundtrack answer did not match the required fields");
570
+ return value.trim();
571
+ }
572
+ function descriptionOf(text) {
573
+ const value = JSON.parse(text);
574
+ if (!isRecord(value)) throw new Error("the soundtrack answer did not match the required fields");
575
+ return {
576
+ overall: requiredText(value.overall),
577
+ bgmPrompt: value.bgm_prompt === null ? null : requiredText(value.bgm_prompt)
578
+ };
579
+ }
580
+ var isMp3 = (bytes) => bytes[0] === 73 && bytes[1] === 68 && bytes[2] === 51 || bytes[0] === 255 && (bytes[1] & 224) === 224;
581
+ async function mp3Of(path, scratch) {
582
+ const bytes = readFileSync(path);
583
+ if (isMp3(bytes)) return bytes;
584
+ const ffmpeg = findFfBinary("ffmpeg", { configuredMustExist: true });
585
+ if (!ffmpeg) throw new Error("ffmpeg is required to describe audio; run: npx hyperframes doctor");
586
+ const out = join2(scratch, `${createHash("sha256").update(path).digest("hex").slice(0, 12)}.mp3`);
587
+ await runFile(
588
+ ffmpeg,
589
+ ["-v", "error", "-y", "-i", path, "-vn", "-ac", "2", "-ar", "44100", "-b:a", "160k", out],
590
+ { windowsHide: true, maxBuffer: 8 * 1024 * 1024 }
591
+ );
592
+ return readFileSync(out);
593
+ }
594
+ var retryable = (status) => status === 429 || status >= 500;
595
+ function textPart(part) {
596
+ if (!isRecord(part) || part.type !== "text") return "";
597
+ return typeof part.text === "string" ? part.text : "";
598
+ }
599
+ function textOf(answer) {
600
+ if (!isRecord(answer) || !Array.isArray(answer.content))
601
+ throw new Error("the description service returned no text");
602
+ const content = answer.content;
603
+ const text = content.map(textPart).join("").trim();
604
+ if (!text) throw new Error("the description service returned no text");
605
+ return text;
606
+ }
607
+ async function generate(access, audio, prompt, structured) {
608
+ const sound = audio ? [
609
+ {
610
+ type: "audio",
611
+ source: { type: "base64", media_type: "audio/mpeg", data: audio.toString("base64") }
612
+ }
613
+ ] : [];
614
+ const body = JSON.stringify({
615
+ model: MODEL,
616
+ max_tokens: 2048,
617
+ messages: [{ role: "user", content: [...sound, { type: "text", text: prompt }] }],
618
+ ...structured ? { output_config: { format: { type: "json_schema", schema: OVERALL_SCHEMA } } } : {}
619
+ });
620
+ for (let attempt = 0; ; attempt++) {
621
+ const response = await fetch(access.url, {
622
+ method: "POST",
623
+ redirect: "error",
624
+ headers: { ...access.headers, "content-type": "application/json" },
625
+ body,
626
+ signal: AbortSignal.timeout(access.timeoutMs)
627
+ });
628
+ if (response.ok) return textOf(await response.json());
629
+ if (attempt + 1 >= ATTEMPTS || !retryable(response.status))
630
+ throw await serviceFailure(response, "the description service");
631
+ await response.body?.cancel();
632
+ }
633
+ }
634
+ async function answers(asks, cacheDir, access) {
635
+ const dir = join2(cacheDir, "describe");
636
+ mkdirSync(dir, { recursive: true });
637
+ const scratch = await mkdtemp(join2(tmpdir(), "hf-describe-"));
638
+ try {
639
+ const settled = await Promise.allSettled(
640
+ asks.map(async ({ path, prompt, structured = false }) => {
641
+ const audio = path ? await mp3Of(path, scratch) : null;
642
+ const hash = createHash("sha256").update(MODEL).update(prompt).update(structured ? JSON.stringify(OVERALL_SCHEMA) : "plain");
643
+ const id = (audio ? hash.update(audio) : hash).digest("hex");
644
+ const file = join2(dir, `${id.slice(0, 24)}.txt`);
645
+ if (existsSync(file)) return readFileSync(file, "utf8");
646
+ const text = await generate(access, audio, prompt, structured);
647
+ if (structured) descriptionOf(text);
648
+ writeFileSync(`${file}.tmp`, text);
649
+ renameSync(`${file}.tmp`, file);
650
+ return text;
651
+ })
652
+ );
653
+ return settled.map((result) => {
654
+ if (result.status === "rejected") throw result.reason;
655
+ return result.value;
656
+ });
657
+ } finally {
658
+ await rm(scratch, { recursive: true, force: true });
659
+ }
660
+ }
661
+ async function describeStems(stemPaths, measured2, cacheDir, warnings) {
662
+ const unavailable = {
663
+ stems: measured2.stems.map((stem) => ({ ...stem, description: null })),
664
+ description: null
665
+ };
666
+ const heard = measured2.stems.filter((stem) => stem.spans.length > 0);
667
+ if (!heard.length) return unavailable;
668
+ try {
669
+ const access = await describeAccess();
670
+ if (typeof access === "string") throw new Error(access);
671
+ const perStem = await answers(
672
+ heard.map((stem) => ({
673
+ path: stemPaths[stem.name],
674
+ prompt: stemPrompt(stem.name, measured2.duration)
675
+ })),
676
+ cacheDir,
677
+ access
678
+ );
679
+ const stems = unavailable.stems.map((stem) => ({
680
+ ...stem,
681
+ description: perStem[heard.findIndex((heardStem) => heardStem.name === stem.name)]?.replace(/\s+/g, " ").trim() || null
682
+ }));
683
+ const [overall] = await answers(
684
+ [
685
+ {
686
+ path: null,
687
+ prompt: overallPrompt({ ...measured2, stems: stems.filter((stem) => stem.description) }),
688
+ structured: true
689
+ }
690
+ ],
691
+ cacheDir,
692
+ access
693
+ );
694
+ if (!overall) throw new Error("the description service returned no soundtrack answer");
695
+ return { stems, description: descriptionOf(overall) };
696
+ } catch (error) {
697
+ const reason = error instanceof Error ? error.message : String(error);
698
+ warnings.push(`stems not described: ${reason.replace(/\s+/g, " ").trim()}`);
699
+ return unavailable;
700
+ }
701
+ }
486
702
 
487
703
  // src/audio/read/signal.ts
488
704
  var READ_RATE = 22050;
@@ -575,6 +791,11 @@ var GAP = 0.03;
575
791
  var SHORTEST_REFERENCE = 0.2;
576
792
  var SAME_ONSET = 0.03;
577
793
  var SPEECH_SLACK = 0.1;
794
+ var LIKE_SOUND = 0.9;
795
+ var RECURS = 3;
796
+ var STANDOUT_WINDOW = 4;
797
+ var STANDOUT_DB = 6;
798
+ var ENTRANCE_SLACK = 0.1;
578
799
  function floors(db) {
579
800
  const out = new Float32Array(db.length);
580
801
  let current = db[0] ?? -120;
@@ -671,34 +892,10 @@ function centroidHz(power) {
671
892
  const sum = e.reduce((acc, p, k) => acc + p * Math.log2(bandHz(k)), 0);
672
893
  return weight > 0 ? 2 ** (sum / weight) : 0;
673
894
  }
674
- var tonal = (power) => {
675
- const sorted = Float64Array.from(power).sort();
676
- return sorted[sorted.length - 1] - sorted[Math.floor(sorted.length * 0.75)] >= 2.5;
677
- };
678
- var KINDS = [
679
- [(s3) => s3.length >= 0.8 && s3.attack >= 0.45 * s3.length, () => "riser"],
680
- [(s3) => s3.band === "low", (s3) => s3.tail >= 0.6 ? "boom" : "thump"],
681
- [(s3) => s3.length <= 0.15, (s3) => s3.centroid >= 3e3 ? "tick" : "click"],
682
- [(s3) => s3.tonal && s3.tail >= 0.4, () => "ding"],
683
- [(s3) => s3.attack >= 0.06 && s3.length <= 1.5, () => "whoosh"]
684
- ];
685
895
  function bandOf(low, centroid) {
686
896
  if (low >= 0.5) return "low";
687
897
  return centroid >= 2500 ? "high" : "mid";
688
898
  }
689
- function kindOf(found, power) {
690
- const centroid = centroidHz(power);
691
- const shape2 = {
692
- length: found.end - found.t,
693
- attack: found.peak - found.t,
694
- tail: found.end - found.peak,
695
- band: bandOf(lowShare(power), centroid),
696
- centroid,
697
- tonal: tonal(power)
698
- };
699
- const kind = KINDS.find(([fits]) => fits(shape2))?.[1](shape2) ?? "hit";
700
- return { kind, band: shape2.band };
701
- }
702
899
  function printOf(power) {
703
900
  const e = energies(power);
704
901
  const octaves = new Float64Array(Math.ceil(e.length / BANDS_PER_PRINT));
@@ -759,12 +956,11 @@ function onBeat(t, beats) {
759
956
  const near = [beats[lo - 1], beats[lo]].filter((b) => b !== void 0);
760
957
  return near.some((b) => Math.abs(b - t) <= BEAT_SLACK);
761
958
  }
762
- function majority(kinds) {
763
- const counts = /* @__PURE__ */ new Map();
764
- for (const k of kinds) counts.set(k, (counts.get(k) ?? 0) + 1);
765
- return [...counts].sort((a, b) => b[1] - a[1])[0][0];
959
+ function loudestPart(parts, sampleRate, f) {
960
+ const end = Math.max(f.t + 0.05, Math.min(f.end, f.t + 0.4));
961
+ return Object.entries(parts).map(([name, samples]) => [name, spanDb(samples, sampleRate, f.t, end)]).sort((a, b) => b[1] - a[1])[0][0];
766
962
  }
767
- function foundIn({ samples: source, heldBy = [] }, input, mixDb) {
963
+ function foundIn({ samples: source, heldBy = [], playsIn = [], stem, parts }, input, mixDb) {
768
964
  const db = source === input.mix ? mixDb : levels(source, input.sampleRate, HOP);
769
965
  const inSpeech = (t) => input.speech.some((s3) => t >= s3.start - SPEECH_SLACK && t < s3.end);
770
966
  const masked = (f) => f.peakDb < (mixDb[Math.round(f.peak / HOP)] ?? -120) - MASKED_DB;
@@ -775,7 +971,13 @@ function foundIn({ samples: source, heldBy = [] }, input, mixDb) {
775
971
  const bands = found.length ? bandFramesOf(asSignal(source, input.sampleRate)).bands : [];
776
972
  return found.map((f) => {
777
973
  const power = shape(bands, f.t, Math.min(f.end, f.t + 0.4));
778
- return { ...f, ...kindOf(f, power), print: printOf(power) };
974
+ return {
975
+ ...f,
976
+ band: bandOf(lowShare(power), centroidHz(power)),
977
+ print: printOf(power),
978
+ stem: parts ? loudestPart(parts, input.sampleRate, f) : stem ?? null,
979
+ inMusic: playsIn.some((span) => f.t >= span.start - ENTRANCE_SLACK && f.t < span.end)
980
+ };
779
981
  });
780
982
  }
781
983
  function measured(input, mixDb) {
@@ -826,22 +1028,41 @@ function drumGroups(members, beats) {
826
1028
  }
827
1029
  return drums;
828
1030
  }
829
- function effectOf(m, group, kind, levels2) {
1031
+ function alikeSounds(a, b) {
1032
+ const ratio = (a.end - a.t) / Math.max(1e-3, b.end - b.t);
1033
+ return ratio >= 0.5 && ratio <= 2 && cosine(a.print, b.print) >= LIKE_SOUND;
1034
+ }
1035
+ function musicHits(sounds) {
1036
+ const playing = sounds.filter((m) => m.inMusic);
1037
+ const own = /* @__PURE__ */ new Set();
1038
+ for (const m of playing) {
1039
+ const same = playing.filter((o) => o.stem === m.stem);
1040
+ const recurs = same.filter((o) => alikeSounds(m, o)).length >= RECURS;
1041
+ const around = same.filter((o) => o !== m && Math.abs(o.t - m.t) <= STANDOUT_WINDOW).map((o) => o.peakDb);
1042
+ const standsOut = around.length > 0 && m.peakDb >= quantile(around, 0.9) + STANDOUT_DB;
1043
+ if (recurs && !standsOut) own.add(m);
1044
+ }
1045
+ return own;
1046
+ }
1047
+ function effectOf(m, group, levels2) {
830
1048
  return {
831
1049
  t: round2(m.t),
832
1050
  end: round2(m.end),
833
- kind,
1051
+ kind: "effect",
834
1052
  group,
835
1053
  band: m.band,
836
1054
  attackMs: Math.round((m.peak - m.t) * 1e3),
837
1055
  tail: round2(m.end - m.peak),
838
1056
  ...levels2,
839
- count: 1
1057
+ count: 1,
1058
+ stem: m.stem
840
1059
  };
841
1060
  }
842
1061
  function findEffects(input) {
843
1062
  const mixDb = levels(input.mix, input.sampleRate, HOP);
844
- const sounds = measured(input, mixDb);
1063
+ const all = measured(input, mixDb);
1064
+ const own = musicHits(all);
1065
+ const sounds = all.filter((m) => !own.has(m));
845
1066
  const members = /* @__PURE__ */ new Map();
846
1067
  for (const m of sounds) members.set(m.group, [...members.get(m.group) ?? [], m]);
847
1068
  const drums = drumGroups(members, input.beats);
@@ -849,10 +1070,8 @@ function findEffects(input) {
849
1070
  const names = new Map(kept.map(([id], i) => [id, `S${i + 1}`]));
850
1071
  const groups = kept.map(([id, list]) => ({
851
1072
  id: names.get(id),
852
- kind: majority(list.map((m) => m.kind)),
853
1073
  count: list.length
854
1074
  }));
855
- const kindOfGroup = new Map(groups.map((g) => [g.id, g.kind]));
856
1075
  const events = [];
857
1076
  for (const m of sounds) {
858
1077
  if (drums.has(m.group)) continue;
@@ -861,10 +1080,9 @@ function findEffects(input) {
861
1080
  if (previous?.group === group && m.t - previous.end <= TRAIN_GAP) {
862
1081
  previous.end = round2(m.end);
863
1082
  previous.count++;
864
- } else
865
- events.push(effectOf(m, group, kindOfGroup.get(group) ?? m.kind, levelsOf(input, mixDb, m)));
1083
+ } else events.push(effectOf(m, group, levelsOf(input, mixDb, m)));
866
1084
  }
867
- const drumHits = [...drums].reduce((n, id) => n + members.get(id).length, 0);
1085
+ const drumHits = [...drums].reduce((n, id) => n + members.get(id).length, own.size);
868
1086
  return { events, groups, drumHits };
869
1087
  }
870
1088
 
@@ -891,6 +1109,31 @@ var TONAL_SHARE = 0.4;
891
1109
  var DENSE_WINDOW = 2;
892
1110
  var DENSE_SHARE = 0.5;
893
1111
  var STEADY = 0.5;
1112
+ var ACTIVE_HOP = 0.25;
1113
+ var ACTIVE_DB = -45;
1114
+ var ACTIVE_GAP = 1;
1115
+ var SHORTEST_ACTIVE = 0.5;
1116
+ var PLAYS_THROUGH = 0.5;
1117
+ function activeSpans(samples, sampleRate) {
1118
+ const hop = Math.round(ACTIVE_HOP * sampleRate);
1119
+ const spans = [];
1120
+ for (let a = 0; a < samples.length; a += hop) {
1121
+ const b = Math.min(samples.length, a + hop);
1122
+ let power = 0;
1123
+ for (let i = a; i < b; i++) power += samples[i] ** 2;
1124
+ if (10 * Math.log10(power / (b - a) + 1e-12) <= ACTIVE_DB) continue;
1125
+ const start = a / sampleRate;
1126
+ const end = b / sampleRate;
1127
+ const last = spans[spans.length - 1];
1128
+ if (last && start - last.end < ACTIVE_GAP) last.end = end;
1129
+ else spans.push({ start, end });
1130
+ }
1131
+ return spans.filter((span) => span.end - span.start >= SHORTEST_ACTIVE).map((span) => ({ start: round2(span.start), end: round2(span.end) }));
1132
+ }
1133
+ function within2(spans, run) {
1134
+ return spans.map((span) => ({ start: Math.max(span.start, run.start), end: Math.min(span.end, run.end) })).filter((span) => span.end - span.start > 0);
1135
+ }
1136
+ var covered = (spans, run) => within2(spans, run).reduce((n, span) => n + span.end - span.start, 0) / (run.end - run.start);
894
1137
  function joined(spans, tooShort2) {
895
1138
  const out = [];
896
1139
  for (const span of spans) {
@@ -1059,7 +1302,7 @@ function fadeFrom(db, run) {
1059
1302
  if (db[f] < body - 3) return round2(f * HOP2, 1);
1060
1303
  return null;
1061
1304
  }
1062
- var leading = (mix) => Object.entries(mix).filter(([, share]) => share >= LEADING_SHARE).sort((a, b) => b[1] - a[1]).map(([name]) => name);
1305
+ var leading = (mix, through = () => true) => Object.entries(mix).filter(([name, share]) => share >= LEADING_SHARE && through(name)).sort((a, b) => b[1] - a[1]).map(([name]) => name);
1063
1306
  var isMusic = (heard) => heard.bpm !== null || heard.tonality >= TONAL_SHARE || leading(heard.mix).length > 1;
1064
1307
  var alike = (p, heard, piece, mix) => dot(p.print, heard.print) >= piece && mixDistance(p.mix, heard.mix) <= mix && sameTempo(p.bpm, heard.bpm);
1065
1308
  function pieceOf(pieces, previous, heard) {
@@ -1068,10 +1311,11 @@ function pieceOf(pieces, previous, heard) {
1068
1311
  return last;
1069
1312
  return pieces.find((p) => alike(p, heard, SAME_PIECE, SAME_MIX));
1070
1313
  }
1071
- function newPiece(id, heard) {
1314
+ function newPiece(id, heard, active) {
1315
+ const through = (name) => covered(active[name] ?? [], heard.run) >= PLAYS_THROUGH;
1072
1316
  return {
1073
1317
  id,
1074
- instruments: leading(heard.mix),
1318
+ instruments: leading(heard.mix, through),
1075
1319
  bpm: heard.bpm,
1076
1320
  firstAt: round2(heard.run.start),
1077
1321
  print: heard.print,
@@ -1100,7 +1344,23 @@ function energyCurve(melodic, sampleRate, duration, musical) {
1100
1344
  }
1101
1345
  return energy;
1102
1346
  }
1347
+ function stemsIn(active, loudest, run) {
1348
+ return loudest.flatMap(
1349
+ (name) => within2(active[name] ?? [], run).map((span) => ({
1350
+ name,
1351
+ start: round2(span.start),
1352
+ end: round2(span.end)
1353
+ }))
1354
+ );
1355
+ }
1103
1356
  function readMusic(input) {
1357
+ const named = { ...input.stems, ...input.drums ? { drums: input.drums } : {} };
1358
+ const active = Object.fromEntries(
1359
+ Object.entries(named).map(([name, samples]) => [name, activeSpans(samples, input.sampleRate)])
1360
+ );
1361
+ const loudest = Object.entries(named).map(
1362
+ ([name, samples]) => [name, energyOf(samples, input.sampleRate, { start: 0, end: Infinity })]
1363
+ ).sort((a, b) => b[1] - a[1]).map(([name]) => name);
1104
1364
  const melodic = mixed(Object.values(input.stems));
1105
1365
  const db = levels(melodic, input.sampleRate, HOP2, LEVEL_WINDOW);
1106
1366
  const duration = melodic.length / input.sampleRate;
@@ -1140,7 +1400,7 @@ function readMusic(input) {
1140
1400
  let entry;
1141
1401
  if (piece) entry = previous?.piece === piece.id ? "resumes" : "returns";
1142
1402
  else {
1143
- piece = newPiece(pieces.length + 1, heard);
1403
+ piece = newPiece(pieces.length + 1, heard, active);
1144
1404
  pieces.push(piece);
1145
1405
  entry = previous ? "new" : "start";
1146
1406
  }
@@ -1150,7 +1410,8 @@ function readMusic(input) {
1150
1410
  piece: piece.id,
1151
1411
  entry,
1152
1412
  bpm: heard.bpm,
1153
- fadeFrom: fadeFrom(db, run)
1413
+ fadeFrom: fadeFrom(db, run),
1414
+ stems: stemsIn(active, loudest, run)
1154
1415
  });
1155
1416
  }
1156
1417
  return {
@@ -1167,10 +1428,10 @@ function readMusic(input) {
1167
1428
 
1168
1429
  // src/audio/read/stems.ts
1169
1430
  import { randomUUID } from "crypto";
1170
- import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "fs";
1171
- import { mkdtemp, rm } from "fs/promises";
1172
- import { tmpdir } from "os";
1173
- import { join as join2 } from "path";
1431
+ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, statSync, writeFileSync as writeFileSync2 } from "fs";
1432
+ import { mkdtemp as mkdtemp2, rm as rm2 } from "fs/promises";
1433
+ import { tmpdir as tmpdir2 } from "os";
1434
+ import { join as join3 } from "path";
1174
1435
  import { setTimeout as sleep } from "timers/promises";
1175
1436
  var URL_ENV = "HYPERFRAMES_AUDIO_STEMS_URL";
1176
1437
  var KEY_ENV = "HYPERFRAMES_AUDIO_API_KEY";
@@ -1187,12 +1448,12 @@ var stemsAccess = () => serviceAccess(
1187
1448
  DEFAULT_TIMEOUT_MS
1188
1449
  );
1189
1450
  function cachedStems(dir) {
1190
- const done = join2(dir, DONE);
1191
- if (!existsSync(done)) return null;
1192
- const names = JSON.parse(readFileSync(done, "utf8"));
1451
+ const done = join3(dir, DONE);
1452
+ if (!existsSync2(done)) return null;
1453
+ const names = JSON.parse(readFileSync2(done, "utf8"));
1193
1454
  if (!STEM_NAMES.every((name) => typeof names[name] === "string")) return null;
1194
- const paths = Object.fromEntries(STEM_NAMES.map((name) => [name, join2(dir, names[name])]));
1195
- return Object.values(paths).every((p) => existsSync(p)) ? paths : null;
1455
+ const paths = Object.fromEntries(STEM_NAMES.map((name) => [name, join3(dir, names[name])]));
1456
+ return Object.values(paths).every((p) => existsSync2(p)) ? paths : null;
1196
1457
  }
1197
1458
  var StillRunning = class extends Error {
1198
1459
  };
@@ -1216,7 +1477,7 @@ async function encoded(path, dir, signal) {
1216
1477
  if (!ffmpeg) throw new Error("ffmpeg is required to separate stems; run: npx hyperframes doctor");
1217
1478
  const audio = await probeAudio(path);
1218
1479
  if (!audio) throw new Error("the recording has no audio track ffmpeg can decode");
1219
- const out = join2(dir, "upload.mp3");
1480
+ const out = join3(dir, "upload.mp3");
1220
1481
  await runFile(
1221
1482
  ffmpeg,
1222
1483
  [
@@ -1239,7 +1500,7 @@ async function separated(url, request, signal) {
1239
1500
  }
1240
1501
  async function fetchStems(path, dir, { url, headers, timeoutMs }) {
1241
1502
  const signal = AbortSignal.timeout(timeoutMs);
1242
- const scratch = await mkdtemp(join2(tmpdir(), "hf-stems-"));
1503
+ const scratch = await mkdtemp2(join3(tmpdir2(), "hf-stems-"));
1243
1504
  try {
1244
1505
  const mp3 = await encoded(path, scratch, signal);
1245
1506
  const client = new HyperframesCloudClient({
@@ -1280,24 +1541,24 @@ async function fetchStems(path, dir, { url, headers, timeoutMs }) {
1280
1541
  throw new Error(
1281
1542
  `the stems service returned an incomplete separation: missing ${missing.join(", ")}`
1282
1543
  );
1283
- mkdirSync(dir, { recursive: true });
1544
+ mkdirSync2(dir, { recursive: true });
1284
1545
  const names = {};
1285
1546
  for (const name of STEM_NAMES) {
1286
1547
  const stem = stems.find((candidate) => candidate.name === name);
1287
1548
  if (!stem) continue;
1288
1549
  const file = `${name}.audio`;
1289
- await downloadToFile(stem.url, join2(dir, file), { signal });
1550
+ await downloadToFile(stem.url, join3(dir, file), { signal });
1290
1551
  names[name] = file;
1291
1552
  }
1292
- writeFileSync(join2(dir, DONE), JSON.stringify(names));
1553
+ writeFileSync2(join3(dir, DONE), JSON.stringify(names));
1293
1554
  return cachedStems(dir);
1294
1555
  } finally {
1295
- await rm(scratch, { recursive: true, force: true });
1556
+ await rm2(scratch, { recursive: true, force: true });
1296
1557
  }
1297
1558
  }
1298
1559
 
1299
1560
  // src/audio/read/types.ts
1300
- var READ_VERSION = 4;
1561
+ var READ_VERSION = 7;
1301
1562
 
1302
1563
  // src/audio/read/voice.ts
1303
1564
  var SENTENCE_END = /[。!?!?…;;.]["'”’」』)]*$/;
@@ -1351,8 +1612,8 @@ function pitchOf(track, start, end) {
1351
1612
  }
1352
1613
  function summary(sentences, pauses, track) {
1353
1614
  const timed = sentences.filter((s3) => s3.rate !== null);
1354
- const seconds = timed.reduce((n, s3) => n + (s3.end - s3.start), 0);
1355
- const meanRate = seconds ? round2(timed.reduce((n, s3) => n + s3.rate * (s3.end - s3.start), 0) / seconds, 1) : null;
1615
+ const seconds2 = timed.reduce((n, s3) => n + (s3.end - s3.start), 0);
1616
+ const meanRate = seconds2 ? round2(timed.reduce((n, s3) => n + s3.rate * (s3.end - s3.start), 0) / seconds2, 1) : null;
1356
1617
  return {
1357
1618
  sentences,
1358
1619
  pauses,
@@ -1432,24 +1693,25 @@ function voiceFromActivity(vocals, sampleRate, track, levelOf) {
1432
1693
 
1433
1694
  // src/audio/read/read.ts
1434
1695
  async function sha256(path) {
1435
- const hash = createHash("sha256");
1696
+ const hash = createHash2("sha256");
1436
1697
  for await (const chunk of createReadStream(path)) hash.update(chunk);
1437
1698
  return hash.digest("hex");
1438
1699
  }
1439
1700
  function transcriptFor(path, given) {
1440
1701
  if (given) return given;
1441
1702
  const sidecar = `${path}.transcript.json`;
1442
- return existsSync2(sidecar) ? sidecar : null;
1703
+ return existsSync3(sidecar) ? sidecar : null;
1443
1704
  }
1444
1705
  function wordsOf(transcript) {
1445
1706
  return loadTranscript(transcript).words.map(({ text, start, end }) => ({ text, start, end }));
1446
1707
  }
1447
- var fingerprint = (path) => path ? createHash("sha256").update(readFileSync2(path)).digest("hex").slice(0, 16) : "none";
1708
+ var fingerprint = (path) => path ? createHash2("sha256").update(readFileSync3(path)).digest("hex").slice(0, 16) : "none";
1448
1709
  function writeAtomic(path, content) {
1449
1710
  const temporary = `${path}.${process.pid}.tmp`;
1450
- writeFileSync2(temporary, content);
1451
- renameSync(temporary, path);
1711
+ writeFileSync3(temporary, content);
1712
+ renameSync2(temporary, path);
1452
1713
  }
1714
+ var CACHE_REVISION = 1;
1453
1715
  async function stemsFor(path, dir, quality, warnings) {
1454
1716
  const cached = cachedStems(dir);
1455
1717
  if (cached) return cached;
@@ -1472,7 +1734,46 @@ async function stemsFor(path, dir, quality, warnings) {
1472
1734
  }
1473
1735
  }
1474
1736
  function heardStems(tracks) {
1475
- return Object.entries(tracks).map(([name, samples]) => ({ name, db: levelWhileHeardDb(samples, READ_RATE) })).filter((stem) => stem.db !== null).sort((a, b) => b.db - a.db || a.name.localeCompare(b.name));
1737
+ return Object.entries(tracks).flatMap(([name, samples]) => {
1738
+ const db = levelWhileHeardDb(samples, READ_RATE);
1739
+ return db === null ? [] : [{ name, db, spans: activeSpans(samples, READ_RATE), description: null }];
1740
+ }).sort((a, b) => b.db - a.db || a.name.localeCompare(b.name));
1741
+ }
1742
+ var VOICE_FREE = "no-vocals.wav";
1743
+ async function mixedFile(paths, out, warnings) {
1744
+ if (existsSync3(out)) return out;
1745
+ const ffmpeg = findFfBinary("ffmpeg", { configuredMustExist: true });
1746
+ if (!ffmpeg) {
1747
+ warnings.push(`no ${basename(out)}: ffmpeg is required; run: npx hyperframes doctor`);
1748
+ return null;
1749
+ }
1750
+ const temporary = `${out}.${process.pid}.tmp.wav`;
1751
+ try {
1752
+ await runFile(
1753
+ ffmpeg,
1754
+ [
1755
+ ...["-v", "error", "-y"],
1756
+ ...paths.flatMap((path) => ["-i", path]),
1757
+ ...["-filter_complex", `amix=inputs=${paths.length}:normalize=0`],
1758
+ ...["-c:a", "pcm_f32le", temporary]
1759
+ ],
1760
+ { windowsHide: true, maxBuffer: 8 * 1024 * 1024 }
1761
+ );
1762
+ renameSync2(temporary, out);
1763
+ return out;
1764
+ } catch (error) {
1765
+ warnings.push(`no ${basename(out)}: ${error instanceof Error ? error.message : error}`);
1766
+ return null;
1767
+ }
1768
+ }
1769
+ var voiceFreeMix = (stemPaths, warnings) => mixedFile(
1770
+ Object.entries(stemPaths).filter(([name]) => name !== VOICE_STEM).map(([, path]) => path),
1771
+ join4(dirname2(stemPaths[VOICE_STEM]), VOICE_FREE),
1772
+ warnings
1773
+ );
1774
+ function tempoOf(music) {
1775
+ const longest = [...music?.segments ?? []].filter((m) => m.bpm !== null).sort((a, b) => b.end - b.start - (a.end - a.start))[0];
1776
+ return longest?.bpm ?? null;
1476
1777
  }
1477
1778
  async function decodedStems(stemPaths) {
1478
1779
  const pitched = {};
@@ -1498,10 +1799,10 @@ function excerpt(samples, spans) {
1498
1799
  (span) => samples.subarray(Math.round(span.start * READ_RATE), Math.round(span.end * READ_RATE))
1499
1800
  );
1500
1801
  const out = new Float32Array(parts.reduce((n, p) => n + p.length, 0));
1501
- let at = 0;
1802
+ let at2 = 0;
1502
1803
  for (const part of parts) {
1503
- out.set(part, at);
1504
- at += part.length;
1804
+ out.set(part, at2);
1805
+ at2 += part.length;
1505
1806
  }
1506
1807
  return out;
1507
1808
  }
@@ -1518,6 +1819,14 @@ function againstMusic(voice, vocals, music, segments) {
1518
1819
  });
1519
1820
  return { ...voice, sentences };
1520
1821
  }
1822
+ function effectSources(pitched, drums, bed, music, ambience) {
1823
+ const segments = music?.segments ?? [];
1824
+ const playing = [...segments, ...music?.breaks ?? []];
1825
+ return [
1826
+ ...drums ? [{ samples: drums, stem: DRUM_STEM, playsIn: playing }] : [],
1827
+ ...bed ? [{ samples: bed, heldBy: [...segments, ...ambience ?? []], parts: pitched }] : []
1828
+ ];
1829
+ }
1521
1830
  async function fromStems(stemPaths, voice, vocals, mix) {
1522
1831
  const { pitched, drums } = await decodedStems(stemPaths);
1523
1832
  const bed = Object.keys(pitched).length ? mixed(Object.values(pitched)) : null;
@@ -1525,10 +1834,7 @@ async function fromStems(stemPaths, voice, vocals, mix) {
1525
1834
  const segments = music?.segments ?? [];
1526
1835
  const everythingElse = mixed(present([bed, drums]));
1527
1836
  const effects = findEffects({
1528
- sources: [
1529
- ...drums ? [{ samples: drums }] : [],
1530
- ...bed ? [{ samples: bed, heldBy: [...segments, ...ambience ?? []] }] : []
1531
- ],
1837
+ sources: effectSources(pitched, drums, bed, music, ambience),
1532
1838
  sampleRate: READ_RATE,
1533
1839
  mix,
1534
1840
  music: bed && everythingElse,
@@ -1536,12 +1842,55 @@ async function fromStems(stemPaths, voice, vocals, mix) {
1536
1842
  beats,
1537
1843
  speech: []
1538
1844
  });
1539
- const stems = separatedStems(stemPaths, pitched, drums, vocals);
1845
+ const stems = separatedStems(stemPaths, pitched, drums, vocals).filter(
1846
+ (stem) => heardLongEnough(stem, vocals.length / READ_RATE)
1847
+ );
1540
1848
  const read2 = music ? againstMusic(voice, vocals, everythingElse, music.segments) : voice;
1541
- return { voice: read2, stems, effects, music, ambience };
1849
+ return { voice: read2, stems, effects, music: music && onlyThe(stems, music), ambience };
1850
+ }
1851
+ var SHORTEST_STEM = 2;
1852
+ var SMALLEST_STEM_SHARE = 0.05;
1853
+ function heardLongEnough(stem, duration) {
1854
+ const heard = stem.spans.reduce((n, span) => n + span.end - span.start, 0);
1855
+ return heard >= SHORTEST_STEM && heard >= SMALLEST_STEM_SHARE * duration;
1856
+ }
1857
+ function onlyThe(stems, music) {
1858
+ const kept = new Set(stems.map((stem) => stem.name));
1859
+ return {
1860
+ ...music,
1861
+ pieces: music.pieces.map((p) => ({
1862
+ ...p,
1863
+ instruments: p.instruments.filter((n) => kept.has(n))
1864
+ })),
1865
+ segments: music.segments.map((m) => ({ ...m, stems: m.stems.filter((s3) => kept.has(s3.name)) }))
1866
+ };
1542
1867
  }
1543
1868
  var transcribeHint = (file) => `run hyperframes transcribe ${file} and pass --transcript`;
1544
- async function analyze(path, file, sha, transcript, stemDir, quality) {
1869
+ async function described(stemPaths, read2, cacheDir, quality) {
1870
+ const warnings = [...read2.warnings];
1871
+ const project = dirname2(dirname2(cacheDir));
1872
+ const mix = await voiceFreeMix(stemPaths, warnings);
1873
+ const located = {
1874
+ ...read2,
1875
+ stemsDir: `${relative(project, dirname2(stemPaths[VOICE_STEM]))}/`,
1876
+ voiceFreeMix: mix && relative(project, mix),
1877
+ warnings
1878
+ };
1879
+ if (quality === "fast") return located;
1880
+ const { stems, description } = await describeStems(
1881
+ stemPaths,
1882
+ {
1883
+ duration: read2.duration,
1884
+ bpm: read2.bpm,
1885
+ stems: read2.stems,
1886
+ breaks: read2.music?.breaks ?? []
1887
+ },
1888
+ cacheDir,
1889
+ warnings
1890
+ );
1891
+ return { ...located, stems, description };
1892
+ }
1893
+ async function analyze(path, file, sha, transcript, stemDir, quality, cacheDir) {
1545
1894
  const warnings = [];
1546
1895
  const stemPaths = await stemsFor(path, stemDir, quality, warnings);
1547
1896
  const words = transcript ? wordsOf(transcript) : [];
@@ -1560,8 +1909,11 @@ async function analyze(path, file, sha, transcript, stemDir, quality) {
1560
1909
  const mix = await recording(path, stemPaths !== null, voiceSamples);
1561
1910
  const levelOf = (span) => spanDb(mix, READ_RATE, span.start, span.end);
1562
1911
  const voice = words.length ? voiceFromWords(words, pitch, levelOf) : voiceFromActivity(voiceSamples, READ_RATE, pitch, levelOf);
1563
- if (stemPaths)
1564
- return { ...about, ...await fromStems(stemPaths, voice, voiceSamples, mix), warnings };
1912
+ if (stemPaths) {
1913
+ const read2 = await fromStems(stemPaths, voice, voiceSamples, mix);
1914
+ const analysis = { ...about, ...read2, bpm: tempoOf(read2.music), warnings };
1915
+ return described(stemPaths, analysis, cacheDir, quality);
1916
+ }
1565
1917
  warnings.push("without stems, effects under speech are not found and music is not read");
1566
1918
  const effects = findEffects({
1567
1919
  sources: [{ samples: voiceSamples }],
@@ -1581,6 +1933,10 @@ function base(file, sha, duration, stemPaths, transcript) {
1581
1933
  duration,
1582
1934
  separation: stemPaths ? "stems" : "mix",
1583
1935
  stems: [],
1936
+ stemsDir: null,
1937
+ voiceFreeMix: null,
1938
+ bpm: null,
1939
+ description: null,
1584
1940
  transcript: transcript ? basename(transcript) : null
1585
1941
  };
1586
1942
  }
@@ -1590,18 +1946,21 @@ async function readAudio(path, file, options) {
1590
1946
  const transcript = transcriptFor(path, options.transcript);
1591
1947
  const transcriptKey = fingerprint(transcript);
1592
1948
  const stem = `${basename(file, extname(file)).replace(/[^\w.-]/g, "_")}-${sha.slice(0, 12)}`;
1593
- mkdirSync2(options.cacheDir, { recursive: true });
1594
- const jsonPath = join3(options.cacheDir, `${stem}.json`);
1595
- const textPath = join3(options.cacheDir, `${stem}.txt`);
1596
- const stemDir = join3(options.cacheDir, "stems", sha.slice(0, 12));
1597
- if (existsSync2(jsonPath) && existsSync2(textPath)) {
1598
- const entry = JSON.parse(readFileSync2(jsonPath, "utf8"));
1949
+ mkdirSync3(options.cacheDir, { recursive: true });
1950
+ const jsonPath = join4(options.cacheDir, `${stem}.json`);
1951
+ const textPath = join4(options.cacheDir, `${stem}.txt`);
1952
+ const stemDir = join4(options.cacheDir, "stems", sha.slice(0, 12));
1953
+ if (existsSync3(jsonPath) && existsSync3(textPath)) {
1954
+ const entry = JSON.parse(readFileSync3(jsonPath, "utf8"));
1599
1955
  const stemsNowPossible = entry.analysis.separation === "mix" && quality === "best" && (cachedStems(stemDir) !== null || typeof await stemsAccess() !== "string");
1600
- if ((entry.analysis.separation !== "stems" || cachedStems(stemDir) !== null) && entry.analysis.version === READ_VERSION && entry.transcriptKey === transcriptKey && !stemsNowPossible)
1956
+ if ((entry.analysis.separation !== "stems" || cachedStems(stemDir) !== null) && entry.analysis.version === READ_VERSION && entry.revision === CACHE_REVISION && entry.transcriptKey === transcriptKey && !stemsNowPossible && !(entry.analysis.separation === "stems" && !entry.analysis.description && quality !== "fast" && typeof await describeAccess() !== "string"))
1601
1957
  return { analysis: entry.analysis, textPath, jsonPath, cached: true };
1602
1958
  }
1603
- const analysis = await analyze(path, file, sha, transcript, stemDir, quality);
1604
- writeAtomic(jsonPath, JSON.stringify({ analysis, transcriptKey }));
1959
+ const analysis = await analyze(path, file, sha, transcript, stemDir, quality, options.cacheDir);
1960
+ writeAtomic(
1961
+ jsonPath,
1962
+ JSON.stringify({ revision: CACHE_REVISION, analysis, transcriptKey })
1963
+ );
1605
1964
  writeAtomic(textPath, formatRead(analysis));
1606
1965
  return { analysis, textPath, jsonPath, cached: false };
1607
1966
  }
@@ -1736,7 +2095,7 @@ async function read(files, flags) {
1736
2095
  const quality = readQuality(files, flags);
1737
2096
  const range = pair("range", flags.range);
1738
2097
  const result = await readAudio(resolve2(process.cwd(), files[0]), files[0], {
1739
- cacheDir: join4(resolve2(flags.dir ?? process.cwd()), ".hyperframes", "read-audio"),
2098
+ cacheDir: join5(resolve2(flags.dir ?? process.cwd()), ".hyperframes", "read-audio"),
1740
2099
  transcript: flags.transcript ? resolve2(process.cwd(), flags.transcript) : void 0,
1741
2100
  quality
1742
2101
  });
@@ -1826,7 +2185,7 @@ var audio_default = defineCommand({
1826
2185
  targets,
1827
2186
  analyzeRequest(flags),
1828
2187
  Boolean(args.full),
1829
- join4(resolve2(flags.dir ?? process.cwd()), ".hyperframes", "audio-kind")
2188
+ join5(resolve2(flags.dir ?? process.cwd()), ".hyperframes", "audio-kind")
1830
2189
  );
1831
2190
  console.log(args.json ? JSON.stringify(withMeta(report)) : formatReport(report));
1832
2191
  }