Magenta RT: Live Music Generation on Your Local Device
This repository profile is provided by osrepos.com, an open source repository discovery platform.
Summary
Magenta RealTime (Magenta RT) is an open-source Python library for live music audio generation on local devices. It allows users to create music using both text and audio prompts, serving as a powerful tool for real-time creative audio exploration. This library is the on-device companion to Google's MusicFX DJ Mode and the Lyria RealTime API.
Repository Information
Topics
Click on any tag to explore related repositories
Use at your own risk
OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.
Introduction
Magenta RealTime (Magenta RT) is an open-source Python library designed for live music audio generation directly on your local device. It serves as the on-device companion to Google's MusicFX DJ Mode and the Lyria RealTime API, enabling users to create music through both text and audio prompts. Magenta RT generates audio in short chunks (2 seconds) given a finite amount of past context (10 seconds), utilizing crossfading to mitigate boundary artifacts between chunks.
Installation
Getting started with Magenta RT is straightforward, offering options for cloud-based demos or local setup.
The fastest way to experience Magenta RT is through its official Colab Demo, which runs in real-time on freely available TPUs. Additionally, there are Colab demos supporting live audio input and customization via finetuning.
For local execution, you can choose between using Docker or performing a native installation.
Running Locally via Docker
This method requires a powerful GPU with 40GB memory, Linux, and Docker.
mkdir -p ~/.cache/magenta_rt
docker run -it \
--gpus device=0 \
-v ~/.cache/magenta_rt:/magenta-realtime/cache \
-p 8000:8000 \
us-docker.pkg.dev/brain-magenta/magenta-rt/magenta-rt:gpu
After running the command, open the web demo at https://localhost:8000.
Local Installation
If you prefer to run Magenta RT natively rather than using Docker, follow these instructions.
Step 1: Install Python 3.12
sudo apt update
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.12 python3.12-venv python3.12-dev -y
Step 2: Install Magenta RT for GPU
# Clone Magenta RT
git clone https://github.com/magenta/magenta-realtime.git
cd magenta-realtime
# Create a virtual environment
python3.12 -m venv .venv
source .venv/bin/activate
# Patch and install t5x
git clone https://github.com/google-research/t5x.git && \
pushd t5x && \
git checkout 7781d16 && \
patch setup.py < ../patch/t5x_setup.py.patch && \
patch t5x/partitioning.py < ../patch/t5x_partitioning.py.patch && \
pip install .[gpu] && \
popd
# Install Magenta RT
pip install -e .[gpu] && pip install tf2jax==0.3.8
# Patch seqIO to remove tensorflow-text dependency
patch .venv/lib/python3.12/site-packages/seqio/vocabularies.py < patch/seqio_vocabularies.py.patch
Step 2 (alternative): Install Magenta RT for TPU
# Create a virtual environment
python3.12 -m venv .venv
source .venv/bin/activate
# Install Magenta RT
git clone https://github.com/magenta/magenta-realtime.git
pip install -e magenta-realtime/[tpu] && pip install tf2jax==0.3.8 huggingface_hub
Step 3: Generate!
python -m magenta_rt.generate \
--prompt="blissful ambient synth" \
--output="./output.mp3"
Examples
Magenta RT offers powerful capabilities for music generation and style blending.
Generating audio with Magenta RT
from magenta_rt import audio, system
from IPython.display import display, Audio
num_seconds = 10
mrt = system.MagentaRT()
style = system.embed_style('funk')
chunks = []
state = None
for i in range(round(num_seconds / mrt.config.chunk_length)):
state, chunk = mrt.generate_chunk(state=state, style=style)
chunks.append(chunk)
generated = audio.concatenate(chunks)
display(Audio(generated.samples.swapaxes(0, 1), rate=mrt.sample_rate))
Blending text and audio styles with MusicCoCa
from magenta_rt import audio, musiccoca
import numpy as np
style_model = musiccoca.MusicCoCa()
my_audio = audio.Waveform.from_file('myjam.mp3')
weighted_styles = [
(2.0, my_audio),
(1.0, 'heavy metal'),
]
weights = np.array([w for w, _ in weighted_styles])
styles = style_model.embed([s for _, s in weighted_styles])
weights_norm = weights / weights.sum()
blended = (weights_norm[:, np.newaxis] * styles).mean(axis=0)
Tokenizing audio with SpectroStream
from magenta_rt import audio, spectrostream
codec = spectrostream.SpectroStream()
my_audio = audio.Waveform.from_file('jam.mp3')
my_tokens = codec.encode(my_audio)
my_audio_reconstruction = codec.decode(my_tokens)
Why Use Magenta RT?
Magenta RT provides a unique platform for real-time, on-device music generation. Its ability to respond to both text and audio prompts makes it incredibly flexible for creators. The integration with powerful models like MusicCoCa for style blending and SpectroStream for audio tokenization offers advanced capabilities for sophisticated audio manipulation. Being open-source, it allows developers and musicians to experiment, customize, and integrate live music generation into their projects.
Links
- GitHub Repository: https://github.com/magenta/magenta-realtime
- Official Blog Post: https://g.co/magenta/rt
- Research Paper: https://arxiv.org/abs/2508.04651
- Model Card: https://github.com/magenta/magenta-realtime/blob/main/MODEL.md
- Colab Demo (Main): https://colab.research.google.com/github/magenta/magenta-realtime/blob/main/notebooks/Magenta_RT_Demo.ipynb
- Colab Demo (Audio Injection): https://colab.research.google.com/github/magenta/magenta-realtime/blob/main/notebooks/Magenta_RT_Audio_Injection.ipynb
- Colab Demo (Finetuning): https://colab.research.google.com/github/magenta/magenta-realtime/blob/main/notebooks/Magenta_RT_Finetune.ipynb
- YouTube Video (Text Prompting): https://www.youtube.com/watch?v=Ae1Kz2zmh9M
- YouTube Video (Audio Prompting): https://www.youtube.com/watch?v=vHIf2UKXmp4
- YouTube Video (Colab Walkthrough): https://www.youtube.com/watch?v=SVTuEdeepVs
Related repositories
Similar repositories that may be relevant next.

Tau: A Minimalist Python Coding Agent for Your Terminal
September 8, 2026
Tau is a Python port of Pi's minimalist coding agent, designed to live in your terminal. It allows users to make requests like "explain this repo" or "add tests," and it can read files, edit code, and run commands. Beyond its utility, Tau also serves as a teaching project, demonstrating how coding agents are built with a small, readable codebase.

Awesome Harness Engineering: Building Reliable AI Agent Systems
September 7, 2026
Awesome Harness Engineering is a comprehensive curated list dedicated to the discipline of designing robust AI agent harnesses. It offers a wealth of resources, patterns, and templates essential for building reliable AI agent systems. Developers can explore tools, best practices, and foundational concepts across various critical areas of agent development.
Best of Agent Harnesses: A Curated List for AI Agent Development
September 7, 2026
RyanAlberts' Best of Agent Harnesses is a comprehensive, curated, and ranked list of over 100 AI agent harnesses and orchestration frameworks. It provides valuable insights for building reliable agentic systems, offering both human-readable guides and machine-readable formats for agents themselves. The repository is rescored weekly to ensure up-to-date recommendations.

Wasm Agents Blueprint: Run Python AI Agents in Your Browser with WebAssembly
September 3, 2026
Wasm Agents Blueprint is an innovative project from Mozilla AI that allows you to run Python-based AI agents directly in your web browser using WebAssembly (Wasm) and Pyodide. It bridges the gap between powerful Python AI frameworks, like the OpenAI Agents SDK, and browser-based applications. This blueprint eliminates the need for complex server setups or Docker containers, offering a streamlined way to experience AI agents.
Source repository
Open the original repository on GitHub.
14 counted GitHub visits