magenta/magenta-realtime

GitHub: magenta/magenta-realtime

Magenta RealTime 2 是一个用于实时音乐生成的开放权重模型,提供 Python 和 C++ 推理工具链,支持在 Apple Silicon 上进行流式音频生成并构建 DAW 插件与独立应用。

Stars: 1569 | Forks: 173

# Magenta RealTime 2 [![CLI 测试](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/eb3f42054d120858.svg)](https://github.com/magenta/magenta-realtime/actions/workflows/cli_tests.yml) Magenta RealTime 2 (MRT2) 是一个用于实时音乐生成的最先进开放权重模型。它包含几个关键组件: * 一个[开放权重模型](https://huggingface.co/google/magenta-realtime-2) * 一个[Python 库](README.md) `magenta-rt`,支持 JAX 和 MLX 后端进行推理 * 一个[C++ 推理引擎](core/README.md) `magentart::core`,用于在 Apple Silicon MacBook 上进行高效的流式音频生成 * 一套基于该推理引擎构建的[示例应用程序](examples/README.md)。 使用此项目可以运行推理、构建 DAW 插件,或将模型嵌入您设想的新应用程序中。 未来的更新将支持有监督微调。 📖 **完整文档:** https://magenta.github.io/magenta-realtime/ (或在本地构建 —— 参见 [`docs/README.md`](docs/README.md))。 ## 仓库亮点 - `magenta_rt/` — Python 推理库(JAX / MLX 后端)。 - `core/` — C++ 推理库(`magentart::core`)。 - `examples/mrt2/auv3` — 适用于 DAW 的多合一 AUv3 插件。 - `examples/mrt2/standalone` — 多合一独立 macOS 应用程序。 - `examples/jam/` — 用于探索音符控制的应用程序。 - `examples/collider/` — 用于探索提示空间的应用程序。 - `notebooks/` - 用于尝试 Python API 的 Notebook。 ## 硬件要求 **实时流式传输**需要 **Apple Silicon**(M 系列)。我们提供两种模型大小: - **`mrt2_small`**(230M 参数) — 可在任何 Apple Silicon Mac 上实时运行,包括 Air 型号。 - **`mrt2_base`**(2.4B 参数) — 质量更高;实时流式传输需要 Pro Max 芯片。 下表显示了哪些设备支持**实时流式传输**(生成音频的速度快于播放速度): | 设备 | `mrt2_small` (230M) | `mrt2_base` (2.4B) | |---|---|---| | M5 Max | ✅ | ✅ | | M3 Max | ✅ | ✅ | | M2 Max | ✅ | ✅ | | M4 Pro | ✅ | ✅ | | M2 Pro | ✅ | ❌ | | M1 Pro | ✅ | ❌ | | M4 Air | ✅ | ❌ | | M3 Air | ✅ | ❌ | | M1 Air | ✅ | ❌ | ## Apple Silicon 快速入门 ``` # 如果您尚未安装 uv,请先安装并创建一个 venv curl -LsSf https://astral.sh/uv/install.sh | sh uv venv --python 3.12 source .venv/bin/activate # 安装依赖项 (Python dev) uv pip install "magenta-rt[mlx]" # 下载资源:style model 和 codec model # (即,MusicCoCa 和 SpectroStream) mrt models init # 下载您想要使用的 streaming model mrt models download # 生成 4 秒音乐(若使用小模型,请改为 `mrt2_small`) mrt mlx generate --prompt "disco funk" --duration 4.0 --model=mrt2_base ``` ### Python 开发 对于本地开发,请克隆仓库而不是从 PyPI 安装: ``` git clone --recurse-submodules https://github.com/magenta/magenta-realtime.git cd magenta-realtime uv pip install -e ".[mlx]" ``` ### C++ 应用程序开发 要开始构建 C++ 应用程序,请执行以下设置: ``` # 安装依赖项 uv pip install "cmake<3.28" # 构建 hello_mrt2(一个基本的命令行界面) cmake . -B build cmake --build build --target hello_mrt2 -j10 # 生成 4 秒音乐 ./build/examples/hello_mrt2/hello_mrt2 \ ~/Documents/Magenta/magenta-rt-v2/models/mrt2_base/mrt2_base.mlxfn \ ~/Documents/Magenta/magenta-rt-v2/resources \ 100 \ --prompt "ambient pads with sub bass" ``` 查看完整文档: - [安装](docs/installation.md) - [模型与检查点](docs/models.md) - [推理](docs/inference.md) - [导出模型](docs/exporting.md) - [延迟基准测试](docs/benchmark.md) - [测试](docs/testing.md) ## 其他资源 - [入门指南](https://magenta.withgoogle.com/mrt2) - [博客文章](https://magenta.withgoogle.com/magenta-realtime-2) - [Hugging Face](https://huggingface.co/google/magenta-realtime-2) ## 引用此工作 请引用我们先前的[技术报告](https://arxiv.org/abs/2508.04651): **BibTeX:** ``` @article{gdmlyria2025live, title={Live Music Models}, author={Caillon, Antoine and McWilliams, Brian and Tarakajian, Cassie and Simon, Ian and Manco, Ilaria and Engel, Jesse and Constant, Noah and Li, Pen and Denk, Timo I. and Lalama, Alberto and Agostinelli, Andrea and Huang, Anna and Manilow, Ethan and Brower, George and Erdogan, Hakan and Lei, Heidi and Rolnick, Itai and Grishchenko, Ivan and Orsini, Manu and Kastelic, Matej and Zuluaga, Mauricio and Verzetti, Mauro and Dooley, Michael and Skopek, Ondrej and Ferrer, Rafael and Borsos, Zal{\'a}n and van den Oord, {\"A}aron and Eck, Douglas and Collins, Eli and Baldridge, Jason and Hume, Tom and Donahue, Chris and Han, Kehang and Roberts, Adam}, journal={arXiv:2508.04651}, year={2025} } ```
标签:Bash脚本, C++, JAX, 人工智能, 数字音频工作站插件, 数据擦除, 模型推理, 用户模式Hook绕过, 逆向工具, 音乐生成, 音频生成