Package-level declarations

Types

Link copied to clipboard
data class InstrumentalBreakOptions(val instrumentalGapMs: Double? = null)

How instrumental lines are added between sung ones.

Link copied to clipboard

The LyricParser for LRC, plain and enhanced. It cleans up the timing after parseLRC; see there.

Link copied to clipboard

The lyrics formats this package reads.

Link copied to clipboard
data class LyricMetadata(val songwriters: List<String>)

Song-level credits a lyrics file carries alongside its lines.

Link copied to clipboard
interface LyricParser

A parser for one lyrics format. detectParser picks the right one for a document.

Link copied to clipboard
data class ParsedTTML(val lyrics: List<Lyric>, val isWordSynced: Boolean, val language: String? = null)

What parseTTMLContent reads from a TTML document.

Link copied to clipboard
data class ParseTTMLOptions(val songDurationMs: Double? = null, val instrumentalGapMs: Double? = null)

Options for parseTTMLContent.

Link copied to clipboard

The LyricParser for text without timing: a lyric per line of text, all at 0.

Link copied to clipboard
data class QrcMetadata(val title: String? = null, val artist: String? = null)

Song metadata, used to drop opening lines that only echo the title or the artist.

Link copied to clipboard

The LyricParser for QQ Music's QRC, see parseQRC.

Link copied to clipboard

The LyricParser for SRT subtitles: a lyric per cue.

Link copied to clipboard
typealias SyncType = LyricSyncType

LyricSyncType under the name this package published first.

Link copied to clipboard

Functions

Link copied to clipboard

Which format input is in. TTML is tried first, then LRC, SRT and QRC; anything else is LyricFormat.PLAIN.

Link copied to clipboard

The parser for input's format, as detectFormat tells it. Never fails: text in no known format is read as plain lyrics, a line per line of text.

Link copied to clipboard
fun insertInstrumentalBreaks(lyrics: List<Lyric>, songDurationMs: Double, gapThreshold: Double? = DEFAULT_INSTRUMENTAL_GAP_MS): List<Lyric>

Turn the silences between lines into explicit instrumental lyrics, so a renderer has something to show during an intro, a solo or an outro instead of holding the last sung line on screen.

Link copied to clipboard
fun isLrc(input: String): Boolean

Whether input looks like LRC: it has a [mm:ss.xx] time stamp.

Link copied to clipboard
fun isQrc(input: String): Boolean

Whether input looks like QRC: QQ Music's <QrcInfos> envelope, or [start,duration] line and (start,duration) word stamps.

Link copied to clipboard
fun isSrt(input: String): Boolean

Whether input looks like SRT: it has a numbered cue with a --> time range.

Link copied to clipboard
fun isTtml(input: String): Boolean

Whether input looks like TTML: it has a <tt> element.

Link copied to clipboard
fun lrcFixers(lyrics: List<Lyric>)

Evens out the word timing of enhanced LRC in place, as Kugou's and Musixmatch's need: a space timed like the word before it gives its time to that word, and when most words last 100 ms or less, each short word is held until the next one starts (no longer than its line). LRCParser runs it after parseLRC; call it yourself only for such sources, since clean timings would be changed too.

Link copied to clipboard
fun parseLRC(lrcText: String, songDurationMs: Double, options: InstrumentalBreakOptions = InstrumentalBreakOptions()): List<Lyric>

Parse an LRC document, plain or enhanced, into lines with optional word level parts.

Link copied to clipboard
fun parseQRC(qrcXml: String, songDurationMs: Double, metadata: QrcMetadata? = null): List<Lyric>

Parse a QRC document, either the <QrcInfos> envelope QQ Music returns or a bare QRC body.

Link copied to clipboard

The singers' names, by the agent ids lines carry once parsed (v1, v2, …, v1000 for a group), as the document's head gives them (<ttm:agent xml:id="…" type="person"><ttm:name>…</ttm:name>). Not upstream, which reads no names: for a host that shows who sings. Agents without a name are left out.

Link copied to clipboard
fun parseTTMLContent(xml: String, options: ParseTTMLOptions = ParseTTMLOptions()): ParsedTTML

Parses a TTML document (Apple Music's, and the community formats built on it): lines, word or syllable timing, background vocals, singers, translations and romanizations. TTMLParser calls this with the default options; call it directly for the song's duration or another gap threshold.