File size: 989 Bytes
cac9d20
ed4d752
cac9d20
 
 
e9ef331
 
 
 
739b974
33e933f
739b974
33e933f
739b974
 
ed4d752
33e933f
739b974
33e933f
739b974
e9ef331
33e933f
739b974
 
 
 
 
ed4d752
 
739b974
ed4d752
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
import os

# تشغيل setup.sh لتثبيت الحزم المطلوبة
os.system('bash setup.sh')

import gradio as gr
from espnet2.bin.tts_inference import Text2Speech
from transformers import AutoTokenizer, AutoModel

# تحميل SaudiBERT لتحليل النص
tokenizer = AutoTokenizer.from_pretrained("faisalq/SaudiBERT")
model = AutoModel.from_pretrained("faisalq/SaudiBERT")

# تحميل نموذج FastSpeech2
tts = Text2Speech.from_pretrained("kan-bayashi/fastspeech2")

# دالة لتحليل النص باستخدام SaudiBERT
def analyze_text(text):
    inputs = tokenizer(text, return_tensors="pt")
    outputs = model(**inputs)
    return text

# دالة لتحويل النص إلى كلام
def tts_najdi(text):
    processed_text = analyze_text(text)
    speech = tts(processed_text)
    return speech['wav']

# واجهة Gradio
iface = gr.Interface(fn=tts_najdi, inputs="text", outputs="audio", title="FastSpeech2 Najdi TTS Model with SaudiBERT")
iface.launch()