veni18 commited on
Commit
cf16c11
·
1 Parent(s): 3a99ac3

Add translation

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -1,7 +1,20 @@
1
  import gradio as gr
 
 
2
 
3
  def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch(share=True)
 
1
  import gradio as gr
2
+ import requests
3
+ import json
4
 
5
  def greet(name):
6
+
7
+ from transformers import pipeline
8
+
9
+ translation = pipeline("translation", model="Helsinki-NLP/opus-mt-en-hu")
10
+ sentences1 = "We believe that trustworthy health information should be free to everyone and we rely on advertising to make that possible. Providing authoritative experiences that are reviewed by physicians and other health and wellness professionals is expensive, but it’s an invaluable service. We collect and securely process your personal data to deliver a relevant experience and support our business, so we ask that you allow cookies in order to access all of our content and features."
11
+ text_translated=[]
12
+ for text in sentences1:
13
+ text_translated.append(translation(text))
14
+
15
+ combined_text = ' '.join([item['translation_text'] for sublist in text_translated for item in sublist])
16
+
17
+ return combined_text
18
 
19
  demo = gr.Interface(fn=greet, inputs="text", outputs="text")
20
+ demo.launch()