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

Function detectJsonFormat

packages/cli/src/whisper/normalize.ts:45–58  ·  view source on GitHub ↗
(raw: unknown)

Source from the content-addressed store, hash-verified

43}
44
45function detectJsonFormat(raw: unknown): TranscriptFormat {
46 if (raw && typeof raw === "object" && !Array.isArray(raw)) {
47 const obj = raw as Record<string, unknown>;
48 if (obj.transcription && Array.isArray(obj.transcription)) return "whisper-cpp";
49 if (obj.words && Array.isArray(obj.words)) return "openai";
50 }
51 if (Array.isArray(raw) && raw[0]?.text !== undefined && raw[0]?.start !== undefined) {
52 return "words-json";
53 }
54 throw new Error(
55 "Unrecognized JSON transcript format. Expected whisper.cpp (transcription[].tokens), " +
56 "OpenAI API (words[]), or normalized ([{text, start, end}]).",
57 );
58}
59
60// ---------------------------------------------------------------------------
61// Parsers

Callers 2

detectFormatFunction · 0.85
loadTranscriptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected