Terjman-Nano / app.py
BounharAbdelaziz's picture
Update app.py
ade53b7 verified
raw
history blame
695 Bytes
import gradio as gr
import requests
import os
API_URL = "https://api-inference.huggingface.co/models/BounharAbdelaziz/Terjman-Nano-MAX_LEN-512"
HF_TOKEN = os.environ['HF_TOKEN']
headers = {"Authorization": "Bearer "+ HF_TOKEN}
def respond(english_text):
payload = {
"inputs": english_text,
}
darija_translated_text = requests.post(API_URL, headers=headers, json=payload)
return darija_translated_text.json()[0]["generated_text"]
app = gr.Interface(fn=respond, inputs="text", outputs="text", title="Terjman-Nano πŸ‘¨β€πŸ’» 😊", description="Translate English text to Moroccan Darija using our smallest model (77M) πŸ€—")
if __name__ == "__main__":
app.launch()