Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,27 @@
|
|
1 |
import gradio as gr
|
2 |
import spaces
|
3 |
import torch
|
|
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
zero = torch.Tensor([0]).cuda()
|
6 |
print(zero.device) # <-- 'cpu' 🤔
|
7 |
-
|
8 |
@spaces.GPU
|
9 |
-
def
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
demo = gr.Interface(fn=
|
14 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import spaces
|
3 |
import torch
|
4 |
+
from transformers import AutoTokenizer
|
5 |
|
6 |
+
|
7 |
+
|
8 |
+
token=os.environ.get("key_")
|
9 |
+
tokenizer = AutoTokenizer.from_pretrained("wasmdashai/vtk",token=token)
|
10 |
+
|
11 |
+
model=VitsModel.from_pretrained("wasmdashai/vtk",token=token).cuda()
|
12 |
zero = torch.Tensor([0]).cuda()
|
13 |
print(zero.device) # <-- 'cpu' 🤔
|
14 |
+
import torch
|
15 |
@spaces.GPU
|
16 |
+
def modelspeech(text):
|
17 |
+
|
18 |
+
|
19 |
+
inputs = tokenizer(text, return_tensors="pt").cuda()
|
20 |
+
with torch.no_grad():
|
21 |
+
wav = model(input_ids=inputs["input_ids"]).waveform.cpu().numpy().reshape(-1)#.detach()
|
22 |
+
|
23 |
+
return model.config.sampling_rate,wav#remove_noise_nr(wav)
|
24 |
+
|
25 |
|
26 |
+
demo = gr.Interface(fn=modelspeech, inputs=["text", outputs=["audio"])
|
27 |
demo.launch()
|