UNPKG

justlyrics

Version:

A comprehensive TypeScript library for parsing, converting, and processing various lyric formats including LRC, ALRC, YRC, QRC, and more

302 lines 9.48 kB
export declare namespace CoreLyric { class Timestamp { static max(...timestamps: (Timestamp | null)[]): Timestamp; static min(...timestamps: (Timestamp | null)[]): Timestamp; milliSeconds: number; constructor(milliSeconds: number); seconds(): number; formatted(): string; } enum VoiceAgentType { Vocal = "vocal", BackgroundVocal = "background-vocal", Other = "other" } interface VoiceAgent { /** * The type of the voice agent. */ type: VoiceAgentType; /** * The number of the voice agent. Should be above 0 (included). 0 stands for unknown, and singers should start from 1. */ n: number; } interface SyllableAnnotation { syllable: string; role: LineAnnotationRole; } interface Syllable { text: string; start: Timestamp | null; end: Timestamp | null; annotations: SyllableAnnotation[]; } enum LineAnnotationRole { Prononciation = "pron", Translation = "trans" } interface LineAnnotation { role: LineAnnotationRole; line: CoreLyric.LineSyncedLine; } class SyllableSyncedLine { syllables: Syllable[]; voiceAgent: VoiceAgent | null; annotations: LineAnnotation[]; constructor(opt: { syllables: Syllable[]; voiceAgent: VoiceAgent | null; annotations: LineAnnotation[]; }); toLineSyncedLine(): LineSyncedLine; extractAnnotations(role: LineAnnotationRole): LineSyncedLine[]; } class LineSyncedLine { static checkOverlap(a: LineSyncedLine, b: LineSyncedLine): boolean; static fromText(tr: string): LineSyncedLine; text: string; start: Timestamp | null; end: Timestamp | null; voiceAgent: VoiceAgent | null; annotations: LineAnnotation[]; constructor(opt: { text: string; start?: Timestamp | null; end?: Timestamp | null; voiceAgent?: VoiceAgent | null; annotations?: LineAnnotation[]; }); extractAnnotations(role: LineAnnotationRole): LineSyncedLine[]; } type LineType = SyllableSyncedLine | LineSyncedLine; namespace Utils { function extractLineAnnotations(lines: LineType[], role: LineAnnotationRole): LineSyncedLine[]; function splitWordSyllables(syl: Syllable): Syllable[]; function preprocessLinesForLyricify(lines: LineType[]): LineType[]; } } export declare namespace LyricIO { namespace Abstraction { namespace ALRC { interface ALRCLyricInfo { lng?: string; author?: string; translation?: string; timeline?: string; transliteration?: string; proofread?: string; offset?: number; duration?: number; } interface ALRCHeader { s: ALRCStyle[]; } interface ALRCStyle { id: string; p?: ALRCStylePosition; c?: string; t?: ALRCStyleAccent; h?: boolean; } enum ALRCStylePosition { Undefined = 0, Left = 1, Center = 2, Right = 3 } enum ALRCStyleAccent { Normal = 0, Background = 1, Whisper = 2, Emphasise = 3 } interface ALRCLine { /** * The unique identifier for the line. */ id?: string; /** * The identifier for the parent line. */ p?: string; /** * The start time of the line in milliseconds. */ f?: number; /** * The end time of the line in milliseconds. */ t?: number; /** * The style of the line. */ s?: string; /** * A comment related to the line. */ comment?: string; /** * The raw text of the line. */ tx?: string; /** * The transliteration of the line. */ lt?: string; /** * The translation of the line. */ tr?: string; /** * A list of words in the line. */ w?: ALRCWord[]; } /** * Represents a word in an ALRCLine. */ interface ALRCWord { /** * The start time of the word in milliseconds. */ f: number; /** * The end time of the word in milliseconds. */ t: number; /** * The word itself. */ w: string; /** * The style of the word, if any. * This property is optional. */ s?: string; /** * The transliteration of the word, if any. * This property is optional. */ l?: string; } interface ALRCFile { /** * The lyrics metadata of the file. */ li?: ALRCLyricInfo; /** * Custom song info of the file. */ si?: any; /** * The header of the file. */ h?: ALRCHeader; /** * List of lines in the file. */ l: ALRCLine[]; } } } namespace Dumping { namespace YRC { interface HeaderContentPart { tx: string; li?: string; or?: string; } interface HeaderLine { t: number; c: HeaderContentPart[]; } interface CreateHeaderParams { lyricists: string[]; musicians: string[]; } function createHeaderLines(data: CreateHeaderParams): HeaderLine[]; } namespace LQE { function createLQEPartHeader(data: { [key: string]: string; }): string; } function dumpLYS(lines: CoreLyric.LineType[]): string; function dumpLRC(lines: CoreLyric.LineType[]): string; function dumpLYL(lines: CoreLyric.LineType[]): string; function dumpQRC(lines: CoreLyric.LineType[]): string; function dumpYRC(lines: CoreLyric.LineType[]): string; function dumpALRC(lines: CoreLyric.LineType[]): string; function dumpSRT(lines: CoreLyric.LineType[]): string; function dumpLQE(lines: CoreLyric.LineType[]): string; function dumpSPL(lines: CoreLyric.LineType[]): string; function dump(type: LyricFormat.Type, lines: CoreLyric.LineType[]): string; function supportDump(type: LyricFormat.Type): boolean; } } export declare namespace LyricFormat { const TYPES: { lys: { displayName: string; extensions: string[]; }; lyl: { displayName: string; extensions: string[]; }; lqe: { displayName: string; extensions: string[]; }; lrc: { displayName: string; extensions: string[]; }; alrc: { displayName: string; extensions: string[]; }; ttml: { displayName: string; extensions: string[]; }; ttml_amll: { displayName: string; extensions: string[]; }; apple_syllable: { displayName: string; extensions: string[]; }; yrc: { displayName: string; extensions: string[]; }; qrc: { displayName: string; extensions: string[]; }; krc: { displayName: string; extensions: string[]; }; srt: { displayName: string; extensions: string[]; }; spl: { displayName: string; extensions: string[]; }; }; type Type = keyof typeof TYPES; const allTypes: Type[]; function getLyricFormatDisplayName(formatType: Type): string; function getLyricFormatFileExtensions(formatType: Type): string[]; function requestReadLyricsFile(description: string, languageExtensions: string[]): Promise<string | null>; function requestWriteLyricsFile(description: string, languageExtensions: string[], content: string, options?: { fileName?: string; }): Promise<boolean>; } //# sourceMappingURL=lyric.d.ts.map