Skip to content

Instantly share code, notes, and snippets.

View Paethon's full-sized avatar

Sebastian Stabinger Paethon

View GitHub Profile
@nateraw
nateraw / Code.gs
Created July 20, 2021 18:42
Add Translation to Google Sheets using HuggingFace's API
function TRANSLATE(text, repo_id="Helsinki-NLP/opus-mt-en-es") {
endpoint = "https://api-inference.huggingface.co/pipeline/translation/" + repo_id;
const payload = JSON.stringify({
"inputs": text
});
// Add your token from https://huggingface.co/settings/token
const options = {
"headers": {"Authorization": "Bearer <YOUR HUGGINGFACE API KEY>"},
"wait_for_model": true,