{"id":13665543,"url":"https://github.com/ropensci/googleLanguageR","last_synced_at":"2025-04-26T08:32:21.217Z","repository":{"id":53762200,"uuid":"89846311","full_name":"ropensci/googleLanguageR","owner":"ropensci","description":"R client for the Google Translation API, Google Cloud Natural Language API and Google Cloud Speech API","archived":false,"fork":false,"pushed_at":"2024-07-17T16:37:20.000Z","size":9073,"stargazers_count":194,"open_issues_count":14,"forks_count":42,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-11-11T00:37:02.553Z","etag":null,"topics":["cloud-speech-api","cloud-translation-api","google-api-client","google-cloud","google-cloud-speech","google-nlp","googleauthr","natural-language-processing","peer-reviewed","r","r-package","rstats","sentiment-analysis","speech-api","translation-api"],"latest_commit_sha":null,"homepage":"https://code.markedmondson.me/googleLanguageR/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ropensci.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-30T11:18:34.000Z","updated_at":"2024-09-05T01:07:36.000Z","dependencies_parsed_at":"2023-09-21T19:22:33.410Z","dependency_job_id":"f3917dba-9f75-4250-a696-255793c1e97f","html_url":"https://github.com/ropensci/googleLanguageR","commit_stats":{"total_commits":344,"total_committers":9,"mean_commits":38.22222222222222,"dds":0.2616279069767442,"last_synced_commit":"5152257d7aac6270cfa7ac34f21becaefa4b1270"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ropensci%2FgoogleLanguageR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ropensci%2FgoogleLanguageR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ropensci%2FgoogleLanguageR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ropensci%2FgoogleLanguageR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ropensci","download_url":"https://codeload.github.com/ropensci/googleLanguageR/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250960193,"owners_count":21514405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloud-speech-api","cloud-translation-api","google-api-client","google-cloud","google-cloud-speech","google-nlp","googleauthr","natural-language-processing","peer-reviewed","r","r-package","rstats","sentiment-analysis","speech-api","translation-api"],"created_at":"2024-08-02T06:00:41.484Z","updated_at":"2025-04-26T08:32:19.245Z","avatar_url":"https://github.com/ropensci.png","language":"HTML","readme":"# googleLanguageR - R client for the Google Translation API, Natural Language API, Speech-to-Text API and Text-to-Speech API\n\n[![CRAN](https://www.r-pkg.org/badges/version/googleLanguageR)](https://cran.r-project.org/package=googleLanguageR)\n[![Build\nStatus](https://travis-ci.org/ropensci/googleLanguageR.png?branch=master)](https://travis-ci.org/ropensci/googleLanguageR)\n[![codecov.io](https://codecov.io/github/ropensci/googleLanguageR/coverage.svg?branch=master)](http://codecov.io/github/ropensci/googleLanguageR?branch=master)\n[![](https://badges.ropensci.org/127_status.svg)](https://github.com/ropensci/onboarding/issues/127)\n\n## Language tools for R via Google Machine Learning APIs\n\nRead the [introduction blogpost on rOpenSci's blog](https://ropensci.org/blog/2017/10/03/googlelanguager/)\n\nThis package contains functions for analysing language through the\n[Google Cloud Machine Learning\nAPIs](https://cloud.google.com/products/machine-learning/)\n\nNote all are paid services, you will need to provide your credit card\ndetails for your own Google Project to use them.\n\nThe package can be used by any user who is looking to take advantage of\nGoogle’s massive dataset to train these machine learning models. Some\napplications include:\n\n  - Translation of speech into another language text, via speech-to-text\n    then translation and having the results spoen back to you\n  - Talking Shiny apps\n  - Identification of sentiment within text, such as from Twitter feeds\n  - Pulling out the objects of a sentence, to help classify texts and\n    get metadata links from Wikipedia about them.\n\nThe applications of the API results could be relevant to business or\nresearchers looking to scale text analysis.\n\n## Google Natural Language API\n\n\u003e Google Natural Language API reveals the structure and meaning of text\n\u003e by offering powerful machine learning models in an easy to use REST\n\u003e API. You can use it to extract information about people, places,\n\u003e events and much more, mentioned in text documents, news articles or\n\u003e blog posts. You can also use it to understand sentiment about your\n\u003e product on social media or parse intent from customer conversations\n\u003e happening in a call center or a messaging app.\n\nRead more [on the Google Natural Language\nAPI](https://cloud.google.com/natural-language/)\n\n## Google Cloud Translation API\n\n\u003e Google Cloud Translation API provides a simple programmatic interface\n\u003e for translating an arbitrary string into any supported language.\n\u003e Translation API is highly responsive, so websites and applications can\n\u003e integrate with Translation API for fast, dynamic translation of source\n\u003e text from the source language to a target language (e.g. French to\n\u003e English).\n\nRead more [on the Google Cloud Translation\nWebsite](https://cloud.google.com/translate/)\n\n## Google Cloud Speech-to-Text API\n\n\u003e Google Cloud Speech-to-Text API enables you to convert audio to text\n\u003e by applying neural network models in an easy to use API. The API\n\u003e recognizes over 80 languages and variants, to support your global user\n\u003e base. You can transcribe the text of users dictating to an\n\u003e application’s microphone or enable command-and-control through voice\n\u003e among many other use cases.\n\nRead more [on the Google Cloud Speech\nWebsite](https://cloud.google.com/speech/)\n\n## Google Cloud Text-to-Speech API\n\n\u003e Google Cloud Text-to-Speech enables developers to synthesize\n\u003e natural-sounding speech with 30 voices, available in multiple\n\u003e languages and variants. It applies DeepMind’s groundbreaking research\n\u003e in WaveNet and Google’s powerful neural networks to deliver the\n\u003e highest fidelity possible. With this easy-to-use API, you can create\n\u003e lifelike interactions with your users, across many applications and\n\u003e devices.\n\nRead more [on the Google Cloud Text-to-Speech\nWebsite](https://cloud.google.com/text-to-speech/)\n\n## Installation\n\n1.  Create a [Google API Console\n    Project](https://cloud.google.com/resource-manager/docs/creating-managing-projects)\n2.  Within your project, add a [payment method to the\n    project](https://support.google.com/cloud/answer/6293589)\n3.  Within your project, check the relevant APIs are activated\n\n\u003c!-- end list --\u003e\n\n  - [Google Natural Language\n    API](https://console.cloud.google.com/apis/api/language.googleapis.com/overview)\n  - [Google Cloud Translation\n    API](https://console.cloud.google.com/apis/api/translate.googleapis.com/overview)\n  - [Google Cloud Speech-to-Text\n    API](https://console.cloud.google.com/apis/api/speech.googleapis.com/overview)\n  - [Google Cloud Text-to-Speech API](https://console.cloud.google.com/apis/library/texttospeech.googleapis.com)\n\n\u003c!-- end list --\u003e\n\n4.  [Generate a service account\n    credential](https://cloud.google.com/storage/docs/authentication#generating-a-private-key)\n    as a JSON file by first [creating a service account](https://developers.google.com/workspace/guides/create-credentials#create_a_service_account) and then [creating credentials for a service account](https://developers.google.com/workspace/guides/create-credentials#create_credentials_for_a_service_account)\n5.  Return to R, and install the official release via\n    `install.packages(\"googleLanguageR\")`, or the development version\n    with `remotes::install_github(\"ropensci/googleLanguageR\")`\n    \n### Docker image\n\nSome Docker images are publicly available.  In general `gcr.io/gcer-public/googleLanguageR:$BRANCH_NAME` carries that GitHub branch's version.\n\n* `gcr.io/gcer-public/googleLanguageR:CRAN` - the latest CRAN version  [![CRAN](https://www.r-pkg.org/badges/version/googleLanguageR)](https://cran.r-project.org/package=googleLanguageR)\n* `gcr.io/gcer-public/googleLanguageR:master` - latest GitHub master version [![Build\nStatus](https://travis-ci.org/ropensci/googleLanguageR.png?branch=master)](https://travis-ci.org/ropensci/googleLanguageR)\n* `gcr.io/gcer-public/googleLanguageR:feature` - a feature branch from GitHub\n\n## Usage\n\n### Authentication\n\nThe best way to authenticate is to use an environment file. See\n`?Startup`. I usually place this in my home directory. (e.g. if using\nRStudio, click on `Home` in the file explorer, create a new `TEXT` file\nand call it `.Renviron`)\n\nSet the file location of your download Google Project JSON file in a\n`GL_AUTH` argument:\n\n    #.Renviron\n    GL_AUTH=location_of_json_file.json\n\nThen, when you load the library you should auto-authenticate:\n\n``` r\nlibrary(googleLanguageR)\n```\n\nYou can also authenticate directly using the `gl_auth` function pointing\nat your JSON auth file:\n\n``` r\nlibrary(googleLanguageR)\ngl_auth(\"location_of_json_file.json\")\n```\n\nYou can then call the APIs via the functions:\n\n  - `gl_nlp()` - Natural Langage API\n  - `gl_speech()` - Cloud Speech-to-Text API\n  - `gl_translate()` - Cloud Translation API\n  - `gl_talk()` - Cloud Text-to-Speech API\n\n## Natural Language API\n\nThe Natural Language API returns natural language understanding\ntechnolgies. You can call them individually, or the default is to return\nthem all. The available returns are:\n\n  - *Entity analysis* - Finds named entities (currently proper names and\n    common nouns) in the text along with entity types, salience,\n    mentions for each entity, and other properties. If possible, will\n    also return metadata about that entity such as a Wikipedia URL. If\n    using the **v1beta2** endpoint this also includes sentiment for each\n    entity.\n  - *Syntax* - Analyzes the syntax of the text and provides sentence\n    boundaries and tokenization along with part of speech tags,\n    dependency trees, and other properties.\n  - *Sentiment* - The overall sentiment of the text, represented by a\n    magnitude `[0, +inf]` and score between `-1.0` (negative sentiment)\n    and `1.0` (positive sentiment).\n\n### Demo for Entity Analysis\n\nYou can pass a vector of text which will call the API for each element.\nThe return is a list of responses, each response being a list of tibbles\nholding the different types of\nanalysis.\n\n``` r\ntexts \u003c- c(\"to administer medicince to animals is frequently a very difficult matter, and yet sometimes it's necessary to do so\", \n         \"I don't know how to make a text demo that is sensible\")\nnlp_result \u003c- gl_nlp(texts)\n\n# two results of lists of tibbles\nstr(nlp_result, max.level = 2)\n```\n\nSee more examples and details [on the\nwebsite](http://code.markedmondson.me/googleLanguageR/articles/nlp.html)\nor via `vignette(\"nlp\", package = \"googleLanguageR\")`\n\n## Google Translation API\n\nYou can detect the language via `gl_translate_detect`, or translate and\ndetect language via `gl_translate`\n\nNote this is a lot more refined than the free version on Google’s\ntranslation\nwebsite.\n\n``` r\ntext \u003c- \"to administer medicine to animals is frequently a very difficult matter, and yet sometimes it's necessary to do so\"\n## translate British into Danish\ngl_translate(text, target = \"da\")$translatedText\n```\n\nSee more examples and details [on the\nwebsite](http://code.markedmondson.me/googleLanguageR/articles/translation.html)\nor via `vignette(\"translate\", package = \"googleLanguageR\")`\n\n## Google Cloud Speech-to-Text API\n\nThe Cloud Speech-to-Text API provides audio transcription. Its\naccessible via the `gl_speech` function.\n\nA test audio file is installed with the package which reads:\n\n\u003e “To administer medicine to animals is frequently a very difficult\n\u003e matter, and yet sometimes it’s necessary to do so”\n\nThe file is sourced from the University of Southampton’s speech\ndetection (`http://www-mobile.ecs.soton.ac.uk/newcomms/`) group and is\nfairly difficult for computers to parse, as we see below:\n\n``` r\n## get the sample source file\ntest_audio \u003c- system.file(\"woman1_wb.wav\", package = \"googleLanguageR\")\n\n## its not perfect but...:)\ngl_speech(test_audio)$transcript\n\n\n    ## # A tibble: 1 x 2\n    ##   transcript                                                    confidence\n    ##   \u003cchr\u003e                                                         \u003cchr\u003e     \n    ## 1 to administer medicine to animals is frequency of very diffi… 0.9180294\n```\n\nSee more examples and details [on the\nwebsite](http://code.markedmondson.me/googleLanguageR/articles/speech.html)\nor via `vignette(\"speech\", package = \"googleLanguageR\")`\n\n## Google Cloud Text-to-Speech API\n\nThe Cloud Text-to-Speech API turns text into talk audio files. Its\naccessible via the `gl_talk` function.\n\nTo use, supply your text to the function:\n\n``` r\ngl_talk(\"This is a talking computer.  Hello Dave.\")\n```\n\nSee more examples and details [on the\nwebsite](http://code.markedmondson.me/googleLanguageR/articles/text-to-speech.html)\nor via `vignette(\"text-to-speech\", package =\n\"googleLanguageR\")`\n\n[![ropensci\\_footer](https://ropensci.org/public_images/ropensci_footer.png)](https://ropensci.org)\n","funding_links":[],"categories":["HTML","R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fropensci%2FgoogleLanguageR","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fropensci%2FgoogleLanguageR","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fropensci%2FgoogleLanguageR/lists"}