音乐 AI 评分系统

该项目,完全本地运行,无需联网依赖。

本项目使用 Hugging Face Transformers 的 CLAP(`laion/clap-htsat-fused`)对音频进行多维分析,目标是:

- 对一批待打分歌曲生成可排序的综合评分与标签,筛选更适合做 AI MV 推广的曲目

- 对歌曲进行提示词反推,辅助音乐制作/复刻方向的定位

- 统一导出 Excel 报表,便于快速浏览、筛选与运营决策

功能概览

- AI综合好听评分(0~100):基于音频-文本相似度的加权评分

- 曲风识别:输出“最可能曲风”并给出曲风 Top3 候选

- 反推创作提示词:从提示词库中匹配最相近的一条,便于复刻创作

- AI MV 推广筛选(更偏运营/投放):输出声学特征、AI MV 推广适配评分、情绪/视觉风格/平台 Top3 与剪辑建议

- Python:建议 3.10+(项目当前在 3.13 环境下运行过)

报表字段说明(核心)

- 歌曲名称:源文件名

- AI综合好听评分:0~100 的综合评分

- AI MV推广适配评分:0~100,偏向节奏清晰、能量稳定、易卡点的曲目

- 精细化识别曲风:Top1 曲风标签

- 曲风Top3:Top3 曲风候选(用于降低单标签误判)

- 情绪氛围Top3:用于 MV 视觉/文案定位

- MV视觉风格Top3:用于 AI MV 画面风格选择

- 推荐平台Top3:用于投放与分发渠道参考

- 剪辑建议:基于节奏与能量的剪辑策略提示

- 主调/BPM/节奏强度/能量均值/能量波动/亮度均值/时长秒:用于更细粒度的制作与运营筛选

- AI同款音乐复刻创作提示词:反推提示词(从提示词库匹配而来)

部分代码:

import os
import sys
import torch
import librosa
import numpy as np
import pandas as pd
from transformers import ClapModel, ClapProcessor

# ===================== 0. 终端编码兼容(Windows 控制台 GBK/CP936) =====================
def configure_console_output():
    """
    配置标准输出/错误输出的编码容错策略,避免 Windows 控制台(如 GBK/CP936)
    在打印包含特殊符号/表情字符时触发 UnicodeEncodeError。
    """
    for stream in (sys.stdout, sys.stderr):
        try:
            if hasattr(stream, "reconfigure"):
                stream.reconfigure(errors="replace")
        except Exception:
            pass


configure_console_output()

# ===================== 1. 设备自动选择 =====================
device = "cuda" if torch.cuda.is_available() else "cpu"
print("当前运行设备:", device)

# ===================== 2. 加载本地CLAP模型(全程离线) =====================
model_name = "laion/clap-htsat-fused"
processor = ClapProcessor.from_pretrained(model_name)
model = ClapModel.from_pretrained(model_name).to(device)
model.eval()

  • All rights reserved.
  • No part of this website, including text and images, may be reproduced, modified, distributed, or transmitted in any form or by any means, without the prior written permission of the author.
  • Unauthorized commercial use is strictly prohibited.
  • Unauthorized personal use is strictly prohibited.