Last active
June 24, 2022 06:53
-
-
Save pablodz/057c0f57c8e889a352dbb46b80ee9f78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 0, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| ], | |
| "source": [ | |
| "# USING GOOGLE API TRANSLATOR (NEED Google Cloud Platform Account)\n", | |
| "def implicit():\n", | |
| " from google.cloud import storage\n", | |
| "\n", | |
| " # If you don't specify credentials when constructing the client, the\n", | |
| " # client library will look for credentials in the environment.\n", | |
| " storage_client = storage.Client()\n", | |
| "\n", | |
| " # Make an authenticated API request\n", | |
| " buckets = list(storage_client.list_buckets())\n", | |
| " print(buckets)\n", | |
| "\n", | |
| "import os \n", | |
| "os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = '/content/FILE-00dfa9ca865d.json' \n", | |
| "\n", | |
| "\"\"\"Translates text into the target language.\n", | |
| "\n", | |
| "Target must be an ISO 639-1 language code.\n", | |
| "See https://g.co/cloud/translate/v2/translate-reference#supported_languages\n", | |
| "\"\"\"\n", | |
| "from google.cloud import translate_v2 as translate\n", | |
| "translate_client = translate.Client()\n", | |
| "\n", | |
| "text='Hola, estoy viendo la televisión.'\n", | |
| "\n", | |
| "# Text can also be a sequence of strings, in which case this method\n", | |
| "# will return a sequence of results for each text.\n", | |
| "result = translate_client.translate(text,target_language='en',source_language='es')\n", | |
| "result['translatedText']" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 3 (system-wide)", | |
| "language": "python", | |
| "metadata": { | |
| "cocalc": { | |
| "description": "Python 3 programming language", | |
| "priority": 100, | |
| "url": "https://www.python.org/" | |
| } | |
| }, | |
| "name": "python3" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython3", | |
| "version": "3.6.9" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 4 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment