Spaces:
Runtime error
Runtime error
Update vc.py
Browse files
vc.py
CHANGED
@@ -3,7 +3,6 @@ import torch
|
|
3 |
from pathlib import Path
|
4 |
from pytube import YouTube
|
5 |
from pydub import AudioSegment
|
6 |
-
from transformers import AutoProcessor, BarkModel
|
7 |
from TTS.api import TTS
|
8 |
import uuid
|
9 |
import os
|
@@ -11,36 +10,7 @@ import os
|
|
11 |
test_audio="./shufflin.wav"
|
12 |
|
13 |
uid = uuid.uuid4()
|
14 |
-
|
15 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
16 |
-
|
17 |
-
processor = AutoProcessor.from_pretrained("suno/bark-small")
|
18 |
-
model = BarkModel.from_pretrained("suno/bark-small").to(device)
|
19 |
-
num_list = ["1","2","3","4","5","6","7","8","9","10"]
|
20 |
-
lang_list = ["en","de"]
|
21 |
-
#SAMPLE_RATE = 24_000
|
22 |
-
def run_bark(text, n='1', lang='en'):
|
23 |
-
uid=uuid.uuid4()
|
24 |
-
#history_prompt = []
|
25 |
-
semantic_prompt=f"v2/{lang}_speaker_{int(n)-1}"
|
26 |
-
|
27 |
-
#text=["Hello, my name is Suno. And, uh — and I like pizza. [laughs] But I also have other interests such as playing tic tac toe."],
|
28 |
-
inputs = processor(text=text,
|
29 |
-
voice_preset = semantic_prompt,
|
30 |
-
return_tensors="pt",
|
31 |
-
)
|
32 |
-
print("generating")
|
33 |
-
speech_values = model.generate(
|
34 |
-
**inputs, coarse_temperature = 0.8, temperature = 0.5, do_sample=True
|
35 |
-
)
|
36 |
-
#speech_values = model.generate(**inputs, do_sample=True)
|
37 |
-
sampling_rate = model.generation_config.sample_rate
|
38 |
-
|
39 |
-
#sampling_rate = 24_000
|
40 |
-
print("writing")
|
41 |
-
scipy.io.wavfile.write(f"bark_out-{uid}.wav", rate=sampling_rate, data=speech_values.cpu().numpy().squeeze())
|
42 |
-
return (f"bark_out-{uid}.wav")
|
43 |
-
|
44 |
|
45 |
|
46 |
def custom_bark(inp, tog, in_aud=None, trim_aud=None, in_aud_mic=None):
|
|
|
3 |
from pathlib import Path
|
4 |
from pytube import YouTube
|
5 |
from pydub import AudioSegment
|
|
|
6 |
from TTS.api import TTS
|
7 |
import uuid
|
8 |
import os
|
|
|
10 |
test_audio="./shufflin.wav"
|
11 |
|
12 |
uid = uuid.uuid4()
|
13 |
+
device="cpu"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
|
16 |
def custom_bark(inp, tog, in_aud=None, trim_aud=None, in_aud_mic=None):
|