Skip to content

Instantly share code, notes, and snippets.

@antoniocachuan
Created October 6, 2020 02:47
Show Gist options
  • Select an option

  • Save antoniocachuan/3bd1c359b826f1beccdd2d56bb66d3aa to your computer and use it in GitHub Desktop.

Select an option

Save antoniocachuan/3bd1c359b826f1beccdd2d56bb66d3aa to your computer and use it in GitHub Desktop.
lab vision API Google Cloud
{
"requests": [
{
"image": {
"source": {
"gcsImageUri": "gs://qwiklabs-gcp-04-cd36f3d11a7c/sign.jpg"
}
},
"features": [
{
"type": "TEXT_DETECTION",
"maxResults": 10
}
]
}
]
}
curl -s -X POST -H "Content-Type: application/json" --data-binary @ocr-request.json https://vision.googleapis.com/v1/images:annotate?key=${API_KEY}
curl -s -X POST -H "Content-Type: application/json" --data-binary @ocr-request.json https://vision.googleapis.com/v1/images:annotate?key=${API_KEY} -o ocr-response.json
translation-request.json
{
"q": "your_text_here",
"target": "en"
}
STR=$(jq .responses[0].textAnnotations[0].description ocr-response.json) && STR="${STR//\"}" && sed -i "s|your_text_here|$STR|g" translation-request.json
curl -s -X POST -H "Content-Type: application/json" --data-binary @translation-request.json https://translation.googleapis.com/language/translate/v2?key=${API_KEY} -o translation-response.json
nl-request.json
{
"document":{
"type":"PLAIN_TEXT",
"content":"your_text_here"
},
"encodingType":"UTF8"
}
STR=$(jq .data.translations[0].translatedText translation-response.json) && STR="${STR//\"}" && sed -i "s|your_text_here|$STR|g" nl-request.json
curl "https://language.googleapis.com/v1/documents:analyzeEntities?key=${API_KEY}" \
-s -X POST -H "Content-Type: application/json" --data-binary @nl-request.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment