Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from deep_translator import GoogleTranslator | |
| def tarjim(text, choice): | |
| try: | |
| if text and choice: | |
| support_languages = GoogleTranslator().get_supported_languages(as_dict=True) | |
| return GoogleTranslator(source='auto',target=support_languages[choice]).translate(text.replace('\n', ' ')) | |
| else: | |
| return gr.Info("Kiritish maydoni bo'sh bo'lmasligi kerak %s" % text) | |
| except Exception as e: | |
| return gr.Error("Xatolik nomi: %s" % e) | |
| with gr.Blocks(theme=gr.themes.Soft()) as demo: | |
| gr.Markdown( | |
| """ | |
| # Tezkor tarjima! | |
| Ma'lumotlarni tezkor tajima qilish uchun kiritish maydonini bo'sh qoldirmang.<br> | |
| Hurmat bilan <a href="https://t.me/shohabbosdev">Shoh Abbos Ulug'murodov</a> | |
| """) | |
| with gr.Accordion(label='Deep Translator haqida...', open=False): | |
| gr.Markdown(""" | |
| Ko'p tarjimonlar yordamida turli tillar o'rtasida sodda tarzda tarjima qilish uchun moslashuvchan BEPUL va CHEKSIZ vosita. | |
| foydalanish juda oddiy <code>pip install deep-translator</code> | |
| """) | |
| with gr.Row(): | |
| with gr.Column(): | |
| tanlash = gr.Dropdown(label='Tilni tanlang', choices=GoogleTranslator().get_supported_languages(), value='uzbek') | |
| inp = gr.Textbox(label='Kirish qismi', placeholder="Tarjima mantnini kiriting..." ,autofocus=True) | |
| with gr.Column(): | |
| out = gr.Textbox(label='Natija', show_copy_button=True) | |
| tozalash = gr.ClearButton(value="Tozalash", variant='primary', size='sm', components=[inp, out], icon='clear-svgrepo-com.svg') | |
| inp.change(tarjim, [inp, tanlash], out) | |
| # tozalash.click(inp, out.clear) | |
| if __name__ == "__main__": | |
| demo.launch() |