Instructions to use safe-models/ContentVec with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use safe-models/ContentVec with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="safe-models/ContentVec")# Load model directly from transformers import AutoProcessor, AutoModel processor = AutoProcessor.from_pretrained("safe-models/ContentVec") model = AutoModel.from_pretrained("safe-models/ContentVec", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 742 Bytes
6a2dcd7 8ac9444 6a2dcd7 8ac9444 6a2dcd7 8ac9444 6a2dcd7 8ac9444 6a2dcd7 8ac9444 6a2dcd7 8ac9444 ef21d04 6a2dcd7 8ac9444 6a2dcd7 8ac9444 | 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 | ---
library_name: transformers
license: mit
---
# ContentVec
The ContentVec model in safetensors format, compatible with HuggingFace Transformers.
## Uses
To extract features, use the following code:
```python
from transformers import AutoProcessor, HubertModel
import librosa
# Load the processor and model
processor = AutoProcessor.from_pretrained("safe-models/ContentVec")
hubert = HubertModel.from_pretrained("safe-models/ContentVec")
# Read the audio
audio, sr = librosa.load("test.wav", sr=16000)
input_values = processor(audio, sampling_rate=sr, return_tensors="pt").input_values
# Get the layer 12 output as the feature
feats = hubert(input_values, output_hidden_states=True)["hidden_states"][12]
print(f"{feats.shape=}")
```
|