Nodes/ComfyUI MIDI Edit/MIDI Extract Lyrics
ComfyUI Node

MIDI Extract Lyrics

The reverse node — pull readable lyrics back out of a MIDI JSON

By ahkimkoo·Created 3 months ago·Updated about a month ago· 5
MIDI Extract Lyrics
    • lyrics_text
    midi_json
    merge_repeatedfalse
    resegmentfalse

    The reverse of the edit nodes: this one takes a MIDI JSON and hands you the lyrics as plain text. Sounds trivial until you remember how the JSON stores lyrics - space-separated tokens, <SP> pause markers, duplicated characters for held notes. Reading that by eye is misery. This node makes it human again.

    What it does by default

    Out of the box it's dead simple: concatenate the text field across all tracks, strip spaces, and turn <SP> into newlines. Because the phrasing follows the original song's pause structure, you get one line per pause-segment, roughly the way the original lyric was broken up.

    That makes it your sanity check after transcription. Run a song through MIDI Transcribe Audio, then Extract, and you'll see exactly what the ASR actually heard - worth doing before you spend time editing lyrics that were mis-transcribed.

    Inputs and output

    • midi_json - the track JSON.
    • merge_repeated (default OFF) - collapse consecutive duplicated characters to one. This is the same operation as running MIDI Merge Repeated Chars on the result, and it's your fix for held-note artifacts like 向向往.
    • resegment (default OFF) - the interesting one. This ignores the original <SP> phrasing entirely and re-flows the text: digits become Chinese numerals, spaces/newlines/punctuation get stripped, repeated characters get merged, and then the CT-Transformer punctuation model re-adds punctuation so the output comes back one natural sentence per line.

    Output is lyrics_text (STRING).

    Where resegment shines: when the original song's phrasing is chopped into awkward fragments (which transcription tends to produce) and you want clean natural-sentence boundaries to work from. Grab the output, rewrite from it, and feed it into MIDI Edit Lyrics or MIDI Lyrics Alignment as your new lyric.

    Gotchas

    Two things worth knowing. First, when resegment is ON, merge_repeated has no effect - the merge step is already baked into the resegment pipeline, so the switch is simply ignored. Second, resegment's first run auto-downloads the CT-Transformer punctuation model (~270 MB) to ComfyUI/models/ct-transformer-punc/, and the NLTK data auto-downloads alongside it. That's a one-time cost.

    No SoulX models needed for this node at all. Install is the standard pack recipe - ComfyUI Manager (search "ComfyUI MIDI Edit"), or manually:

    cd ComfyUI/custom_nodes
    git clone --recursive https://github.com/ahkimkoo/ComfyUI-MIDI-Edit.git
    pip install -r requirements.txt
    

    The --recursive is not a suggestion: without it the SoulX-Singer submodule directory comes up empty and the whole pack fails to import, even for nodes that never touch the synthesis engine. If you already cloned plain, git submodule update --init --recursive in the folder fixes it.

    CategoryMIDI-Edit

    Inputs (3)

    NameTypeDefaultDescription
    midi_jsonSTRING
    merge_repeatedBOOLEANfalse
    resegmentBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    lyrics_textSTRING