local setting #405
Unanswered
strongman22255
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is my code for local setting.
from transformers import AutoProcessor, AutoModel
import torch
import numpy as np
import soundfile as sf
processor_path = "E:/AI/Bark/bark"
model_path = "E:/AI/Bark/bark"
processor = AutoProcessor.from_pretrained(processor_path)
model = AutoModel.from_pretrained(model_path)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = model.to(device)
coarse_prompt = np.load("E:/AI/Bark/bark/speaker_embeddings/v2/ja_speaker_7_coarse_prompt.npy")
fine_prompt = np.load("E:/AI/Bark/bark/speaker_embeddings/v2/ja_speaker_7_fine_prompt.npy")
semantic_prompt = np.load("E:/AI/Bark/bark/speaker_embeddings/v2/ja_speaker_7_semantic_prompt.npy")
text_prompt = "あたしがどれほどあんたを愛していることしらないの? [anger]なんであたしにそうをするの?もう、あたしの目から消えろよ!!!"
inputs = processor(text=text_prompt, return_tensors="pt").to(device)
inputs["coarse_prompt"] = torch.tensor(coarse_prompt).to(device)
inputs["fine_prompt"] = torch.tensor(fine_prompt).to(device)
inputs["semantic_prompt"] = torch.tensor(semantic_prompt).to(device)
speech_values = model.generate(**inputs, do_sample=True)
sampling_rate = model.config.sample_rate
sf.write('output.wav', speech_values.cpu().numpy().squeeze(), sampling_rate)
but there is an error here.
plz help
Beta Was this translation helpful? Give feedback.
All reactions