🎤

랩 AI 모델 카탈로그 — 가사 생성, 라임 감지, 플로우 분석까지

GPT-2 랩 파인튜닝 모델 + pronouncing 라임 분석 + 실행 가능한 코드 전부

1. 랩 가사 생성 — input → model → output

가장 추천: Elida-Sensoy/gpt2-rap-generator

GPT-2를 랩 가사(Eminem 스타일 포함)로 파인튜닝한 모델. pipeline()으로 바로 돌린다.

from transformers import pipeline, set_seed

# 모델 로드 (~500MB 자동 다운로드)
generator = pipeline("text-generation", model="Elida-Sensoy/gpt2-rap-generator")
set_seed(42)

# input → model → output
results = generator(
    "I walk the streets at night",  # 시작 문구
    max_length=200,
    num_return_sequences=3,         # 3개 버전 생성
    temperature=1.75,               # 높을수록 창의적 (1.0=보통, 2.0=파격)
    top_p=0.95,
    do_sample=True,
    pad_token_id=50256
)

for i, r in enumerate(results):
    print(f"--- 버전 {i+1} ---")
    print(r["generated_text"])

기대 결과: 입력 문구에 이어서 라임이 맞는 랩 가사가 생성된다. 다중 음절 라임, 내부 라임(internal rhyme) 패턴을 학습했다.

다른 모델 옵션:

모델 크기 특징 난이도
Elida-Sensoy/gpt2-rap-generator ~500 MB 영어 랩 특화, 라임 밀도 높음 ★☆☆☆☆
flax-community/gpt2-rap-lyric-generator ~500 MB 10K+ 곡 학습, 데모 Space 있음 ★☆☆☆☆
weej16/rap-lyrics-qwen-0.6b 600 MB Qwen3 기반, 최신 (2026) ★★☆☆☆
harishchaurasia/gpt2-lyrics-model-fine-tuned ~500 MB 400K 가사 학습 (��� 특화 아님) ★☆☆☆☆
petkopetkov/Qwen2.5-0.5B-song-lyrics-generation 500 MB 다국어 가사 생성 ★★☆☆☆
petkopetkov/SmolLM2-135M-Instruct-song-lyrics-generation 135 MB 가장 가벼움 ★☆☆☆☆

2. 라임 감지 — "이 두 단어가 라임이 맞나?"

HuggingFace에 라임 감지 전용 모델은 없다. 대신 pronouncing 라이브러리가 CMU 발음 사전 기반으로 라임을 정확하게 판별한다.

pip install pronouncing

import pronouncing

# 라임 찾기
rhymes = pronouncing.rhymes("flow")
print(rhymes[:10])
# → ['aglow', 'ago', 'below', 'bestow', 'blow', 'bow', 'chateau', 'crow', 'doe', 'doh']

# 두 단어가 라임하는지 확인
def do_they_rhyme(word1, word2):
    return word2 in pronouncing.rhymes(word1)

print(do_they_rhyme("cat", "hat"))    # → True
print(do_they_rhyme("cat", "dog"))    # → False
print(do_they_rhyme("flow", "know"))  # → True
print(do_they_rhyme("money", "honey")) # → True

3. 음소·강세 분석 — "이 단어의 발음 구조는?"

import pronouncing

# 음소 (발음 기호) 조회
phones = pronouncing.phones_for_word("rapping")
print(phones)
# → ['R AE1 P IH0 NG']
# R=r, AE1=강세있는 'æ', P=p, IH0=약한 'ɪ', NG=ng

# 강세 패턴
stresses = pronouncing.stresses_for_word("rapping")
print(stresses)
# → ['10']  (1=강세, 0=비강세 → 강-약)

stresses2 = pronouncing.stresses_for_word("incredible")
print(stresses2)
# → ['0100']  (약-강-약-약)

4. 가사 생성 + 라임 체크 조합

생성된 가사의 라임을 자동으로 검증하는 파이프라인:

from transformers import pipeline
import pronouncing
import re

# 1. 가사 생성
generator = pipeline("text-generation", model="Elida-Sensoy/gpt2-rap-generator")
result = generator("Money on my mind", max_length=150, do_sample=True,
                   temperature=1.5, top_p=0.95, pad_token_id=50256)
lyrics = result[0]["generated_text"]

# 2. 줄 단위로 분리
lines = [l.strip() for l in lyrics.split("\n") if l.strip()]

# 3. 각 줄의 마지막 단어 추출
def last_word(line):
    words = re.findall(r"[a-zA-Z']+", line)
    return words[-1].lower() if words else ""

# 4. 연속된 줄의 라임 체크
print("=== 라임 분석 ===")
for i in range(len(lines) - 1):
    w1 = last_word(lines[i])
    w2 = last_word(lines[i + 1])
    rhymes = w2 in pronouncing.rhymes(w1) if w1 and w2 else False
    status = "✓ 라임" if rhymes else "✗ 노라임"
    print(f"  {w1:15s} / {w2:15s} → {status}")
    print(f"    {lines[i]}")
    print(f"    {lines[i+1]}")

기대 출력:

=== 라임 분석 ===
  mind            / grind           → ✓ 라임
    Money on my mind
    Every day I hustle and grind
  grind           / line            → ✗ 노라임
    Every day I hustle and grind
    Walking on the thin line

5. 음절 수 분석 — 플로우 측정

pip install syllables

import syllables

# 줄별 음절 수 → 플로우의 밀도
lines = [
    "Money on my mind every single day",
    "Hustle never stops I just pave the way",
    "Yo",
]

for line in lines:
    count = syllables.estimate(line)
    words = len(line.split())
    print(f"  음절:{count:3d}  단어:{words:2d}  밀도:{count/max(words,1):.1f}  | {line}")
# → 음절: 10  단어: 7  밀도:1.4  | Money on my mind every single day
# → 음절: 10  단어: 8  밀도:1.2  | Hustle never stops I just pave the way
# → 음절:  1  단어: 1  밀도:1.0  | Yo

음절 수가 비슷한 줄끼리 짝을 이루면 플로우가 안정적이다.

6. 비트 분석 — 오디오에서 BPM·비트 위치

가사가 비트에 맞는지 확인하려면 오디오 분석이 필요하다:

pip install librosa

import librosa

y, sr = librosa.load("beat.mp3")
tempo, beat_frames = librosa.beat.beat_track(y=y, sr=sr)
beat_times = librosa.frames_to_time(beat_frames, sr=sr)

print(f"BPM: {tempo:.0f}")
print(f"비트 위치 (초): {beat_times[:8]}")
# → BPM: 90
# → 비트 위치 (초): [0.46 1.13 1.81 2.48 3.16 3.83 4.51 5.18]

학습 데이터셋

직접 파인튜닝하고 싶다면:

데이터셋 내용 크기
Cropinky/rap_lyrics_english 영어 랩 가사 (Genius), 50+ 래퍼 10K+ 곡
nateraw/rap-lyrics-v1 영어 랩 가사 1K~10K
theelderemo/genius-lyrics-cleaned 장르별 가사 (rap/pop/rock) 1M+
Dr3dre/Genius-song-lyrics-cleaned Genius 전체 가사 5M+ 곡

관련 연��

DeepRapper (Microsoft Research Asia, ACL 2021) — Transformer 기반 랩 생성. 라임 + 리듬(비트)을 동시에 모델링. 역순 가사 생성 + 라임 제약 방식이 독특하다. 다만 공개 모델은 없다.

난이도 정리

난이도 할 수 있는 것 도구
★☆☆☆☆ 랩 가사 생성 pipeline() + gpt2-rap-generator
★☆☆☆☆ 라임 찾기/확인 pronouncing
★★☆☆☆ 생성 + 라임 자동 검증 pipeline + pronouncing 조합
★★☆☆☆ 음절/강세 분석 pronouncing + syllables
★★☆☆☆ 비트 분석 (BPM) librosa
★★★☆☆ 특정 래퍼 스타일 파인튜닝 HuggingArtists + Genius API
★★★★☆ 비트에 맞는 가사 생성 DeepRapper 방식 (직접 구현)

핵심 개념

1

가사 생성 — pipeline(\"text-generation\", model=\"gpt2-rap-generator\")로 랩 가사 생성

2

라임 감지 — pronouncing.rhymes(\"flow\")로 라임 단어 목록 조회

3

음소·강세 분석 — pronouncing.phones_for_word()로 발음 구조 파악

4

라임 자동 검증 — 생성된 가사의 줄 끝 단어가 라임하는지 자동 체크

5

비트 분석 — librosa.beat.beat_track()으로 BPM·비트 위치 추출

사용 사례

랩 가사 작성 보조 — AI가 생성한 가사를 베이스로 수정·발전 라임 품질 측정 — 가사의 라임 밀도·패턴을 자동 분석 랩 교육 — 음절 수·강세 패턴으로 플로우의 구조를 시각화