Instructions to use artificial-feelings/bark-forked with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use artificial-feelings/bark-forked with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-to-speech", model="artificial-feelings/bark-forked")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForTextToWaveform processor = AutoProcessor.from_pretrained("artificial-feelings/bark-forked") model = AutoModelForTextToWaveform.from_pretrained("artificial-feelings/bark-forked", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download handler.py from artificial-feelings/bark-forked: direct link, hf CLI and curl.
- Browser
- Download file 912 Bytes
-
https://huggingface.co/artificial-feelings/bark-forked/resolve/main/handler.py
- Command line
-
hf download hf://artificial-feelings/bark-forked/handler.py
-
curl -L -o handler.py https://huggingface.co/artificial-feelings/bark-forked/resolve/main/handler.py
912 Bytes
| from transformers import AutoProcessor, AutoModel | |
| import torch | |
| # set device | |
| DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu') | |
| if DEVICE.type != 'cuda': | |
| raise ValueError("need to run on GPU") | |
| class EndpointHandler(): | |
| def __init__(self, path=""): | |
| self.processor = AutoProcessor.from_pretrained(path) | |
| self.model = AutoModel.from_pretrained(path) | |
| self.model.to(DEVICE) | |
| def __call__(self, data): #-> List[Dict[str, Any]] | |
| # get inputs | |
| input_text = data['inputs'] | |
| inputs = self.processor( | |
| text=input_text, | |
| return_tensors="pt", | |
| voice_preset = "v2/en_speaker_6" | |
| ).to(DEVICE) | |
| speech_values = self.model.generate(**inputs, do_sample=True) | |
| sample_rate = self.model.generation_config.sample_rate | |
| return {'audio': speech_values.tolist(), 'sample_rate': sample_rate} |