ai iteration
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user