Instructions to use hf-audio/xcodec2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hf-audio/xcodec2 with Transformers:
# Load model directly from transformers import AutoFeatureExtractor, AutoModel extractor = AutoFeatureExtractor.from_pretrained("hf-audio/xcodec2") model = AutoModel.from_pretrained("hf-audio/xcodec2") - Notebooks
- Google Colab
- Kaggle
ImportError: cannot import name 'Xcodec2Model' from 'transformers'
When I try to use the code snippet given in the Model Card I am getting the following error:
ImportError: cannot import name 'Xcodec2Model' from 'transformers'
I have installed transformers in my project directory using uv add transformers and the transformers version is 4.57.1
Hi @anandaswarup thanks for your message, this is actually a draft model card as XCodec2 isn't yet merged into Transformers: https://github.com/huggingface/transformers/pull/37868
You can use the model by installing code from the fork
pip install git+https://github.com/Deep-unlearning/transformers.git@add-xcodec2
Ok thanks a lot for your reply. Any timeline on when it will be merged into the main Transformers branch? In the meanwhile, I will use your fork.
Not sure yet, there's some pending additions/reviews that first need to be addressed
@anandaswarup xcodec2 has been merged into Transformers! please use this checkpoint: https://huggingface.co/HKUSTAudio/xcodec2-hf