Flux9665 commited on
Commit
fe7c793
1 Parent(s): 4194020

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -24
app.py CHANGED
@@ -3,29 +3,25 @@ import torch.cuda
3
 
4
  from InferenceInterfaces.ControllableInterface import ControllableInterface
5
  from Utility.utils import float2pcm
 
6
 
 
 
7
 
8
- class TTSWebUI:
9
-
10
- def __init__(self, gpu_id="cpu", title="Simplistic Stochastic Speech Synthesis with ToucanTTS", article="For a multilingual version, have a look at https://huggingface.co/spaces/Flux9665/MassivelyMultilingualTTS"):
11
- self.controllable_ui = ControllableInterface(gpu_id=gpu_id)
12
- self.iface = gr.Interface(fn=self.read,
13
- inputs=[gr.Textbox(lines=2,
14
- placeholder="write what you want the synthesis to read here...",
15
- value="What I cannot create, I do not understand.",
16
- label="Text input"),
17
- max_length=300],
18
- outputs=[gr.Audio(type="numpy", label="Speech")],
19
- title=title,
20
- theme="default",
21
- allow_flagging="never",
22
- article=article)
23
- self.iface.launch()
24
-
25
- def read(self, prompt):
26
- sr, wav = self.controllable_ui.read(prompt, -24.)
27
- return sr, float2pcm(wav)
28
-
29
-
30
- if __name__ == '__main__':
31
- TTSWebUI(gpu_id="cuda" if torch.cuda.is_available() else "cpu")
 
3
 
4
  from InferenceInterfaces.ControllableInterface import ControllableInterface
5
  from Utility.utils import float2pcm
6
+ import spaces
7
 
8
+ gpu_id="cuda"
9
+ controllable_ui = ControllableInterface(gpu_id=gpu_id)
10
 
11
+ @spaces.GPU
12
+ def read(self, prompt):
13
+ sr, wav = controllable_ui.read(prompt, -24.)
14
+ return sr, float2pcm(wav)
15
+
16
+ iface = gr.Interface(fn=read,
17
+ inputs=[gr.Textbox(lines=2,
18
+ placeholder="write what you want the synthesis to read here...",
19
+ value="What I cannot create, I do not understand.",
20
+ label="Text input"),
21
+ max_length=400],
22
+ outputs=[gr.Audio(type="numpy", label="Speech")],
23
+ title="Simplistic Stochastic Speech Synthesis with ToucanTTS",
24
+ theme="default",
25
+ allow_flagging="never",
26
+ article="This space is purely optimized for English. For a multilingual version, have a look at https://huggingface.co/spaces/Flux9665/MassivelyMultilingualTTS")
27
+ iface.launch()