|
import gradio as gr |
|
from transformers import pipeline |
|
from espnet2.bin.tts_inference import Text2Speech |
|
import warnings |
|
from krill_to_latin import Perevod |
|
|
|
|
|
perevod = Perevod() |
|
warnings.filterwarnings('ignore') |
|
|
|
|
|
def generateTextAndAudio(inputText, numGen): |
|
|
|
|
|
inputText = perevod.translate_for_summarizer(inputText) |
|
textOutput = textGenerator(inputText, max_length=numGen) |
|
|
|
|
|
genText = textOutput[0]['generated_text'] |
|
|
|
print("-" * 75) |
|
print("Input Text:", inputText) |
|
print("Generated Text:", genText) |
|
print("-" * 75) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return genText |
|
|
|
|
|
|
|
textGenerator = pipeline('text-generation', model='rifkat/GPTuz') |
|
audioGenerator = Text2Speech.from_pretrained("espnet/kan-bayashi_ljspeech_joint_finetune_conformer_fastspeech2_hifigan") |
|
|
|
input1_textbox = gr.Textbox(label="Tekst*") |
|
input2_slider = gr.Slider(minimum=1, maximum=100, step=1, default=30, label="Generatsiya bo'ladigan so'zlar soni") |
|
|
|
output1_textbox = gr.Textbox(label="Generatsiya bo'lgan tekst") |
|
|
|
|
|
title = "Tekst gereratsiya qiling!" |
|
description = "Tekst kiriting va nechta so'z generatsiya qilishini" |
|
|
|
examples = [ |
|
["Давлат хавфсизлик хизмати", 50], |
|
["Шунинг учун биз", 30], |
|
["Лекин бугун бу нарсани қилмасак", 60] |
|
] |
|
iface = gr.Interface(fn=generateTextAndAudio, |
|
inputs=[input1_textbox, input2_slider], |
|
|
|
outputs=output1_textbox, |
|
title=title, |
|
description=description, |
|
examples=examples).launch(debug=True) |