feliksius commited on
Commit
fc58506
·
verified ·
1 Parent(s): 3c8a820

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from transformers import pipeline
3
+
4
+ app = FastAPI()
5
+ translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-id")
6
+
7
+ @app.post("/translate")
8
+ async def translate(text: str):
9
+ result = translator(text)
10
+ return {"translated_text": result[0]["translation_text"]}