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
File size: 912 Bytes
da51fe7 2074891 576bca9 2074891 da51fe7 2074891 da51fe7 96937e3 da51fe7 96937e3 2074891 da51fe7 96937e3 da51fe7 96937e3 | 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 | 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} |