NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

TeleMelody: Lyric-to-Melody Generation with a Template-Based Two-Stage Method

Zeqian Ju, Peiling Lu, Xu Tan, Rui Wang, Chen Zhang, Songruoyao Wu, Kejun Zhang, Xiang-Yang Li, Tao Qin, Tie-Yan Liu

Introduction

Generating a melody from lyrics (L2M) is a fundamental task in computer music that requires a model to understand the complex relationship between linguistic rhythm and musical structure. Traditional end-to-end systems often struggle with this task due to three primary hurdles: a lack of high-quality paired training data, limited user control over musical elements like tonality or chords, and the inherent complexity of mapping raw text directly to MIDI notes in a "black box" fashion.

TeleMelody addresses these issues by introducing a two-stage framework that uses a musical Template as an intermediate bridge. This approach decomposes the difficult L2M problem into two more manageable sub-problems, mimicking the workflow of human songwriters.

The TeleMelody Framework

The TeleMelody pipeline consists of two distinct modules designed to separate the linguistic processing from the musical generation.

The two-stage pipeline of TeleMelody.
  1. Lyric-to-Template (L2T): This stage predicts the musical structure from the input text. It utilizes a Transformer-based model to predict rhythm patterns and a rule-based mapping to determine cadences (musical pauses) based on punctuation. Tonality and chord progressions can either be provided by the user for maximum control or inferred automatically.
  2. Template-to-Melody (T2M): This stage uses an encoder-decoder Transformer to generate the final melody notes based on the template. By decoupling the lyrics from the final note generation, this module can be trained on massive amounts of unpaired MIDI data, effectively solving the data scarcity bottleneck.

The Musical Template: A Bridge Between Text and Music

The core innovation of TeleMelody is the explicit intermediate representation known as the Template. This template encodes four key musical elements that guide the generation process:

  • Tonality: The key of the piece (e.g., C major).
  • Chord Progression: The harmonic foundation (e.g., I-IV-V-I).
  • Rhythm Pattern: The timing of the notes relative to the syllables.
  • Cadence: Structural points of rest or resolution.
Example of the musical template elements.

By using this template, users can achieve fine-grained controllability. For instance, a user can generate a melody for a set of lyrics and then easily change the tonality from major to minor or swap the chord progression without needing to re-process the lyrics.

Training Strategy and Alignment

To ensure high-quality output, TeleMelody employs two key training strategies:

  • Self-Supervised Training: The T2M module is trained using a self-supervised approach. Templates are extracted from existing MIDI files using rule-based methods, allowing the model to learn how to translate structural templates into melodic notes without requiring paired lyrics.
  • Alignment Regularization: To ensure the generated melody strictly follows the template, the authors introduce a loss function that forces the model's attention mechanism to align specific melody notes with their corresponding template elements (e.g., ensuring a note's pitch is harmonically consistent with the current chord).

Results and Evaluation

TeleMelody was evaluated against state-of-the-art models like SongMASS and standard Transformer baselines using both objective and subjective metrics.

  • Objective Performance: TeleMelody achieved significantly higher similarity in pitch distribution (PD) and duration distribution (DD). In English tasks, it reached a PD of 43.86%, compared to 34.32% for SongMASS.
  • Subjective Quality: Human evaluators, including professional musicians, rated TeleMelody higher across all categories: Harmony, Rhythm, Structure, and overall Quality. On a 5-point scale, TeleMelody earned a quality score of 3.3 for English melodies, while SongMASS scored 2.2.
  • Data Efficiency: The framework proved highly robust; even when trained on only 50% of the available paired data, it continued to outperform the baselines, demonstrating the power of its self-supervised T2M stage.

Conclusion

TeleMelody represents a significant step forward in controllable lyric-to-melody generation. By introducing a template-based two-stage pipeline, it overcomes data scarcity and provides users with intuitive control over the musical structure. Future work may involve expanding the template to include elements like musical style and emotion, or scaling the model to capture even more complex musical distributions.

Summary updated

BibTeX
@inproceedings{ju2022telemelody,
  author = {Zeqian Ju and Peiling Lu and Xu Tan and Rui Wang and Chen Zhang and Songruoyao Wu and Kejun Zhang and Xiang-Yang Li and Tao Qin and Tie-Yan Liu},
  title = {{TeleMelody: Lyric-to-Melody Generation with a Template-Based Two-Stage Method}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  doi = {10.18653/v1/2022.emnlp-main.364},
}
Figure