mlx-examples/musicgen
锦此 f7bbe458ae Add timeout to generate functions
Add timeout handling to various `generate` functions across multiple files.

* **cvae/main.py**
  - Add `timeout` parameter to `generate` function.
  - Implement timeout handling using `signal` module in `generate` function.

* **flux/dreambooth.py**
  - Add `timeout` parameter to `generate_progress_images` function.
  - Implement timeout handling using `signal` module in `generate_progress_images` function.

* **musicgen/generate.py**
  - Add `timeout` parameter to `main` function.
  - Implement timeout handling using `signal` module in `main` function.

* **stable_diffusion/txt2image.py**
  - Add `timeout` parameter to `main` function.
  - Implement timeout handling using `signal` module in `main` function.

* **llava/generate.py**
  - Add `timeout` parameter to `main` function.
  - Implement timeout handling using `signal` module in `main` function.

* **llms/gguf_llm/generate.py**
  - Add `timeout` parameter to `generate` function.
  - Implement timeout handling using `signal` module in `generate` function.

* **llms/mlx_lm/generate.py**
  - Add `timeout` parameter to `main` function.
  - Implement timeout handling using `signal` module in `main` function.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/jincdream/mlx-examples?shareId=XXXX-XXXX-XXXX-XXXX).
2024-10-22 17:06:58 +08:00
..
benchmarks MusicGen (#1020) 2024-10-11 10:16:20 -07:00
encodec.py MusicGen (#1020) 2024-10-11 10:16:20 -07:00
generate.py Add timeout to generate functions 2024-10-22 17:06:58 +08:00
musicgen.py MusicGen (#1020) 2024-10-11 10:16:20 -07:00
README.md Update README.md (#1045) 2024-10-14 06:21:25 -07:00
requirements.txt MusicGen (#1020) 2024-10-11 10:16:20 -07:00
t5.py MusicGen (#1020) 2024-10-11 10:16:20 -07:00
utils.py MusicGen (#1020) 2024-10-11 10:16:20 -07:00

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:

from musicgen 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 and code for more details. ↩︎