@arbidocs/blocks 0.5.191 → 0.5.192

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 (140) hide show
  1. package/bin/arbidocs-mix-take.mjs +34 -0
  2. package/bin/arbidocs-record-take.mjs +77 -11
  3. package/bin/arbidocs-voice-take.mjs +32 -0
  4. package/dist/{ConnectedCallDock-PVBDNOTA.cjs → ConnectedCallDock-7GGYYQNK.cjs} +23 -23
  5. package/dist/{ConnectedCallDock-PVBDNOTA.cjs.map → ConnectedCallDock-7GGYYQNK.cjs.map} +1 -1
  6. package/dist/{ConnectedCallRoom-H2OWGUEN.cjs → ConnectedCallRoom-ZZ7RBGGY.cjs} +16 -16
  7. package/dist/{ConnectedCallRoom-H2OWGUEN.cjs.map → ConnectedCallRoom-ZZ7RBGGY.cjs.map} +1 -1
  8. package/dist/{ConnectedNativeDocxComparison-NKVGPLSK.cjs → ConnectedNativeDocxComparison-PPVXDQY3.cjs} +20 -20
  9. package/dist/{ConnectedNativeDocxComparison-NKVGPLSK.cjs.map → ConnectedNativeDocxComparison-PPVXDQY3.cjs.map} +1 -1
  10. package/dist/{ConnectedPresentation-N6HNSYRH.cjs → ConnectedPresentation-LNDESKYE.cjs} +19 -19
  11. package/dist/{ConnectedPresentation-N6HNSYRH.cjs.map → ConnectedPresentation-LNDESKYE.cjs.map} +1 -1
  12. package/dist/{ConnectedProductionSetDialog-KT6BPSRE.cjs → ConnectedProductionSetDialog-SHDI7KP6.cjs} +6 -6
  13. package/dist/{ConnectedProductionSetDialog-KT6BPSRE.cjs.map → ConnectedProductionSetDialog-SHDI7KP6.cjs.map} +1 -1
  14. package/dist/{ConnectedSlidesTab-J7OPUXI4.cjs → ConnectedSlidesTab-SYDDGJWM.cjs} +16 -16
  15. package/dist/{ConnectedSlidesTab-J7OPUXI4.cjs.map → ConnectedSlidesTab-SYDDGJWM.cjs.map} +1 -1
  16. package/dist/{ConnectedStreamedWordArtifact-BLSAP7NY.cjs → ConnectedStreamedWordArtifact-GAACBGTY.cjs} +20 -20
  17. package/dist/{ConnectedStreamedWordArtifact-BLSAP7NY.cjs.map → ConnectedStreamedWordArtifact-GAACBGTY.cjs.map} +1 -1
  18. package/dist/{DocumentReviewCard-C2ZXJ2ZL.cjs → DocumentReviewCard-Q3NKJLSM.cjs} +19 -19
  19. package/dist/{DocumentReviewCard-C2ZXJ2ZL.cjs.map → DocumentReviewCard-Q3NKJLSM.cjs.map} +1 -1
  20. package/dist/{FilesViewerDialog-NUPMAEIC.cjs → FilesViewerDialog-4JWDTDO7.cjs} +53 -53
  21. package/dist/{FilesViewerDialog-NUPMAEIC.cjs.map → FilesViewerDialog-4JWDTDO7.cjs.map} +1 -1
  22. package/dist/{WorkspaceTableView-CSOPEZFT.cjs → WorkspaceTableView-QT63XYII.cjs} +10 -10
  23. package/dist/{WorkspaceTableView-CSOPEZFT.cjs.map → WorkspaceTableView-QT63XYII.cjs.map} +1 -1
  24. package/dist/agents/index.cjs +287 -287
  25. package/dist/{ai-2B4BMS6O.cjs → ai-A5YTWIEC.cjs} +25 -25
  26. package/dist/ai-A5YTWIEC.cjs.map +1 -0
  27. package/dist/auth/index.cjs +12 -12
  28. package/dist/calls/index.cjs +125 -125
  29. package/dist/chat/index.cjs +23 -23
  30. package/dist/{chunk-VNUBBRJM.cjs → chunk-2K5DLB7B.cjs} +3 -3
  31. package/dist/{chunk-VNUBBRJM.cjs.map → chunk-2K5DLB7B.cjs.map} +1 -1
  32. package/dist/{chunk-GOLLGCGK.cjs → chunk-33236Q7Y.cjs} +70 -70
  33. package/dist/{chunk-GOLLGCGK.cjs.map → chunk-33236Q7Y.cjs.map} +1 -1
  34. package/dist/{chunk-NTXII2XQ.cjs → chunk-3EIO4ZH5.cjs} +6 -6
  35. package/dist/{chunk-NTXII2XQ.cjs.map → chunk-3EIO4ZH5.cjs.map} +1 -1
  36. package/dist/{chunk-B5AOYT4U.cjs → chunk-5FSULBPE.cjs} +3 -3
  37. package/dist/{chunk-B5AOYT4U.cjs.map → chunk-5FSULBPE.cjs.map} +1 -1
  38. package/dist/{chunk-3P6KGC46.cjs → chunk-5OD6DRG7.cjs} +3 -3
  39. package/dist/{chunk-3P6KGC46.cjs.map → chunk-5OD6DRG7.cjs.map} +1 -1
  40. package/dist/{chunk-R37KPMUZ.cjs → chunk-5RUY5THD.cjs} +7 -7
  41. package/dist/{chunk-R37KPMUZ.cjs.map → chunk-5RUY5THD.cjs.map} +1 -1
  42. package/dist/{chunk-GEVBY536.cjs → chunk-633ZCYVN.cjs} +37 -37
  43. package/dist/{chunk-GEVBY536.cjs.map → chunk-633ZCYVN.cjs.map} +1 -1
  44. package/dist/{chunk-E62542RM.cjs → chunk-65NQW4RR.cjs} +18 -18
  45. package/dist/{chunk-E62542RM.cjs.map → chunk-65NQW4RR.cjs.map} +1 -1
  46. package/dist/{chunk-DFQWX2XY.cjs → chunk-7GVKG3G4.cjs} +13 -13
  47. package/dist/{chunk-DFQWX2XY.cjs.map → chunk-7GVKG3G4.cjs.map} +1 -1
  48. package/dist/{chunk-SOJYSRO4.cjs → chunk-A7MGQMOV.cjs} +10 -10
  49. package/dist/{chunk-SOJYSRO4.cjs.map → chunk-A7MGQMOV.cjs.map} +1 -1
  50. package/dist/{chunk-KJ5M72M2.cjs → chunk-AWQEN6WW.cjs} +7 -7
  51. package/dist/{chunk-KJ5M72M2.cjs.map → chunk-AWQEN6WW.cjs.map} +1 -1
  52. package/dist/{chunk-3U6XE7SF.cjs → chunk-AZUPMHZI.cjs} +4 -4
  53. package/dist/{chunk-3U6XE7SF.cjs.map → chunk-AZUPMHZI.cjs.map} +1 -1
  54. package/dist/{chunk-CUYELFKB.cjs → chunk-EAH7LFJN.cjs} +4 -4
  55. package/dist/{chunk-CUYELFKB.cjs.map → chunk-EAH7LFJN.cjs.map} +1 -1
  56. package/dist/{chunk-GY4T4JSC.cjs → chunk-EFV52SZ6.cjs} +4 -4
  57. package/dist/{chunk-GY4T4JSC.cjs.map → chunk-EFV52SZ6.cjs.map} +1 -1
  58. package/dist/{chunk-SLVWSTFY.cjs → chunk-ELN3YOXF.cjs} +28 -28
  59. package/dist/{chunk-SLVWSTFY.cjs.map → chunk-ELN3YOXF.cjs.map} +1 -1
  60. package/dist/{chunk-YNFETLNZ.cjs → chunk-ER2MRSLT.cjs} +3 -3
  61. package/dist/{chunk-YNFETLNZ.cjs.map → chunk-ER2MRSLT.cjs.map} +1 -1
  62. package/dist/{chunk-5UNZO4FA.cjs → chunk-GLNL5AL5.cjs} +50 -50
  63. package/dist/{chunk-5UNZO4FA.cjs.map → chunk-GLNL5AL5.cjs.map} +1 -1
  64. package/dist/{chunk-YK3GUFZX.cjs → chunk-GZPNBSRE.cjs} +15 -15
  65. package/dist/{chunk-YK3GUFZX.cjs.map → chunk-GZPNBSRE.cjs.map} +1 -1
  66. package/dist/{chunk-H3CYXI46.cjs → chunk-HH5MKRBL.cjs} +7 -7
  67. package/dist/{chunk-H3CYXI46.cjs.map → chunk-HH5MKRBL.cjs.map} +1 -1
  68. package/dist/{chunk-4GMPS6VX.cjs → chunk-IRDL2EC6.cjs} +49 -49
  69. package/dist/{chunk-4GMPS6VX.cjs.map → chunk-IRDL2EC6.cjs.map} +1 -1
  70. package/dist/{chunk-VJFU2KKF.cjs → chunk-J46Y2L26.cjs} +4 -4
  71. package/dist/{chunk-VJFU2KKF.cjs.map → chunk-J46Y2L26.cjs.map} +1 -1
  72. package/dist/{chunk-PVT4EZUR.cjs → chunk-KD37PODE.cjs} +5 -5
  73. package/dist/{chunk-PVT4EZUR.cjs.map → chunk-KD37PODE.cjs.map} +1 -1
  74. package/dist/{chunk-JGU6YLIA.cjs → chunk-KQJUY2OE.cjs} +11 -11
  75. package/dist/{chunk-JGU6YLIA.cjs.map → chunk-KQJUY2OE.cjs.map} +1 -1
  76. package/dist/{chunk-MXM4BTXY.cjs → chunk-KZH6HMJL.cjs} +4 -4
  77. package/dist/{chunk-MXM4BTXY.cjs.map → chunk-KZH6HMJL.cjs.map} +1 -1
  78. package/dist/{chunk-XKQKHXRU.cjs → chunk-L3MYUPSH.cjs} +5 -5
  79. package/dist/{chunk-XKQKHXRU.cjs.map → chunk-L3MYUPSH.cjs.map} +1 -1
  80. package/dist/{chunk-SNYCK354.cjs → chunk-LYDSETR7.cjs} +5 -5
  81. package/dist/{chunk-SNYCK354.cjs.map → chunk-LYDSETR7.cjs.map} +1 -1
  82. package/dist/{chunk-X6TSOKEP.cjs → chunk-LYJFE37D.cjs} +3 -3
  83. package/dist/{chunk-X6TSOKEP.cjs.map → chunk-LYJFE37D.cjs.map} +1 -1
  84. package/dist/{chunk-NBW67JUB.cjs → chunk-OHWYQI3B.cjs} +12 -12
  85. package/dist/{chunk-NBW67JUB.cjs.map → chunk-OHWYQI3B.cjs.map} +1 -1
  86. package/dist/{chunk-CM2LUZ7K.cjs → chunk-QDIIOZBP.cjs} +30 -30
  87. package/dist/{chunk-CM2LUZ7K.cjs.map → chunk-QDIIOZBP.cjs.map} +1 -1
  88. package/dist/{chunk-WXRAU2FF.cjs → chunk-QSY2VW7V.cjs} +6 -6
  89. package/dist/{chunk-WXRAU2FF.cjs.map → chunk-QSY2VW7V.cjs.map} +1 -1
  90. package/dist/{chunk-ZLOPSDVW.cjs → chunk-RNQ3MDTR.cjs} +4 -4
  91. package/dist/{chunk-ZLOPSDVW.cjs.map → chunk-RNQ3MDTR.cjs.map} +1 -1
  92. package/dist/{chunk-QOTDPA62.cjs → chunk-SXC4ZIN4.cjs} +10 -10
  93. package/dist/{chunk-QOTDPA62.cjs.map → chunk-SXC4ZIN4.cjs.map} +1 -1
  94. package/dist/{chunk-W7TSEN3J.cjs → chunk-TLIZD6DV.cjs} +6 -6
  95. package/dist/{chunk-W7TSEN3J.cjs.map → chunk-TLIZD6DV.cjs.map} +1 -1
  96. package/dist/{chunk-NS7PWOL7.cjs → chunk-VD3HI5RF.cjs} +3 -3
  97. package/dist/{chunk-NS7PWOL7.cjs.map → chunk-VD3HI5RF.cjs.map} +1 -1
  98. package/dist/{chunk-6N7QT2DH.cjs → chunk-VDHBLDQC.cjs} +3 -3
  99. package/dist/{chunk-6N7QT2DH.cjs.map → chunk-VDHBLDQC.cjs.map} +1 -1
  100. package/dist/{chunk-6ZJBUMNK.cjs → chunk-VDT7TEAH.cjs} +3 -3
  101. package/dist/{chunk-6ZJBUMNK.cjs.map → chunk-VDT7TEAH.cjs.map} +1 -1
  102. package/dist/{chunk-SKIQ54TG.cjs → chunk-VJHDCYKE.cjs} +13 -13
  103. package/dist/{chunk-SKIQ54TG.cjs.map → chunk-VJHDCYKE.cjs.map} +1 -1
  104. package/dist/{chunk-MWJPCTBV.cjs → chunk-XKXKEVHH.cjs} +6 -6
  105. package/dist/{chunk-MWJPCTBV.cjs.map → chunk-XKXKEVHH.cjs.map} +1 -1
  106. package/dist/{chunk-DJ7LSKBJ.cjs → chunk-XQPJWPWE.cjs} +3 -3
  107. package/dist/{chunk-DJ7LSKBJ.cjs.map → chunk-XQPJWPWE.cjs.map} +1 -1
  108. package/dist/{chunk-XYMM6ZPS.cjs → chunk-Z6M2CI63.cjs} +65 -65
  109. package/dist/{chunk-XYMM6ZPS.cjs.map → chunk-Z6M2CI63.cjs.map} +1 -1
  110. package/dist/collaboration/index.cjs +13 -13
  111. package/dist/connect/docx.cjs +23 -23
  112. package/dist/connect/index.cjs +1204 -1204
  113. package/dist/connect/viewer.cjs +41 -41
  114. package/dist/dashboards/index.cjs +1 -1
  115. package/dist/embed/index.cjs +48 -48
  116. package/dist/facts/index.cjs +39 -39
  117. package/dist/files/index.cjs +221 -221
  118. package/dist/home/index.cjs +9 -9
  119. package/dist/index.cjs +1797 -1797
  120. package/dist/pages/index.cjs +31 -31
  121. package/dist/record/band.d.ts +95 -0
  122. package/dist/record/index.cjs +414 -13
  123. package/dist/record/index.cjs.map +1 -1
  124. package/dist/record/index.d.ts +35 -2
  125. package/dist/record/index.js +402 -15
  126. package/dist/record/index.js.map +1 -1
  127. package/dist/record/narration.d.ts +71 -0
  128. package/dist/settings/index.cjs +139 -139
  129. package/dist/shell/index.cjs +81 -81
  130. package/dist/studio/index.cjs +29 -29
  131. package/dist/styles.css +1 -1
  132. package/dist/workflow-canvas/index.cjs +64 -64
  133. package/dist/workspaces/index.cjs +5 -5
  134. package/node_modules/@arbidocs/coedit/package.json +1 -1
  135. package/package.json +11 -6
  136. package/record/SKILL.md +178 -26
  137. package/record/mix-take.py +320 -0
  138. package/record/recap-slide.mjs +118 -0
  139. package/record/voice-take.py +129 -0
  140. package/dist/ai-2B4BMS6O.cjs.map +0 -1
@@ -0,0 +1,118 @@
1
+ /**
2
+ * The closing recap slide of a narrated video, as PNGs, one per step: the story's points ticked off one
3
+ * by one as the voice names them, then the close (the title underlined, a thank-you). Styled with the
4
+ * brand the take recorded (its fonts and colours), like the edit's cards. Run by mix-take.py.
5
+ *
6
+ * node recap-slide.mjs <spec.json> <out dir>
7
+ *
8
+ * spec: { width, height, brand, recap: { kicker, title, lede, points: [{ title, detail }], closing } }.
9
+ * Writes step-0.png (nothing ticked) … step-N.png (all N ticked) and step-final.png.
10
+ */
11
+ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
12
+ import path from 'node:path'
13
+ import { pathToFileURL } from 'node:url'
14
+ import { chromium } from '@playwright/test'
15
+
16
+ const esc = (s = '') =>
17
+ s.replace(/[&<>"]/g, (ch) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' })[ch])
18
+
19
+ function css(b, w, h) {
20
+ const fonts = (b.fontFiles ?? [])
21
+ .map(
22
+ (f) =>
23
+ `@font-face { font-family: "${f.family}"; font-weight: ${f.weight ?? '100 900'}; src: url(${f.url});${f.unicodeRange ? ` unicode-range: ${f.unicodeRange};` : ''} }`
24
+ )
25
+ .join('\n')
26
+ return `${fonts}
27
+ :root { --from: ${b.coverFrom ?? '#0b1622'}; --mid: ${b.coverMid ?? '#0e1b2c'}; --to: ${b.coverTo ?? '#1f6feb'};
28
+ --accent: ${b.accent ?? '#c9a24b'}; --ink: ${b.ink ?? '#0e1b2d'}; --text: ${b.coverTitle ?? '#f4f6f8'};
29
+ --display: ${b.displayFont ?? 'ui-serif, Georgia, serif'}; --sans: ${b.sansFont ?? 'Inter, ui-sans-serif, system-ui, sans-serif'}; }
30
+ * { box-sizing: border-box; margin: 0; padding: 0; }
31
+ html, body { width: ${w}px; height: ${h}px; overflow: hidden; background: var(--from); color: var(--text);
32
+ font-family: var(--sans); -webkit-font-smoothing: antialiased; }
33
+ .slide { position: relative; width: ${w}px; height: ${h}px; overflow: hidden;
34
+ background: radial-gradient(70% 85% at 96% 112%, color-mix(in srgb, var(--to) 64%, transparent) 0%, transparent 62%),
35
+ radial-gradient(46% 58% at -4% -8%, color-mix(in srgb, var(--accent) 12%, transparent) 0%, transparent 70%),
36
+ linear-gradient(135deg, var(--from) 0%, var(--mid) 58%, var(--from) 100%); }
37
+ .slide::before { content: ""; position: absolute; inset: 40px; border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent); border-radius: 4px; }
38
+ .grid { position: absolute; inset: 0; display: grid; grid-template-columns: 0.9fr 1fr; column-gap: 110px; align-items: center;
39
+ padding: 120px 150px 170px; }
40
+ .kicker { text-transform: uppercase; letter-spacing: .28em; font-size: 22px; font-weight: 600; color: var(--accent); }
41
+ h1 { font-family: var(--display); font-weight: 560; font-size: 104px; line-height: 1.02; letter-spacing: -.02em; margin-top: 34px; }
42
+ h1 span { background: linear-gradient(var(--accent), var(--accent)) no-repeat 0 94% / 0% 7px; }
43
+ .final h1 span { background-size: 100% 7px; }
44
+ .lede { margin-top: 38px; font-size: 30px; line-height: 1.45; color: color-mix(in srgb, var(--text) 72%, transparent); max-width: 25ch; }
45
+ ol { list-style: none; }
46
+ li { display: grid; grid-template-columns: 58px 1fr; column-gap: 30px; padding: 30px 0;
47
+ border-top: 1px solid color-mix(in srgb, var(--accent) 24%, transparent); opacity: .3; }
48
+ li:last-child { border-bottom: 1px solid color-mix(in srgb, var(--accent) 24%, transparent); }
49
+ li.done { opacity: 1; }
50
+ .tick { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; margin-top: 4px;
51
+ border: 2px solid color-mix(in srgb, var(--accent) 75%, transparent); }
52
+ .tick svg { width: 30px; height: 30px; fill: none; stroke: var(--ink); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
53
+ li.done .tick { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 18%, transparent); }
54
+ li.done .tick svg { visibility: visible; }
55
+ .n { font-size: 17px; font-weight: 650; letter-spacing: .22em; color: var(--accent); }
56
+ li h2 { font-size: 37px; line-height: 1.18; font-weight: 600; letter-spacing: -.005em; margin-top: 8px; }
57
+ li p { font-size: 24px; line-height: 1.4; color: color-mix(in srgb, var(--text) 66%, transparent); margin-top: 8px; }
58
+ .foot { position: absolute; left: 150px; right: 150px; bottom: 92px; display: flex; align-items: center; justify-content: space-between; }
59
+ .mark { display: flex; align-items: center; gap: 16px; font-size: 22px; color: color-mix(in srgb, var(--text) 64%, transparent); }
60
+ .rule { width: 56px; height: 2px; background: var(--accent); }
61
+ .thanks { font-family: var(--display); font-size: 34px; font-weight: 500; color: var(--text); visibility: hidden; }
62
+ .thanks b { color: var(--accent); font-weight: 500; }
63
+ .final .thanks { visibility: visible; }
64
+ `
65
+ }
66
+
67
+ const TICK = '<svg viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>'
68
+
69
+ function markup(spec, done, final) {
70
+ const r = spec.recap
71
+ const [lead, last] = (() => {
72
+ const words = r.title.split(' ')
73
+ return [words.slice(0, -1).join(' '), words[words.length - 1]]
74
+ })()
75
+ const points = r.points
76
+ .map(
77
+ (p, i) => `<li class="${i < done ? 'done' : ''}"><div class="tick">${TICK}</div><div>
78
+ <div class="n">${String(i + 1).padStart(2, '0')}</div><h2>${esc(p.title)}</h2><p>${esc(p.detail)}</p></div></li>`
79
+ )
80
+ .join('')
81
+ return `<div class="slide${final ? ' final' : ''}"><div class="grid">
82
+ <div><div class="kicker">${esc(r.kicker)}</div><h1>${esc(lead)} <span>${esc(last)}</span></h1><p class="lede">${esc(r.lede)}</p></div>
83
+ <ol>${points}</ol></div>
84
+ <div class="foot"><div class="mark"><span class="rule"></span><span>${esc(spec.brand?.firmLabel ?? '')}</span></div>
85
+ <div class="thanks">${esc(r.closing)}</div></div></div>`
86
+ }
87
+
88
+ async function main() {
89
+ const [specFile, outDir] = process.argv.slice(2)
90
+ if (!specFile || !outDir) throw new Error('usage: recap-slide.mjs <spec.json> <out dir>')
91
+ const spec = JSON.parse(readFileSync(specFile, 'utf8'))
92
+ const { width: w, height: h } = spec
93
+ mkdirSync(outDir, { recursive: true })
94
+ const html = path.join(outDir, 'recap.html')
95
+ writeFileSync(
96
+ html,
97
+ `<!doctype html><html><head><meta charset="utf-8"><style>${css(spec.brand ?? {}, w, h)}</style></head><body><div id="o"></div></body></html>`
98
+ )
99
+ const browser = await chromium.launch()
100
+ try {
101
+ const page = await browser.newPage({ viewport: { width: w, height: h } })
102
+ await page.goto(pathToFileURL(html).href)
103
+ const n = spec.recap.points.length
104
+ const steps = [
105
+ ...Array.from({ length: n + 1 }, (_, i) => [`step-${i}`, i, false]),
106
+ ['step-final', n, true],
107
+ ]
108
+ for (const [name, done, final] of steps) {
109
+ await page.locator('#o').evaluate((el, m) => (el.innerHTML = m), markup(spec, done, final))
110
+ await page.evaluate(() => document.fonts.ready)
111
+ await page.screenshot({ path: path.join(outDir, `${name}.png`) })
112
+ }
113
+ } finally {
114
+ await browser.close()
115
+ }
116
+ }
117
+
118
+ await main()
@@ -0,0 +1,129 @@
1
+ """Speak a story's narration: one clip per line, and a manifest of their lengths for the story to pace by.
2
+
3
+ arbidocs-voice-take <story>.narration.json <out dir> --model <kokoro dir> [--ref <clip.wav>]
4
+
5
+ The narration is the story's script:
6
+
7
+ {"voice": "bf_lily", "lang": "en-gb", "speed": 1, "lines": [{"id", "text", "speech"?}], "recap": {...},
8
+ "spoken": [[pattern, said]], "phonemes": [[heard, meant]], "respell": [[pattern, said]]}
9
+
10
+ `text` is what the band shows; what is spoken is `speech` when given, else `text` with `spoken`
11
+ applied (regular expressions: a time, a web address, a name written one way and said another).
12
+ `phonemes` fixes what Kokoro's phonemiser gets wrong (its guess -> the word as it is said);
13
+ `respell` does the same for Chatterbox, which reads text, not phonemes.
14
+
15
+ The house voice is Kokoro's `bf_lily` in British English (82M, ONNX, offline, on the CPU):
16
+ `pip install kokoro-onnx soundfile` in a venv, and <kokoro dir> holding `model.onnx` and
17
+ `voices/<voice>.bin` (both from the Hugging Face repo onnx-community/Kokoro-82M-v1.0-ONNX).
18
+ `"engine": "chatterbox"` (with `exaggeration`, `cfg`) instead clones the voice of the clip given as
19
+ `--ref` (`pip install chatterbox-tts`; a GPU if there is one, else the CPU: slower, same voice,
20
+ about 4.6 GB of memory).
21
+
22
+ A line whose words, voice and speed have not changed is not spoken again. After changing
23
+ `phonemes` or `respell`, delete the clips of the lines they touch.
24
+ """
25
+ import argparse
26
+ import hashlib
27
+ import json
28
+ import re
29
+ import sys
30
+ from pathlib import Path
31
+
32
+ PAD = 0.06 # s of silence kept either side of the voice
33
+ HOUSE_VOICE = "bf_lily"
34
+ HOUSE_LANG = "en-gb"
35
+
36
+
37
+ def spoken(text, rules):
38
+ """`text` as it is said: each [pattern, said] rule applied in order."""
39
+ for pattern, said in rules:
40
+ text = re.sub(pattern, said, text)
41
+ return text
42
+
43
+
44
+ def clip_key(tag, said):
45
+ """A clip is spoken again only when this changes: the voice's settings and the words said."""
46
+ return hashlib.sha1(f"{tag}|{said}".encode()).hexdigest()[:12]
47
+
48
+
49
+ def main():
50
+ ap = argparse.ArgumentParser()
51
+ ap.add_argument("script")
52
+ ap.add_argument("out")
53
+ ap.add_argument("--model", help="Kokoro: directory with model.onnx and voices/<voice>.bin")
54
+ ap.add_argument("--ref", help="Chatterbox: reference clip of the voice to clone")
55
+ args = ap.parse_args()
56
+
57
+ import numpy as np
58
+ import soundfile as sf
59
+
60
+ script = json.loads(Path(args.script).read_text())
61
+ voice = script.get("voice", HOUSE_VOICE)
62
+ lang = script.get("lang", HOUSE_LANG)
63
+ speed = float(script.get("speed", 1.0))
64
+ out = Path(args.out)
65
+ out.mkdir(parents=True, exist_ok=True)
66
+ manifest_path = out / "manifest.json"
67
+ old = json.loads(manifest_path.read_text())["lines"] if manifest_path.exists() else {}
68
+
69
+ engine = script.get("engine", "kokoro")
70
+ if engine == "chatterbox":
71
+ if not args.ref:
72
+ sys.exit("engine chatterbox needs --ref <clip of the voice to clone>")
73
+ import torch
74
+ from chatterbox.tts import ChatterboxTTS
75
+ tts = ChatterboxTTS.from_pretrained(device="cuda" if torch.cuda.is_available() else "cpu")
76
+ ex, cfg = float(script.get("exaggeration", 0.5)), float(script.get("cfg", 0.5))
77
+ rate = tts.sr
78
+ respell = script.get("respell", [])
79
+
80
+ def render(said):
81
+ torch.manual_seed(0)
82
+ return tts.generate(spoken(said, respell), audio_prompt_path=args.ref, exaggeration=ex, cfg_weight=cfg).squeeze(0).cpu().numpy()
83
+ tag = f"cb|{Path(args.ref).name}|{ex}|{cfg}"
84
+ else:
85
+ if not args.model:
86
+ sys.exit("the Kokoro voice needs --model <directory with model.onnx and voices/>")
87
+ from kokoro_onnx import Kokoro
88
+ model = Path(args.model)
89
+ pack = model / f"voice-{voice}.npz"
90
+ if not pack.exists():
91
+ np.savez(pack, **{voice: np.fromfile(model / "voices" / f"{voice}.bin", dtype=np.float32).reshape(-1, 1, 256)})
92
+ kokoro = Kokoro(str(model / "model.onnx"), str(pack))
93
+ rate = 24000
94
+ fixes = script.get("phonemes", [])
95
+
96
+ def render(said):
97
+ phonemes = kokoro.tokenizer.phonemize(said, lang=lang)
98
+ for heard, meant in fixes:
99
+ phonemes = phonemes.replace(heard, meant)
100
+ audio, _ = kokoro.create(phonemes, voice=voice, speed=speed, lang=lang, is_phonemes=True)
101
+ return audio
102
+ tag = f"{voice}|{speed}"
103
+
104
+ rules = script.get("spoken", [])
105
+ lines = {}
106
+ for line in script["lines"]:
107
+ said = line.get("speech") or spoken(line["text"], rules)
108
+ key = clip_key(tag, said)
109
+ wav = out / f"{line['id']}.wav"
110
+ if old.get(line["id"], {}).get("key") == key and wav.exists():
111
+ lines[line["id"]] = {**old[line["id"]], "text": line["text"]}
112
+ continue
113
+ audio = np.asarray(render(said), np.float32)
114
+ loud = np.flatnonzero(np.abs(audio) > 0.01) # trim the model's own lead-in and tail
115
+ if loud.size:
116
+ audio = audio[max(0, loud[0] - int(0.02 * rate)):loud[-1] + int(0.08 * rate)]
117
+ audio = np.concatenate([np.zeros(int(PAD * rate), np.float32), audio, np.zeros(int(PAD * rate), np.float32)])
118
+ sf.write(wav, audio, rate, subtype="PCM_16")
119
+ lines[line["id"]] = {"text": line["text"], "spoken": said, "file": wav.name, "duration": round(len(audio) / rate, 3), "key": key,
120
+ "peak": round(float(np.abs(audio).max()), 3)}
121
+ print(f"{line['id']:10s} {lines[line['id']]['duration']:5.2f} s {said}", flush=True)
122
+
123
+ total = sum(v["duration"] for v in lines.values())
124
+ manifest_path.write_text(json.dumps({"voice": voice, "lang": lang, "speed": speed, "total": round(total, 2), "lines": lines}, indent=1))
125
+ print(f"{len(lines)} lines, {total:.1f} s of narration -> {manifest_path}")
126
+
127
+
128
+ if __name__ == "__main__":
129
+ main()
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"ai-2B4BMS6O.cjs"}