mirror of
https://github.com/ml-explore/mlx-examples.git
synced 2025-12-16 02:08:55 +08:00
MusicGen (#1020)
* Add MusicGen model * add benchmarks * change to from_pretrained * symlinks * add readme and requirements * fix readme * readme
This commit is contained in:
31
musicgen/README.md
Normal file
31
musicgen/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# MusicGen
|
||||
|
||||
An example of Meta's MusicGen model in MLX.[^1] MusicGen is used to generate
|
||||
music from text descriptions.
|
||||
|
||||
### Setup
|
||||
|
||||
Install the requirements:
|
||||
|
||||
```
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
An example using the model:
|
||||
|
||||
```python
|
||||
import mlx.core as mx
|
||||
from music_gen import MusicGen
|
||||
from utils import save_audio
|
||||
|
||||
model = MusicGen.from_pretrained("facebook/musicgen-medium")
|
||||
|
||||
audio = model.generate("happy rock")
|
||||
|
||||
save_audio("out.wav", audio, model.sampling_rate)
|
||||
```
|
||||
|
||||
[^1]: Refer to the [arXiv paper](https://arxiv.org/abs/2306.05284) and
|
||||
[code](https://github.com/facebookresearch/audiocraft/blob/main/docs/MUSICGEN.md) for more details.
|
||||
Reference in New Issue
Block a user