MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / detectFormat

Function detectFormat

packages/cli/src/whisper/normalize.ts:37–43  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

35 * Detect the format of a transcript file from its extension and content.
36 */
37export function detectFormat(filePath: string): TranscriptFormat {
38 const ext = extname(filePath).toLowerCase();
39 if (ext === ".srt") return "srt";
40 if (ext === ".vtt") return "vtt";
41 if (ext === ".json") return detectJsonFormat(JSON.parse(readFileSync(filePath, "utf-8")));
42 throw new Error(`Unsupported transcript file extension: ${ext}. Use .json, .srt, or .vtt`);
43}
44
45function detectJsonFormat(raw: unknown): TranscriptFormat {
46 if (raw && typeof raw === "object" && !Array.isArray(raw)) {

Callers 1

normalize.test.tsFile · 0.85

Calls 1

detectJsonFormatFunction · 0.85

Tested by

no test coverage detected