wasmdashai commited on
Commit
f7906ff
·
verified ·
1 Parent(s): afb7b89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -5
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 greet(n):
10
- print(zero.device) # <-- 'cuda:0' 🤗
11
- return f"Hello {zero + n} Tensor"
 
 
 
 
 
 
12
 
13
- demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
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()