Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import BarkModel
|
2 |
+
|
3 |
+
model = BarkModel.from_pretrained("suno/bark-small")
|
4 |
+
import torch
|
5 |
+
|
6 |
+
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
7 |
+
model = model.to(device)
|
8 |
+
from transformers import AutoProcessor
|
9 |
+
|
10 |
+
processor = AutoProcessor.from_pretrained("suno/bark")
|
11 |
+
# prepare the inputs
|
12 |
+
text_prompt = "Let's try generating speech, with Bark, a text-to-speech model"
|
13 |
+
inputs = processor(text_prompt)
|
14 |
+
|
15 |
+
# generate speech
|
16 |
+
speech_output = model.generate(**inputs.to(device))
|
17 |
+
from IPython.display import Audio
|
18 |
+
|
19 |
+
sampling_rate = model.generation_config.sample_rate
|
20 |
+
Audio(speech_output[0].cpu().numpy(), rate=sampling_rate)
|