Instructions to use strumber/Meta-AudioGen-API with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Adapters
How to use strumber/Meta-AudioGen-API with Adapters:
from adapters import AutoAdapterModel model = AutoAdapterModel.from_pretrained("<base-model-id>") model.load_adapter("strumber/Meta-AudioGen-API", set_active=True) - Notebooks
- Google Colab
- Kaggle
Download huggingface_integration.py from strumber/Meta-AudioGen-API: direct link, hf CLI and curl.
- Browser
- Download file 656 Bytes
-
https://huggingface.co/strumber/Meta-AudioGen-API/resolve/main/huggingface_integration.py
- Command line
-
hf download hf://strumber/Meta-AudioGen-API/huggingface_integration.py
-
curl -L -o huggingface_integration.py https://huggingface.co/strumber/Meta-AudioGen-API/resolve/main/huggingface_integration.py
656 Bytes
| from transformers import PreTrainedModel, PretrainedConfig | |
| import torch | |
| from audio_craft_model import AudioCraftGenerator | |
| class AudioCraftForHuggingFace(PreTrainedModel): | |
| def __init__(self, config: PretrainedConfig, model_name='facebook/audiogen-medium', duration=5): | |
| super(AudioCraftForHuggingFace, self).__init__(config) | |
| self.audio_craft_generator = AudioCraftGenerator(model_name, duration) | |
| def forward(self, descriptions): | |
| with torch.no_grad(): | |
| wav = self.audio_craft_generator(descriptions) | |
| return wav | |
| def save_wav(self, wav, idx): | |
| return self.audio_craft_generator.save_wav(wav, idx) |