@slidevideo/cli 0.1.1
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.
- package/CHANGELOG.md +33 -0
- package/IMPRESSUM.md +13 -0
- package/LICENSE-TERMS.md +58 -0
- package/README.md +25 -0
- package/addons/slidevideo/geometry.ts +127 -0
- package/addons/slidevideo/global-top.vue +232 -0
- package/addons/slidevideo/package.json +1 -0
- package/addons/slidevideo/playback-entries.ts +14 -0
- package/addons/slidevideo/preview.ts +157 -0
- package/dist/adapters/browser-runtime.d.ts +37 -0
- package/dist/adapters/browser-runtime.js +1 -0
- package/dist/adapters/edge.d.ts +7 -0
- package/dist/adapters/edge.js +46 -0
- package/dist/adapters/elevenlabs.d.ts +7 -0
- package/dist/adapters/elevenlabs.js +58 -0
- package/dist/adapters/powerpoint-preview.d.ts +2 -0
- package/dist/adapters/powerpoint-preview.js +18 -0
- package/dist/adapters/powerpoint.d.ts +21 -0
- package/dist/adapters/powerpoint.js +434 -0
- package/dist/adapters/registry.d.ts +4 -0
- package/dist/adapters/registry.js +13 -0
- package/dist/adapters/slidev-inputs.d.ts +1 -0
- package/dist/adapters/slidev-inputs.js +86 -0
- package/dist/adapters/slidev-inspection.d.ts +3 -0
- package/dist/adapters/slidev-inspection.js +79 -0
- package/dist/adapters/slidev-server.d.ts +1 -0
- package/dist/adapters/slidev-server.js +48 -0
- package/dist/adapters/slidev.d.ts +30 -0
- package/dist/adapters/slidev.js +251 -0
- package/dist/annotation-paint.d.ts +19 -0
- package/dist/annotation-paint.js +13 -0
- package/dist/annotations.d.ts +27 -0
- package/dist/annotations.js +115 -0
- package/dist/assembly.d.ts +48 -0
- package/dist/assembly.js +138 -0
- package/dist/calibration.d.ts +24 -0
- package/dist/calibration.js +346 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +180 -0
- package/dist/compositor.d.ts +18 -0
- package/dist/compositor.js +155 -0
- package/dist/contracts.d.ts +358 -0
- package/dist/contracts.js +1 -0
- package/dist/errors.d.ts +7 -0
- package/dist/errors.js +15 -0
- package/dist/executables.d.ts +23 -0
- package/dist/executables.js +165 -0
- package/dist/installation.d.ts +6 -0
- package/dist/installation.js +32 -0
- package/dist/license-key.d.ts +12 -0
- package/dist/license-key.js +55 -0
- package/dist/license-status.d.ts +16 -0
- package/dist/license-status.js +12 -0
- package/dist/media.d.ts +12 -0
- package/dist/media.js +57 -0
- package/dist/overlay-assets.d.ts +2 -0
- package/dist/overlay-assets.js +58 -0
- package/dist/pipeline.d.ts +50 -0
- package/dist/pipeline.js +257 -0
- package/dist/preview/contracts.d.ts +34 -0
- package/dist/preview/contracts.js +1 -0
- package/dist/preview/player.d.ts +1 -0
- package/dist/preview/player.js +129 -0
- package/dist/preview/server.d.ts +1 -0
- package/dist/preview/server.js +112 -0
- package/dist/preview/view.d.ts +1 -0
- package/dist/preview/view.js +36 -0
- package/dist/revoked-keys.json +1 -0
- package/dist/run.d.ts +12 -0
- package/dist/run.js +109 -0
- package/dist/setup-install.d.ts +7 -0
- package/dist/setup-install.js +98 -0
- package/dist/setup-license.d.ts +2 -0
- package/dist/setup-license.js +63 -0
- package/dist/setup.d.ts +34 -0
- package/dist/setup.js +218 -0
- package/dist/speech.d.ts +6 -0
- package/dist/speech.js +125 -0
- package/dist/storyboard.d.ts +6 -0
- package/dist/storyboard.js +86 -0
- package/dist/timing.d.ts +6 -0
- package/dist/timing.js +162 -0
- package/package.json +134 -0
- package/schemas/annotation-geometry.v1.json +130 -0
- package/schemas/revoked-keys.schema.json +11 -0
- package/schemas/run-manifest.v1.json +96 -0
- package/schemas/schedule.v1.json +108 -0
- package/schemas/schedule.v2.json +496 -0
- package/schemas/speech.v1.json +173 -0
- package/schemas/storyboard.v1.json +461 -0
- package/schemas/storyboard.v2.json +802 -0
- package/schemas/timing-evidence.v1.json +129 -0
- package/skills/slidevideo/SKILL.md +56 -0
- package/skills/slidevideo/references/production.md +76 -0
- package/skills/slidevideo/references/storyboard.md +272 -0
- package/tools/edge-tts/edge-tts.py +19 -0
- package/tools/edge-tts/requirements.lock +34 -0
- package/tools/powerpoint/Native.cs +277 -0
- package/tools/powerpoint/powerpoint.ps1 +714 -0
- package/tools/powerpoint/preview.ps1 +100 -0
- package/tools/powerpoint/requirements.json +11 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { AnnotationGeometry, ResolvedAnnotation, Schedule, ScheduledAction } from '../../dist/contracts.js'
|
|
2
|
+
import { annotationPaint, type AnnotationPaint } from '../../dist/annotation-paint.js'
|
|
3
|
+
import { playbackEntries } from './playback-entries'
|
|
4
|
+
import { geometryCollector } from './geometry'
|
|
5
|
+
|
|
6
|
+
type PreviewStatus = 'loading' | 'ready' | 'playing' | 'paused' | 'ended' | 'error'
|
|
7
|
+
export type PreviewLayer = AnnotationPaint & { id: string }
|
|
8
|
+
type Position = { slide: string; visit: string; click: number; index: number }
|
|
9
|
+
export function createPreview(
|
|
10
|
+
schedule: Schedule,
|
|
11
|
+
hashes: Record<string, string>,
|
|
12
|
+
parentOrigin: string,
|
|
13
|
+
prepare: (schedule: Schedule, hashes: Record<string, string>) => Promise<void>,
|
|
14
|
+
apply: (item: ScheduledAction) => Promise<void>,
|
|
15
|
+
position: () => Position,
|
|
16
|
+
layers: (value: PreviewLayer[]) => void,
|
|
17
|
+
) {
|
|
18
|
+
let status: PreviewStatus = 'loading'
|
|
19
|
+
let message = ''
|
|
20
|
+
let offset = 0
|
|
21
|
+
let origin = 0
|
|
22
|
+
let generation = 0
|
|
23
|
+
let frame = 0
|
|
24
|
+
let lastNotification = 0
|
|
25
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
26
|
+
let wake: (() => void) | undefined
|
|
27
|
+
let running: Promise<void> | undefined
|
|
28
|
+
let resetting: Promise<void> | undefined
|
|
29
|
+
let collector: ReturnType<typeof geometryCollector> | undefined
|
|
30
|
+
const geometry: AnnotationGeometry[] = []
|
|
31
|
+
const active = new Map<string, ResolvedAnnotation>()
|
|
32
|
+
const media = new Set<HTMLMediaElement>()
|
|
33
|
+
const animations = new Set<Animation>()
|
|
34
|
+
const entries: (ReturnType<typeof playbackEntries>[number] | { at: number; order: number; type: 'media-end'; id: string })[] = playbackEntries(schedule)
|
|
35
|
+
for (const item of schedule.actions) if (item.action.type === 'play') entries.push({ at: item.end_ms, order: 0, type: 'media-end', id: item.action.media })
|
|
36
|
+
entries.sort((a, b) => a.at - b.at || a.order - b.order)
|
|
37
|
+
|
|
38
|
+
const elapsed = () => Math.min(schedule.duration_ms, status === 'playing' ? offset + performance.now() - origin : offset)
|
|
39
|
+
function notify() {
|
|
40
|
+
window.parent.postMessage({ type: 'slidevideo-preview-state', status, elapsedMs: elapsed(), durationMs: schedule.duration_ms, ...(message ? { message } : {}) }, parentOrigin)
|
|
41
|
+
}
|
|
42
|
+
function interruptWait() {
|
|
43
|
+
clearTimeout(timer); timer = undefined
|
|
44
|
+
const resolve = wake; wake = undefined; resolve?.()
|
|
45
|
+
}
|
|
46
|
+
function freeze() {
|
|
47
|
+
for (const animation of document.getAnimations()) if (animation.playState === 'running' || animation.pending) { animation.pause(); animations.add(animation) }
|
|
48
|
+
for (const element of media) element.pause()
|
|
49
|
+
}
|
|
50
|
+
function stop() {
|
|
51
|
+
generation++; interruptWait(); cancelAnimationFrame(frame)
|
|
52
|
+
collector?.stop(); collector = undefined
|
|
53
|
+
for (const element of media) element.pause()
|
|
54
|
+
media.clear(); active.clear(); layers([])
|
|
55
|
+
}
|
|
56
|
+
function fail(error: unknown) {
|
|
57
|
+
offset = elapsed(); status = 'error'; message = error instanceof Error ? error.message : String(error)
|
|
58
|
+
freeze(); stop(); notify()
|
|
59
|
+
}
|
|
60
|
+
function paint() {
|
|
61
|
+
const output: PreviewLayer[] = []
|
|
62
|
+
for (const annotation of schedule.annotations ?? []) {
|
|
63
|
+
if (!active.has(annotation.id)) continue
|
|
64
|
+
const record = geometry.find(item => item.id === annotation.id)
|
|
65
|
+
if (!record) throw new Error(`Annotation ${annotation.id}: preview geometry is unavailable`)
|
|
66
|
+
const { bottom_border, ...fill } = annotationPaint(annotation, record)
|
|
67
|
+
output.push({ id: annotation.id, ...fill })
|
|
68
|
+
if (bottom_border) output.push({ id: `${annotation.id}:border`, ...bottom_border })
|
|
69
|
+
}
|
|
70
|
+
layers(output)
|
|
71
|
+
}
|
|
72
|
+
async function waitUntil(at: number, current: number) {
|
|
73
|
+
while (current === generation) {
|
|
74
|
+
const remaining = at - elapsed()
|
|
75
|
+
if (status === 'playing' && remaining <= 0) return true
|
|
76
|
+
await new Promise<void>(resolve => { wake = resolve; if (status === 'playing') timer = setTimeout(() => { timer = undefined; wake = undefined; resolve() }, Math.max(0, remaining)) })
|
|
77
|
+
}
|
|
78
|
+
return false
|
|
79
|
+
}
|
|
80
|
+
function tick() {
|
|
81
|
+
if (status !== 'playing' && status !== 'paused') return
|
|
82
|
+
if (status === 'paused') freeze()
|
|
83
|
+
if (performance.now() - lastNotification > 200) { notify(); lastNotification = performance.now() }
|
|
84
|
+
frame = requestAnimationFrame(tick)
|
|
85
|
+
}
|
|
86
|
+
async function run(current: number) {
|
|
87
|
+
try {
|
|
88
|
+
collector = geometryCollector(schedule.annotations ?? [], geometry, position, elapsed, fail)
|
|
89
|
+
for (const entry of entries) {
|
|
90
|
+
if (!await waitUntil(entry.at, current)) return
|
|
91
|
+
if (entry.type === 'start') { collector!.start(entry.annotation); active.set(entry.annotation.id, entry.annotation); paint() }
|
|
92
|
+
else if (entry.type === 'end') { collector!.end(entry.annotation); active.delete(entry.annotation.id); paint() }
|
|
93
|
+
else if (entry.type === 'media-end') {
|
|
94
|
+
const element = document.getElementById(entry.id)
|
|
95
|
+
if (element instanceof HTMLMediaElement) { element.pause(); media.delete(element) }
|
|
96
|
+
} else {
|
|
97
|
+
await apply(entry.item)
|
|
98
|
+
if (current !== generation) return
|
|
99
|
+
if (entry.item.action.type === 'play') {
|
|
100
|
+
const element = document.getElementById(entry.item.action.media)
|
|
101
|
+
if (element instanceof HTMLMediaElement) media.add(element)
|
|
102
|
+
}
|
|
103
|
+
if (status === 'paused') freeze()
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (!await waitUntil(schedule.duration_ms, current)) return
|
|
107
|
+
collector!.complete()
|
|
108
|
+
offset = schedule.duration_ms; status = 'ended'; stop(); notify()
|
|
109
|
+
} catch (error) { if (current === generation) fail(error) }
|
|
110
|
+
}
|
|
111
|
+
async function reset() {
|
|
112
|
+
stop(); await running
|
|
113
|
+
for (const animation of animations) animation.cancel()
|
|
114
|
+
animations.clear(); geometry.length = 0
|
|
115
|
+
offset = 0; status = 'loading'; message = ''; notify()
|
|
116
|
+
await prepare(schedule, hashes)
|
|
117
|
+
const first = schedule.actions[0]
|
|
118
|
+
if (first?.action.type === 'slide') await apply(first)
|
|
119
|
+
status = 'ready'; notify()
|
|
120
|
+
}
|
|
121
|
+
async function restart() {
|
|
122
|
+
if (!resetting) resetting = reset().catch(fail).finally(() => { resetting = undefined })
|
|
123
|
+
await resetting
|
|
124
|
+
}
|
|
125
|
+
async function play() {
|
|
126
|
+
await resetting
|
|
127
|
+
if (status === 'ended' || status === 'error') await restart()
|
|
128
|
+
if (status !== 'ready' && status !== 'paused') return
|
|
129
|
+
const resume = status === 'paused'
|
|
130
|
+
origin = performance.now(); status = 'playing'
|
|
131
|
+
for (const animation of animations) animation.play()
|
|
132
|
+
animations.clear()
|
|
133
|
+
try { for (const element of media) await element.play() } catch (error) { fail(error); return }
|
|
134
|
+
interruptWait(); notify()
|
|
135
|
+
if (!resume) { frame = requestAnimationFrame(tick); running = run(generation) }
|
|
136
|
+
}
|
|
137
|
+
function pause() {
|
|
138
|
+
if (status !== 'playing') return
|
|
139
|
+
offset = elapsed(); status = 'paused'; freeze(); interruptWait(); notify()
|
|
140
|
+
}
|
|
141
|
+
function receive(event: MessageEvent) {
|
|
142
|
+
if (event.source !== window.parent || event.origin !== parentOrigin || event.data?.type !== 'slidevideo-preview') return
|
|
143
|
+
if (event.data.action === 'hello') notify()
|
|
144
|
+
if (event.data.action === 'play') void play().catch(fail)
|
|
145
|
+
if (event.data.action === 'pause') pause()
|
|
146
|
+
if (event.data.action === 'restart') void restart().then(play).catch(fail)
|
|
147
|
+
}
|
|
148
|
+
window.addEventListener('message', receive)
|
|
149
|
+
return {
|
|
150
|
+
get status() { return status },
|
|
151
|
+
get elapsedMs() { return elapsed() },
|
|
152
|
+
durationMs: schedule.duration_ms,
|
|
153
|
+
play, pause, restart,
|
|
154
|
+
initialize: restart,
|
|
155
|
+
dispose() { stop(); window.removeEventListener('message', receive) },
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Schedule, ScheduledAction, ObservedEvent, AnnotationGeometry, PresentationInspection } from '../contracts.js';
|
|
2
|
+
export type PlaybackState = {
|
|
3
|
+
version: number;
|
|
4
|
+
phase: string;
|
|
5
|
+
events: ObservedEvent[];
|
|
6
|
+
markers: {
|
|
7
|
+
color: string;
|
|
8
|
+
observed_ms: number;
|
|
9
|
+
paint_interval_ms: number;
|
|
10
|
+
rendered_by_ms: number;
|
|
11
|
+
}[];
|
|
12
|
+
failure: string;
|
|
13
|
+
annotation_geometry?: AnnotationGeometry[];
|
|
14
|
+
};
|
|
15
|
+
export interface PlaybackRuntime {
|
|
16
|
+
version: number;
|
|
17
|
+
state: PlaybackState;
|
|
18
|
+
prepare(schedule: Schedule, expectedHashes?: Record<string, string>): Promise<void>;
|
|
19
|
+
play(verifyTiming?: boolean): Promise<void>;
|
|
20
|
+
apply(action: ScheduledAction): Promise<void>;
|
|
21
|
+
navigate(index: number, click?: number): Promise<void>;
|
|
22
|
+
inspectTargets(): Promise<PresentationInspection['annotation_targets']>;
|
|
23
|
+
media(id: string): HTMLMediaElement;
|
|
24
|
+
preview?: {
|
|
25
|
+
readonly status: string;
|
|
26
|
+
readonly elapsedMs: number;
|
|
27
|
+
readonly durationMs: number;
|
|
28
|
+
play(): Promise<void>;
|
|
29
|
+
pause(): void;
|
|
30
|
+
restart(): Promise<void>;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
declare global {
|
|
34
|
+
interface Window {
|
|
35
|
+
__slidevideo: PlaybackRuntime;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Narration, SpeechAsset, TtsAdapter, Voice } from '../contracts.js';
|
|
2
|
+
export declare class EdgeAdapter implements TtsAdapter {
|
|
3
|
+
id: string;
|
|
4
|
+
version: string;
|
|
5
|
+
validate(voice: Voice): void;
|
|
6
|
+
synthesize(segment: Narration, voice: Voice, destination: string): Promise<Omit<SpeechAsset, 'key'>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { rm } from 'node:fs/promises';
|
|
2
|
+
import { execute, saveJson, probe, decode, hashFile, audioDuration } from '../media.js';
|
|
3
|
+
import { ProductionError, requireCondition } from '../errors.js';
|
|
4
|
+
import { packagePath } from '../installation.js';
|
|
5
|
+
import { executable } from '../executables.js';
|
|
6
|
+
export class EdgeAdapter {
|
|
7
|
+
id = 'edge-tts';
|
|
8
|
+
version = '7.3.1-adapter-1';
|
|
9
|
+
validate(voice) {
|
|
10
|
+
for (const [key, value] of Object.entries(voice.options ?? {})) {
|
|
11
|
+
requireCondition(['rate', 'volume', 'pitch'].includes(key), 'VOICE_OPTION', `Edge TTS does not support option ${key}`, 3);
|
|
12
|
+
requireCondition(typeof value === 'string' && (key === 'pitch' ? /^[+-]\d+Hz$/ : /^[+-]\d+%$/).test(value), 'VOICE_OPTION', `Invalid Edge TTS ${key}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
async synthesize(segment, voice, destination) {
|
|
16
|
+
const request = `${destination}.request.json`;
|
|
17
|
+
await saveJson(request, { text: segment.text, voice: voice.voice, options: voice.options ?? {}, audio: destination });
|
|
18
|
+
let data;
|
|
19
|
+
try {
|
|
20
|
+
data = JSON.parse((await execute(executable('python'), [packagePath('tools', 'edge-tts', 'edge-tts.py'), request], 90000)).toString());
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw new ProductionError('TTS_PROVIDER', `Edge TTS failed for ${segment.id}: ${String(error)}`, 4);
|
|
24
|
+
}
|
|
25
|
+
finally {
|
|
26
|
+
await rm(request, { force: true });
|
|
27
|
+
}
|
|
28
|
+
requireCondition(data.version === '7.3.1', 'TTS_VERSION', `Install edge-tts 7.3.1, found ${data.version}`, 3);
|
|
29
|
+
let cursor = 0;
|
|
30
|
+
const units = data.words.map(word => {
|
|
31
|
+
const start = segment.text.indexOf(word.text, cursor);
|
|
32
|
+
requireCondition(start >= cursor, 'ALIGNMENT_MAPPING', `Edge word cannot map to transcript for ${segment.id}`, 4);
|
|
33
|
+
cursor = start + word.text.length;
|
|
34
|
+
return { ...word, start, end: cursor };
|
|
35
|
+
});
|
|
36
|
+
await decode(destination);
|
|
37
|
+
const properties = await probe(destination);
|
|
38
|
+
requireCondition(properties.has_audio && properties.duration_ms > 0, 'TTS_AUDIO', `Edge returned invalid audio for ${segment.id}`, 4);
|
|
39
|
+
return {
|
|
40
|
+
id: segment.id, audio: destination, sha256: await hashFile(destination), format: 'mp3', duration_ms: await audioDuration(destination),
|
|
41
|
+
transcript: { original: segment.text, normalized: segment.text },
|
|
42
|
+
alignment: { form: 'original', granularity: 'word', text: segment.text, units },
|
|
43
|
+
provenance: { adapter: this.id, version: this.version, provider: this.id, voice: voice.voice, options: voice.options ?? {}, generated_at: new Date().toISOString() },
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Narration, SpeechAsset, TtsAdapter, Voice } from '../contracts.js';
|
|
2
|
+
export declare class ElevenLabsAdapter implements TtsAdapter {
|
|
3
|
+
id: string;
|
|
4
|
+
version: string;
|
|
5
|
+
validate(voice: Voice): void;
|
|
6
|
+
synthesize(segment: Narration, voice: Voice, destination: string): Promise<Omit<SpeechAsset, 'key'>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { writeFile } from 'node:fs/promises';
|
|
2
|
+
import { requireCondition, ProductionError } from '../errors.js';
|
|
3
|
+
import { decode, hashFile, probe, executionScope, audioDuration } from '../media.js';
|
|
4
|
+
export class ElevenLabsAdapter {
|
|
5
|
+
id = 'elevenlabs';
|
|
6
|
+
version = '1';
|
|
7
|
+
validate(voice) {
|
|
8
|
+
const options = voice.options ?? {};
|
|
9
|
+
for (const key of Object.keys(options))
|
|
10
|
+
requireCondition(['model_id', 'stability', 'similarity_boost', 'speed'].includes(key), 'VOICE_OPTION', `ElevenLabs does not support option ${key}`, 3);
|
|
11
|
+
requireCondition(options.model_id === undefined || typeof options.model_id === 'string', 'VOICE_OPTION', 'model_id must be a string');
|
|
12
|
+
for (const key of ['stability', 'similarity_boost', 'speed']) {
|
|
13
|
+
const value = options[key];
|
|
14
|
+
requireCondition(value === undefined || typeof value === 'number' && Number.isFinite(value) && value >= (key === 'speed' ? 0.7 : 0) && value <= (key === 'speed' ? 1.2 : 1), 'VOICE_OPTION', `Invalid ElevenLabs ${key}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async synthesize(segment, voice, destination) {
|
|
18
|
+
const key = process.env.ELEVENLABS_API_KEY ?? process.env.ELEVENLABS_KEY;
|
|
19
|
+
requireCondition(key, 'TTS_CREDENTIAL', 'Set ELEVENLABS_API_KEY before generating speech', 4, { segment: segment.id });
|
|
20
|
+
const options = voice.options ?? {};
|
|
21
|
+
const { model_id = 'eleven_multilingual_v2', ...voice_settings } = options;
|
|
22
|
+
let response;
|
|
23
|
+
try {
|
|
24
|
+
response = await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(voice.voice)}/with-timestamps?output_format=mp3_44100_128`, {
|
|
25
|
+
method: 'POST', headers: { 'xi-api-key': key, 'Content-Type': 'application/json' },
|
|
26
|
+
body: JSON.stringify({ text: segment.text, model_id, voice_settings }), signal: AbortSignal.any([AbortSignal.timeout(90000), ...executionScope.getStore() ? [executionScope.getStore()] : []]),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
throw new ProductionError('TTS_NETWORK', `ElevenLabs request failed for ${segment.id}`, 4);
|
|
31
|
+
}
|
|
32
|
+
requireCondition(response.ok, 'TTS_PROVIDER', `ElevenLabs returned HTTP ${response.status} for ${segment.id}`, 4);
|
|
33
|
+
const data = await response.json();
|
|
34
|
+
requireCondition(typeof data.audio_base64 === 'string', 'TTS_RESPONSE', 'ElevenLabs returned no audio', 4);
|
|
35
|
+
const alignmentData = data.alignment ?? data.normalized_alignment;
|
|
36
|
+
let alignment = null;
|
|
37
|
+
if (alignmentData) {
|
|
38
|
+
let offset = 0;
|
|
39
|
+
alignment = {
|
|
40
|
+
form: data.alignment ? 'original' : 'normalized', granularity: 'character', text: alignmentData.characters.join(''),
|
|
41
|
+
units: alignmentData.characters.map((text, index) => {
|
|
42
|
+
const start = offset;
|
|
43
|
+
offset += text.length;
|
|
44
|
+
return { text, start, end: offset, start_ms: alignmentData.character_start_times_seconds[index] * 1000, end_ms: alignmentData.character_end_times_seconds[index] * 1000 };
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
await writeFile(destination, Buffer.from(data.audio_base64, 'base64'));
|
|
49
|
+
await decode(destination);
|
|
50
|
+
const properties = await probe(destination);
|
|
51
|
+
requireCondition(properties.has_audio && properties.duration_ms > 0, 'TTS_AUDIO', `Invalid generated speech ${segment.id}`, 4);
|
|
52
|
+
return {
|
|
53
|
+
id: segment.id, audio: destination, sha256: await hashFile(destination), format: 'mp3', duration_ms: await audioDuration(destination),
|
|
54
|
+
transcript: { original: segment.text, normalized: data.normalized_alignment?.characters.join('') ?? segment.text }, alignment,
|
|
55
|
+
provenance: { adapter: this.id, version: this.version, provider: this.id, voice: voice.voice, options, generated_at: new Date().toISOString() },
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function nativePreview(command) {
|
|
2
|
+
return {
|
|
3
|
+
async request(req, res) {
|
|
4
|
+
const url = new URL(req.url ?? '/', 'http://localhost');
|
|
5
|
+
const control = url.searchParams.get('command');
|
|
6
|
+
const action = req.method === 'GET' && url.pathname === '/native/frame' ? 'frame'
|
|
7
|
+
: req.method === 'POST' && url.pathname === '/native/control' && ['play', 'pause', 'restart'].includes(control ?? '') ? control : undefined;
|
|
8
|
+
if (!action) {
|
|
9
|
+
res.writeHead(404);
|
|
10
|
+
res.end();
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const state = await command(action);
|
|
14
|
+
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'no-store' });
|
|
15
|
+
res.end(JSON.stringify(state));
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { NativePreview } from '../preview/contracts.js';
|
|
2
|
+
import type { PresentationAdapter, PresentationInspection, ProductionOptions, ProgressReporter, Schedule, Storyboard, VisualArtifact } from '../contracts.js';
|
|
3
|
+
export declare class PowerPointAdapter implements PresentationAdapter {
|
|
4
|
+
readonly id = "powerpoint";
|
|
5
|
+
readonly version = "native-2";
|
|
6
|
+
private deck?;
|
|
7
|
+
private session?;
|
|
8
|
+
private cleanupPromise?;
|
|
9
|
+
private prepared?;
|
|
10
|
+
inspect(file: string): Promise<PresentationInspection>;
|
|
11
|
+
private targets;
|
|
12
|
+
inspectTargets(_story: Storyboard): Promise<PresentationInspection['annotation_targets']>;
|
|
13
|
+
private slide;
|
|
14
|
+
validate(story: Storyboard, _inspection: PresentationInspection, schedule?: Schedule): void;
|
|
15
|
+
private operations;
|
|
16
|
+
prepare(story: Storyboard, schedule: Schedule, directory: string, production?: ProductionOptions): Promise<void>;
|
|
17
|
+
startPreview(story: Storyboard, schedule: Schedule, directory: string): Promise<NativePreview>;
|
|
18
|
+
private openPlayback;
|
|
19
|
+
execute(progress?: ProgressReporter): Promise<VisualArtifact>;
|
|
20
|
+
cleanup(): Promise<void>;
|
|
21
|
+
}
|