Views
No views yet
facebook/MelodyFlow HuggingFace Space — Meta uploaded it there but never merged it into audiocraft main. MAESTRO vendors that Space's audiocraft/ subtree under backend/ai/melodyflow_pkg/. The non-commercial clause attaches only to the weights and to anything derived from running them..bin layout (PyTorch pickle) verbatim — state_dict.bin (the flow-matching DiT language model) plus compression_state_dict.bin (the EnCodec compression model, 2-channel / 32 kHz). We do NOT convert to safetensors here because the vendored audiocraft loader expects pickled {xp.cfg, best_state} packages and reads the OmegaConf cfg blob alongside the tensor dict in one torch.load call. Splitting cfg into a sidecar would require a custom loader — deferred.weights_only=True rejects these pickles (numpy scalars in xp.cfg). MAESTRO's runner wraps the load in a _TorchLoadWeightsOnlyShim context manager; vanilla audiocraft users on torch ≥ 2.6 will hit the same issue and need a similar shim.1# Requires the facebook/MelodyFlow Space's audiocraft subtree on PYTHONPATH
2# (the upstream audiocraft PyPI release does NOT include MelodyFlow).
3from audiocraft.models import MelodyFlow
4model = MelodyFlow.get_pretrained('AEmotionStudio/melodyflow-models', device='cuda')
5
6# Generate from text alone:
7model.set_generation_params(solver='midpoint', steps=64, duration=10.0)
8wav = model.generate(descriptions=['cinematic strings'])
9
10# OR edit a source clip via regularized latent inversion:
11import torchaudio
12src, sr = torchaudio.load('source.wav') # MelodyFlow's EnCodec is stereo
13if src.shape[0] == 1: src = src.repeat(2, 1)
14src = src.unsqueeze(0).to('cuda')
15import torch
16with torch.no_grad():
17 prompt_tokens = model.encode_audio(src)
18model.set_editing_params(solver='euler', steps=25, regularize=True,
19 regularize_iters=4, lambda_kl=0.2)
20edited = model.edit(prompt_tokens=prompt_tokens,
21 descriptions=['solo piano with reverb'],
22 src_descriptions=['gentle arpeggio'])
23torchaudio.save('edited.wav', edited[0].cpu(), model.sample_rate)Le Lan, G., Nagaraja, V., Chang, E., Kant, D., Ni, Z., Shi, Y., Iandola, F., & Chandra, V. (2024). High Fidelity Text-Guided Music Editing via Single-Stage Flow Matching. arXiv:2407.03648.