Spaces:
Sleeping
Sleeping
import gradio as gr | |
import spaces | |
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 greet2(text): | |
text=clean_text(text).strip() | |
for t in text.split(' '): | |
try: | |
if t.strip()!='': | |
wave = model.tts(t,vowelizer='shakkelha') | |
yield 22025,wave.view(-1).cpu().numpy() | |
except :pass | |
def greet(text): | |
t=clean_text(text).strip() | |
wave = model.tts(t) | |
return 22025,wave.view(-1).cpu().numpy() | |
audio_player = gr.Audio(label="أ audio",streaming=True) | |
demo = gr.Interface(fn=greet, inputs="text", outputs=audio_player) | |
demo.launch() | |