Spaces:
Sleeping
Sleeping
File size: 968 Bytes
fcf3782 6c77ca7 1e96a52 2ada30a f4ff040 fcf3782 f4ff040 6c77ca7 1a9f0c8 ab3e784 f4ff040 ab3e784 f9b2acb 56caa10 039e52c 0461481 6c77ca7 1a9f0c8 ab3e784 f4ff040 0461481 fcf3782 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
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
@spaces.GPU
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()
|