Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,11 +2,24 @@ import gradio as gr
|
|
2 |
from models.tacotron2 import Tacotron2Wave
|
3 |
model = Tacotron2Wave('pretrained/tacotron2_ar_adv.pth')
|
4 |
#model = model.cuda()
|
|
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
def greet(text):
|
7 |
-
|
|
|
|
|
8 |
|
9 |
-
|
|
|
|
|
|
|
|
|
10 |
|
11 |
demo = gr.Interface(fn=greet, inputs="text", outputs="audio")
|
12 |
demo.launch()
|
|
|
2 |
from models.tacotron2 import Tacotron2Wave
|
3 |
model = Tacotron2Wave('pretrained/tacotron2_ar_adv.pth')
|
4 |
#model = model.cuda()
|
5 |
+
import re
|
6 |
|
7 |
+
def clean_text(text):
|
8 |
+
|
9 |
+
# حذف الأرقام والحروف الإنجليزية والنقطة
|
10 |
+
cleaned_text = re.sub(r"[0-9a-zA-Z\.]", " ", text)
|
11 |
+
|
12 |
+
return cleaned_text
|
13 |
def greet(text):
|
14 |
+
try:
|
15 |
+
text=clean_text(text).strip()
|
16 |
+
wave = model.tts(text,vowelizer='shakkelha')
|
17 |
|
18 |
+
return 22025,wave.view(-1).cpu().numpy()
|
19 |
+
except error:
|
20 |
+
return None
|
21 |
+
|
22 |
+
|
23 |
|
24 |
demo = gr.Interface(fn=greet, inputs="text", outputs="audio")
|
25 |
demo.launch()
|