wasm-ara / app.py
wasmdashai's picture
Update app.py
dcb69bc verified
raw
history blame
732 Bytes
import gradio as gr
from models.tacotron2 import Tacotron2Wave
model = Tacotron2Wave('pretrained/tacotron2_ar_adv.pth')
#model = model.cuda()
import re
def clean_text(text):
# حذف الأرقام والحروف الإنجليزية والنقطة
cleaned_text = re.sub(r"[0-9a-zA-Z\.]", " ", text)
return cleaned_text
def greet(text):
text=clean_text(text).strip()
for t in text.split(' '):
try:
if t.strip()!='':
wave = model.tts(t)
yield 22025,wave.view(-1).cpu().numpy()
except error:pass
demo = gr.Interface(fn=greet, inputs="text", outputs="audio")
demo.launch()