ai iteration

This commit is contained in:
2025-08-08 18:27:10 +02:00
parent 512521e9d0
commit 1d51176311
9 changed files with 2880 additions and 49 deletions

View File

@@ -1,11 +1,14 @@
import * as fs from "fs";
import * as path from "path";
function toSrtTime(seconds: number): string {
const date = new Date(0);
date.setSeconds(seconds);
const timeString = date.toISOString().substr(11, 12);
return timeString.replace(".", ",");
function toSrtTime(secondsFloat: number): string {
const totalMs = Math.max(0, Math.round(secondsFloat * 1000));
const hours = Math.floor(totalMs / 3600000);
const minutes = Math.floor((totalMs % 3600000) / 60000);
const seconds = Math.floor((totalMs % 60000) / 1000);
const ms = totalMs % 1000;
const pad = (n: number, w: number) => n.toString().padStart(w, "0");
return `${pad(hours, 2)}:${pad(minutes, 2)}:${pad(seconds, 2)},${pad(ms, 3)}`;
}
export function createSrt(storyName: string, chunks: string[], chunkDurations: number[]): string {