File size: 1,465 Bytes
96f4874 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
---
inference: false
tags:
- musicgen
license: cc-by-nc-4.0
pipeline_tag: text-to-audio
---
# MeditationMusicGen
This model is a fine-tuned version of facebooks MusicGen.
Refer to https://huggingface.co/facebook/musicgen-small for more details.
## 🤗 Transformers Usage
You can run MeditationMusicGen locally with the 🤗 Transformers library from version 4.31.0 onwards.
1. First install the 🤗 [Transformers library](https://github.com/huggingface/transformers) and scipy:
```
pip install --upgrade pip
pip install --upgrade transformers scipy
```
```python
from transformers import AutoProcessor, MusicgenForConditionalGeneration
import scipy
processor = AutoProcessor.from_pretrained("facebook/musicgen-small")
model = MusicgenForConditionalGeneration.from_pretrained("bfh-genai/meditation-musicgen")
relaxing_description = 'Peaceful meditation background sound'
conditioned_text_input = processor(text=relaxing_description, padding=True, return_tensors="pt")
audio_value = model.generate(**conditioned_text_input,
do_sample=True,
guidance_scale=3, # Value >1, best results achieved with 3.
max_new_tokens=256 # 256 ^= 5 seconds of audio.
)
scipy.io.wavfile.write(f"my_audio.wav", rate=32_000, data=audio_values[0, 0].numpy())
```
**License:** Code is released under MIT, model weights are released under CC-BY-NC 4.0.
|