Instructions to use moonbox-dev/magenta-realtime-2-small-ONNX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Magenta RT
How to use moonbox-dev/magenta-realtime-2-small-ONNX with Magenta RT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Magenta RealTime 2 (small) ONNX
ONNX builds of Magenta RealTime 2 (small), made by Moonbox for on-device use with ONNX Runtime (CPU, CUDA, DirectML). Each precision is one folder; what the graphs take and return, and the signal processing that goes around them, is under How to run.
Files
The last column is the benchmark on the VoiceBank-DEMAND test set (824 noisy utterances; details under How to run): each precision's speech-quality scores, and how far its output is from the original PyTorch model's.
| Precision | File | Size | sha256 | Benchmark |
|---|---|---|---|---|
| fp16 | fp16/codec.onnx |
213.7 MB | 9ff6a5e07cf7 |
fp16 weights, fp32 math (temporal and depth transformers; the codec and MusicCoCa as fp32): KL 1.8e-6 (p95 3.3e-6), top-1 99.9 % (level 0: 100 %), codec 99.5 dB, style tokens equal on 3 of 3 prompts; 32.4 frames/s (CUDA) |
| fp16 | fp16/config.json |
1.0 kB | 36fa9d8d4def |
(the same build: numbers in its first row) |
| fp16 | fp16/depth.onnx |
74.0 MB | 9861ee641c01 |
(the same build: numbers in its first row) |
| fp16 | fp16/mapper.onnx |
86.2 MB | 4886045a5748 |
(the same build: numbers in its first row) |
| fp16 | fp16/music_encoder.onnx |
371.0 MB | 56a066efaffc |
(the same build: numbers in its first row) |
| fp16 | fp16/musiccoca_audio.npz |
0.5 MB | 1893693359f8 |
(the same build: numbers in its first row) |
| fp16 | fp16/pipeline.py |
20.5 kB | bde31b193e61 |
(the same build: numbers in its first row) |
| fp16 | fp16/pretrained_vector_quantizer.onnx |
72.4 MB | 5063e3009b51 |
(the same build: numbers in its first row) |
| fp16 | fp16/spm.model |
0.5 MB | ff325a99b61b |
(the same build: numbers in its first row) |
| fp16 | fp16/states.npz |
12.9 MB | a5d612a010d5 |
(the same build: numbers in its first row) |
| fp16 | fp16/temporal.onnx |
410.9 MB | c96e243d03ff |
(the same build: numbers in its first row) |
| fp16 | fp16/text_encoder.onnx |
419.4 MB | 9c79116eaa91 |
(the same build: numbers in its first row) |
| int8 | int8/codec.onnx |
213.7 MB | 9ff6a5e07cf7 |
weight-only int8 (temporal and depth transformers; the codec and MusicCoCa as fp32): KL 0.0047 (p95 0.0087), top-1 94.1 % (level 0: 97.7 %), codec 99.5 dB, style tokens equal on 3 of 3 prompts; 27.9 frames/s (CUDA) |
| int8 | int8/config.json |
1.0 kB | 36fa9d8d4def |
(the same build: numbers in its first row) |
| int8 | int8/depth.onnx |
37.3 MB | 2fd81f64d503 |
(the same build: numbers in its first row) |
| int8 | int8/mapper.onnx |
86.2 MB | 4886045a5748 |
(the same build: numbers in its first row) |
| int8 | int8/music_encoder.onnx |
371.0 MB | 56a066efaffc |
(the same build: numbers in its first row) |
| int8 | int8/musiccoca_audio.npz |
0.5 MB | 1893693359f8 |
(the same build: numbers in its first row) |
| int8 | int8/pipeline.py |
20.5 kB | bde31b193e61 |
(the same build: numbers in its first row) |
| int8 | int8/pretrained_vector_quantizer.onnx |
72.4 MB | 5063e3009b51 |
(the same build: numbers in its first row) |
| int8 | int8/spm.model |
0.5 MB | ff325a99b61b |
(the same build: numbers in its first row) |
| int8 | int8/states.npz |
12.9 MB | a5d612a010d5 |
(the same build: numbers in its first row) |
| int8 | int8/temporal.onnx |
208.2 MB | 0d6c565d13f7 |
(the same build: numbers in its first row) |
| int8 | int8/text_encoder.onnx |
419.4 MB | 9c79116eaa91 |
(the same build: numbers in its first row) |
How to run
Magenta RealTime 2, the small model (Google DeepMind; a live music model: it generates 48 kHz stereo music 40 ms at
a time, steered by a text or audio prompt that can change while it plays), as ONNX graphs and pipeline.py, a numpy
runtime that does the rest:
temporal.onnx: one step of the temporal transformer (12 layers) on the frame's 144 conditioning tokens (12 MusicCoCa style tokens, 128 piano-roll notes, drums, CFG scales) and the previous frame's 12 codes, with its attention state (a 41-frame window plus attention sinks) as inputs and outputs -> a hidden state.depth.onnx: one step of the depth transformer, run 12 times a frame (one per residual codebook level), each giving the logits of that level's next code.codec.onnx: one step of the SpectroStream decoder, the frame's 12 codes -> 1920 stereo samples.text_encoder.onnx,mapper.onnx,pretrained_vector_quantizer.onnx,spm.model: MusicCoCa's text path, a prompt -> its 12 style tokens;music_encoder.onnxandmusiccoca_audio.npz: its audio path (a clip of music as the prompt).states.npz,config.json: the initial states and the original's constants and defaults.pipeline.py: the conditioning, the original's sampling (each level's logits outside its 1024 codes masked, top-k 40, Gumbel noise times the temperature 1.3, argmax) and the streaming loop. On CUDA the three step graphs run as CUDA graphs with their states kept on the GPU. Needs numpy, onnx, onnxruntime (or onnxruntime-gpu) and sentencepiece; soundfile for the command line.
import sys; sys.path.insert(0, "fp16")
import soundfile as sf
from pipeline import MagentaRT2
mrt = MagentaRT2("fp16", providers=["CUDAExecutionProvider", "CPUExecutionProvider"])
sf.write("funk.wav", mrt.generate("disco funk", seconds=10), 48000) # float32 [samples, 2]
stream = mrt.stream("ambient pads with sub bass") # live: one 40 ms frame per call
for _ in range(250):
chunk = stream.step() # [1920, 2]
stream.set_style("heavy metal guitar solo") # a new prompt (or CFG scales, notes, drums) between frames
Precisions. fp16/: the transformers' weights stored in fp16 and cast to fp32 where they are read, so the
arithmetic is fp32 (with fp16 arithmetic the error grows over the stream: KL 0.69). int8/: the transformers'
weights int8 per output channel, activations fp32. In both, the codec and MusicCoCa are the fp32 graphs.
Benchmark. Against the original (magenta_rt's JAX system in fp32 on the CPU) on 3 prompts ("disco funk", "ambient pads with sub bass", "heavy metal guitar solo"), 10 s each: the original generates, then the ONNX graphs are teacher-forced on its codes. KL is the mean KL divergence of each level's code distribution from the original's (nats; p95 in brackets), top-1 the share of steps whose most likely code is the original's; codec SNR is the decoded audio against the original's decode of the same codes (worst prompt); style tokens: MusicCoCa's tokens equal to the original's. Pass (music language model): KL <= 0.01 and top-1 >= 90 %, codec >= 30 dB, style tokens equal. Speed: frames generated per second (real time is 25) on an RTX 3080 Laptop GPU, whole pipeline.
| KL | top-1 | codec SNR (dB) | style tokens | frames / s | |
|---|---|---|---|---|---|
| original, bf16 (its accelerator default) | 0.0018 (0.0031) | 94.4 % | - | - | - |
fp16/ (CUDA) |
1.8e-6 (3.3e-6) | 99.9 % | 99.5 | 3 / 3 | 32.4 |
int8/ (CUDA) |
0.0047 (0.0087) | 94.1 % | 99.5 | 3 / 3 | 27.9 |
A 4-bit build (MatMulNBits, block 32) is not published: KL 0.35, top-1 55 %.
How these were made
From Magenta RealTime 2 (small) at revision 010aa0dcb0, starting from an fp32 ONNX graph (where it came from is said above).
fp16: onnxconverter-common with inputs and outputs kept fp32, or, where the network's activations leave fp16's
range, fp16 weights with fp32 math (said above when so). int8: weight-only, every Conv / MatMul / GRU weight int8
with a per-output-channel scale behind DequantizeLinear and activations in fp32, so it runs on the CPU provider
without a calibration set. int4: ONNX Runtime's MatMulNBits (weight-only, block 32) on the MatMul weights, the rest
int8 as above, where the graph has enough MatMul weights to matter. No bf16: ONNX Runtime has no bf16 convolution or
GRU kernels. Every graph was benchmarked before upload; the sha256 column above is what the files must hash to.
License
CC-BY-4.0 (weights) / Apache-2.0 (code). These files are a derivative of the original model and carry its license: it is copied in this repository, and it governs your use of these files. The original model card follows unchanged.
Original model card
Model Card for Magenta RealTime 2
Authors: Google DeepMind
Resources:
Terms of Use
Magenta RealTime 2 is offered under a combination of licenses: the codebase is licensed under Apache 2.0, and the model weights under Creative Commons Attribution 4.0 International. In addition, we specify the following usage terms:
Copyright 2026 Google LLC
Use these materials responsibly and do not generate content, including outputs, that infringe or violate the rights of others, including rights in copyrighted content.
Google claims no rights in outputs you generate using Magenta RealTime 2. You and your users are solely responsible for outputs and their subsequent uses.
Unless required by applicable law or agreed to in writing, all software and materials distributed here under the Apache 2.0 or CC-BY licenses are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the licenses for the specific language governing permissions and limitations under those licenses. You are solely responsible for determining the appropriateness of using, reproducing, modifying, performing, displaying or distributing the software and materials, and any outputs, and assume any and all risks associated with your use or distribution of any of the software and materials, and any outputs, and your exercise of rights and permissions under the licenses.
Model Details
Magenta RealTime 2 is an open music generation model from Google built for on device streaming generation with low-latency control. It is a live music model and a follow up to the prior Magenta RealTime model and Lyria RealTime API, offering on-device generation with richer control and lower latency. Magenta RealTime 2 enables the continuous generation of musical audio steered by text prompts, audio examples, and MIDI.
System Components
Magenta RealTime 2 is composed of three components: SpectroStream, MusicCoCa, and an LLM. The structure is similar to that of the original Magenta RealTime, detailed here. The primary difference is the LLM, which is now a Decoder-only model supporting frame-wise autoregression (rather than chunk-wise) and tuned for on-device streaming with frame-level control.
- SpectroStream (Li+ 25) is a discrete audio codec that converts stereo 48kHz audio into tokens.
- MusicCoCa is a contrastive-trained model capable of embedding audio and text into a common embedding space, building on Yu+ 22 and Huang+ 22.
- A decoder-only Transformer LLM generates audio tokens given context
audio tokens, a tokenized MusicCoCa embedding, and MIDI tokens. There are
two configurations:
- A
baseconfiguration with 2.4B parameters - A
smallconfiguration with 230M parameters
- A
Inputs and outputs
- SpectroStream RVQ codec: Tokenizes high-fidelity music audio
- Encoder input / Decoder output: Music audio waveforms, 48kHz stereo
- Encoder output / Decoder input: Discrete audio tokens, 25Hz frame rate, 64 RVQ depth, 10 bit codes, 16kbps
- MusicCoCa: Joint embeddings of text and music audio
- Input: Music audio waveforms, 16kHz mono, or text representation of music style e.g. "heavy metal"
- Output: 768 dimensional embedding, quantized to 12 RVQ depth, 10 bit codes
- Decoder Transformer LLM: Generates audio tokens given context, MIDI,
and style. At each timestep (codec frame), the model receives:
- Input:
- (Context) SpectroStream tokens
base: 25 frame (1s) windowed attention per layer, 20 layerssmall: 41 frame (~1.6s) windowed attention per layer, 12 layers- Yields 20s effective receiptive field for both models
- (Style) 12 MusicCoCa tokens
- (MIDI) 128-dim multihot vector representing the state of each MIDI pitch during this frame (0 = Off, 1 = Sustain, 2 = Onset, 3 = Sustain or onset, model decides)
- (Context) SpectroStream tokens
- Output: 1 generated frame, 12 RVQ tokens
- Input:
Uses
Music generation models, in particular ones targeted for continuous real-time generation and control, have a wide range of applications across various industries and domains. The following list of potential uses is not comprehensive. The purpose of this list is to provide contextual information about the possible use-cases that the model creators considered as part of model training and development.
- Interactive Music Creation
- Live Performance / Improvisation: These models can be used to generate music in a live performance setting, controlled by performers manipulating style embeddings or the audio context
- Accessible Music-Making & Music Therapy: People with impediments to using traditional instruments (skill gaps, disabilities, etc.) can participate in communal jam sessions or solo music creation.
- Video Games: Developers can create a custom soundtrack for users in real-time based on their actions and environment.
- Research
- Transfer learning: Researchers can leverage representations from MusicCoCa and Magenta RT 2 to recognize musical information.
- Personalization
- Musicians can finetune models with their own catalog to customize the model to their style (fine tuning support coming soon).
- Education
- Exploring Genres, Instruments, and History: Natural language prompting enables users to quickly learn about and experiment with musical concepts.
Out-of-Scope Use
See our Terms of Use above for usage we consider out of scope.
Bias, Risks, and Limitations
Magenta RT 2 supports the real-time generation and steering of instrumental music. The purpose and intention of this capability is to foster the development of new real-time, interactive co-creation workflows that seamlessly integrate with human-centered forms of musical creativity.
Every AI music generation model, including Magenta RT 2, carries a risk of impacting the economic and cultural landscape of music. We aim to mitigate these risks through the following avenues:
- Prioritizing human-AI interaction as fundamental in the design of Magenta RT 2.
- Distributing the model under a terms of service that prohibit developers from generating outputs that infringe or violate the rights of others, including rights in copyrighted content.
- Training on primarily instrumental data. With specific prompting, this model has been observed to generate some vocal sounds and effects, though those vocal sounds and effects tend to be non-lexical.
Known limitations
Magenta RealTime 2 has similar limitations to Magenta RealTime in terms of genre coverage and non lexical vocalizations, refer here for details.
Benefits
At the time of release, Magenta RealTime 2 represents the only open weights model supporting real-time, continuous musical audio generation with low latency control (~200ms). It is designed specifically to enable live, interactive musical creation, bringing new capabilities to musical performances, art installations, video games, and many other applications.
How to Get Started with the Model
See our Get Started Page and GitHub repository for usage examples.
Training Details
Training Data
Magenta RealTime 2 was trained on ~71k hours of stock music from multiple sources, mostly instrumental.
Hardware
Magenta RealTime 2 was trained using Tensor Processing Unit (TPU) hardware.
Software
Training was done using JAX and Sequence Layers. JAX allows researchers to take advantage of the latest generation of hardware, including TPUs, for faster and more efficient training of large models.
Evaluation
Model evaluation metrics and results will be shared in our forthcoming technical report.
Citation
A paper about Magenta RealTime 2 is forthcoming. For now, please cite our previous technical report:
BibTeX:
@inproceedings{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},
booktitle={NeurIPS Creative AI},
year={2025}
}
Model tree for moonbox-dev/magenta-realtime-2-small-ONNX
Base model
google/magenta-realtime-2