KeerthiVM commited on
Commit
37d0da8
·
unverified ·
1 Parent(s): 65639d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -103
app.py CHANGED
@@ -1,106 +1,3 @@
1
- # import os
2
- # from huggingface_hub import InferenceClient
3
- # import gradio as gr
4
-
5
- # # Initialize the client with the correct provider
6
- # HF_TOKEN = os.environ.get("HF_TOKEN", None)
7
- # client = InferenceClient(
8
- # provider="hf-inference",
9
- # api_key=HF_TOKEN
10
- # )
11
-
12
- # def translate_text(text, src_lang, tgt_lang):
13
- # """
14
- # Function to handle translation using the MBART model
15
- # """
16
- # if not text.strip():
17
- # return "Please enter text to translate"
18
-
19
- # try:
20
- # # Use the translation method with model-specific parameters
21
- # result = client.translation(
22
- # text,
23
- # model="facebook/mbart-large-50-many-to-many-mmt",
24
- # src_lang=src_lang, # Source language code
25
- # tgt_lang=tgt_lang # Target language code
26
- # )
27
- # return result
28
-
29
- # except Exception as e:
30
- # return f"Error in translation: {str(e)}"
31
-
32
- # # Create the Gradio interface
33
- # with gr.Blocks(title="Multilingual Translation Chatbot", theme="soft") as demo:
34
- # gr.Markdown("# 🌍 Multilingual Translation Chatbot")
35
- # gr.Markdown("Translate between 50 languages using facebook/mbart-large-50-many-to-many-mmt")
36
-
37
- # with gr.Row():
38
- # with gr.Column():
39
- # src_lang = gr.Dropdown(
40
- # choices=[
41
- # "ar_AR", "en_XX", "fr_XX", "es_XX", "de_DE",
42
- # "zh_CN", "hi_IN", "ru_RU", "ja_XX", "pt_XX", "it_IT"
43
- # ],
44
- # value="ru_RU",
45
- # label="Source Language Code"
46
- # )
47
- # input_text = gr.Textbox(
48
- # lines=4,
49
- # placeholder="Enter text to translate...",
50
- # label="Input Text",
51
- # value="Меня зовут Вольфганг и я живу в Берлине"
52
- # )
53
-
54
- # with gr.Column():
55
- # tgt_lang = gr.Dropdown(
56
- # choices=[
57
- # "ar_AR", "en_XX", "fr_XX", "es_XX", "de_DE",
58
- # "zh_CN", "hi_IN", "ru_RU", "ja_XX", "pt_XX", "it_IT"
59
- # ],
60
- # value="en_XX",
61
- # label="Target Language Code"
62
- # )
63
- # output_text = gr.Textbox(
64
- # lines=4,
65
- # label="Translation",
66
- # interactive=False
67
- # )
68
-
69
- # # Translate button
70
- # translate_btn = gr.Button("Translate 🌐", variant="primary")
71
- # translate_btn.click(
72
- # fn=translate_text,
73
- # inputs=[input_text, src_lang, tgt_lang],
74
- # outputs=output_text
75
- # )
76
-
77
- # # Examples for quick testing
78
- # gr.Examples(
79
- # examples=[
80
- # ["Меня зовут Вольфганг и я живу в Берлине", "ru_RU", "en_XX"],
81
- # ["Hello, how are you today?", "en_XX", "es_XX"],
82
- # ["Bonjour, comment ça va?", "fr_XX", "en_XX"],
83
- # ["今天天气很好", "zh_CN", "en_XX"]
84
- # ],
85
- # inputs=[input_text, src_lang, tgt_lang]
86
- # )
87
-
88
- # # Clear button
89
- # clear_btn = gr.Button("Clear")
90
- # clear_btn.click(
91
- # fn=lambda: ["", "ru_RU", "en_XX", ""],
92
- # outputs=[input_text, src_lang, tgt_lang, output_text]
93
- # )
94
-
95
- # print("hellow")
96
-
97
- # # Launch the interface
98
- # if __name__ == "__main__":
99
- # demo.launch(share=True)
100
-
101
-
102
-
103
-
104
  import os
105
  from huggingface_hub import InferenceClient
106
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  from huggingface_hub import InferenceClient
3
  import gradio as gr