|
import os |
|
|
|
|
|
os.system('bash setup.sh') |
|
|
|
import gradio as gr |
|
from espnet2.bin.tts_inference import Text2Speech |
|
from transformers import AutoTokenizer, AutoModel |
|
|
|
|
|
tokenizer = AutoTokenizer.from_pretrained("faisalq/SaudiBERT") |
|
model = AutoModel.from_pretrained("faisalq/SaudiBERT") |
|
|
|
|
|
tts = Text2Speech.from_pretrained("kan-bayashi/fastspeech2") |
|
|
|
|
|
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'] |
|
|
|
|
|
iface = gr.Interface(fn=tts_najdi, inputs="text", outputs="audio", title="FastSpeech2 Najdi TTS Model with SaudiBERT") |
|
iface.launch() |
|
|