Spaces:
Runtime error
Runtime error
Dhruv Diddi
commited on
Commit
·
02840b8
1
Parent(s):
923dda3
add reqs
Browse files- app.py +19 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from libretranslatepy import LibreTranslateAPI
|
3 |
+
lt = LibreTranslateAPI("https://translate.argosopentech.com/")
|
4 |
+
|
5 |
+
def predict(text):
|
6 |
+
lang_detected = lt.detect(text)[0]['language']
|
7 |
+
print(lang_detected)
|
8 |
+
english_translated = lt.translate(text, lang_detected, "en")
|
9 |
+
print(english_translated)
|
10 |
+
return english_translated
|
11 |
+
|
12 |
+
iface = gr.Interface(
|
13 |
+
fn=predict,
|
14 |
+
inputs='text',
|
15 |
+
outputs='text',
|
16 |
+
examples=[["Hola! Me llamo Dhruv"]]
|
17 |
+
)
|
18 |
+
|
19 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
libretranslatepy
|