Spaces:
Sleeping
Sleeping
Create app.py
Browse files
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"]}
|