@leelaing/transcripts
v0.1.0
Published
Transcript and song-lyric parsing utilities for SRT, VTT, LRC, TXT, JSON, and Whisper Music phrase JSON.
Readme
@lcharleslaing/transcripts
Transcript and song-lyric parsing utilities for SRT, VTT, LRC, TXT, JSON, and Whisper Music phrase JSON.
Supported formats
- SRT
- WebVTT / VTT
- LRC
- TXT
- Generic JSON segment/chunk formats
- Whisper Music phrase JSON, including
.phrase.jsonand.phrases.json
All formats normalize to the same structure:
interface TranscriptLine {
start: number | null;
end: number | null;
text: string;
}
interface Transcript {
format: TranscriptFormat;
lines: TranscriptLine[];
text: string;
}Phrase-level Whisper Music chunks stay phrase-level; they are not merged into larger subtitle blocks.
Usage
import { detectTranscriptFormat, parseTranscript } from '@lcharleslaing/transcripts';
const content = '[00:01.20]First lyric line\n[00:03.40]Second lyric line';
const format = detectTranscriptFormat(content, 'song.lrc');
const transcript = parseTranscript(content, { filename: 'song.lrc' });
console.log(format); // lrc
console.log(transcript.lines);You can force a known format:
const transcript = parseTranscript(jsonContent, {
format: 'phrase-json'
});JSON compatibility
The JSON parser recognizes common collections such as:
segmentslinesitemstranscriptphrasesphrase_segmentsphraseSegmentschunks
Common text fields include text, phrase, content, line, lyrics, and lyric.
Common timing fields include start, start_time, startTime, end, end_time, endTime, duration, and related aliases.
Development
npm install
npm startQuality checks
npm run checkBuild
npm run buildLicense
MIT
