How to use the Google Cloud Translation API

I referred to the next page. Text Translation (Basic)

ex01.py


#! /usr/bin/python
#
#
from google.cloud import translate_v2 as translate

text="Es war einmal ein kleines Mädchen."
target="ja"

translate_client = translate.Client()
#
result = translate_client.translate(text, target_language=target)

print("Text: {}".format(result["input"]))
print("Translation: {}".format(result["translatedText"]))
print("Detected source language: {}".format(result["detectedSourceLanguage"]))

Execution method

export GOOGLE_APPLICATION_CREDENTIALS=./***.json
#
./ex01.py

Execution result

Text: Es war einmal ein kleines Mädchen.
Translation:Once upon a time there was a little girl.
Detected source language: de

Recommended Posts

How to use the Google Cloud Translation API
How to use GCP's Cloud Vision API
How to use the NHK program guide API
How to use the generator
How to use the decorator
How to use Google Colaboratory
How to use the zip function
How to use the optparse module
[Python] Hit the Google Translation API
[Memo] How to use Google MµG
How to use OpenPose's Python API
How to use bing search api
How to use the ConfigParser module
[Python] How to use Typetalk API
How to use the Spark ML pipeline
How to use Google Test in C
[Linux] How to use the echo command
How to use the Linux grep command
How to use Google Assistant on Windows 10
Use Google Cloud Vision API from Python
How to use the IPython debugger (ipdb)
How to display Map using Google Map API (Android)
How to use xml.etree.ElementTree
How to use Python-shell
How to use the C library in Python
From the introduction of GoogleCloudPlatform Natural Language API to how to use it
How to use tf.data
How to use virtualenv
How to use MkDocs for the first time
How to use Seaboan
How to use image-match
How to use shogun
How to use Pandas 2
How to use numpy.vectorize
Use the MediaWiki API to get Wiki information
How to use pytest_report_header
How to use partial
How to use Bio.Phylo
I tried using the Google Cloud Vision API
How to use the graph drawing library Bokeh
How to use SymPy
How to use x-means
How to call Cloud API from GCP Cloud Functions
How to use WikiExtractor.py
How to use IPython
Until you can use the Google Speech API
How to use virtualenv
How to use Matplotlib
When introducing the Google Cloud Vision API to rails, I followed the documentation.
[Algorithm x Python] How to use the list
How to use iptables
How to use numpy
How to use TokyoTechFes2015
How to use venv
How to use dictionary {}
How to use Pyenv
How to use list []
How to use python-kabusapi
How to use OptParse
How to use return
[Google Cloud Platform] Use Google Cloud API using API Client Library