From 916510eb70946c9b4d3cccd5911e532b84b2d38b Mon Sep 17 00:00:00 2001 From: Mark Edmondson Date: Sun, 19 Apr 2020 15:12:21 +0200 Subject: [PATCH] rename build folder #70 and add some docs --- .Rbuildignore | 2 +- {build => cloud_build}/build.R | 0 {build => cloud_build}/cloudbuild-tests.yml | 0 vignettes/speech.Rmd | 27 +- vignettes/speech.html | 42 +- vignettes/text-to-speech.Rmd | 28 ++ vignettes/text-to-speech.html | 427 ++++++++++++++++---- 7 files changed, 419 insertions(+), 107 deletions(-) rename {build => cloud_build}/build.R (100%) rename {build => cloud_build}/cloudbuild-tests.yml (100%) diff --git a/.Rbuildignore b/.Rbuildignore index e3dcca5..7c43eda 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -9,5 +9,5 @@ ^\.httr-oauth$ ^cran-comments\.md$ ^\.Renviron$ -^build$ +^cloud_build$ ^CRAN-RELEASE$ diff --git a/build/build.R b/cloud_build/build.R similarity index 100% rename from build/build.R rename to cloud_build/build.R diff --git a/build/cloudbuild-tests.yml b/cloud_build/cloudbuild-tests.yml similarity index 100% rename from build/cloudbuild-tests.yml rename to cloud_build/cloudbuild-tests.yml diff --git a/vignettes/speech.Rmd b/vignettes/speech.Rmd index e694209..590c647 100644 --- a/vignettes/speech.Rmd +++ b/vignettes/speech.Rmd @@ -1,17 +1,17 @@ --- -title: "Google Cloud Speech API" +title: "Google Cloud Speech-to-Text API" author: "Mark Edmondson" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > - %\VignetteIndexEntry{Google Cloud Speech API} + %\VignetteIndexEntry{Google Cloud Speech-to-Text API} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- -The Google Cloud Speech API enables you to convert audio to text by applying neural network models in an easy to use API. The API recognizes over 80 languages and variants, to support your global user base. You can transcribe the text of users dictating to an application’s microphone or enable command-and-control through voice among many other use cases. +The Google Cloud Speech-to-Text API enables you to convert audio to text by applying neural network models in an easy to use API. The API recognizes over 80 languages and variants, to support your global user base. You can transcribe the text of users dictating to an application’s microphone or enable command-and-control through voice among many other use cases. -Read more [on the Google Cloud Speech Website](https://cloud.google.com/speech/) +Read more [on the Google Cloud Speech-to-Text Website](https://cloud.google.com/speech/) The Cloud Speech API provides audio transcription. Its accessible via the `gl_speech` function. @@ -47,7 +47,7 @@ return$timings # etc... ``` -### Demo for Google Cloud Speech API +### Demo for Google Cloud Speech-to-Text API A test audio file is installed with the package which reads: @@ -96,6 +96,23 @@ result$timings #5 0.900s 1s Dream ``` +## Custom configurations + +You can also send in other arguments which can help shape the output, such as speaker diagrization (labelling different speakers) - to use such custom configurations create a [`RecognitionConfig`](https://cloud.google.com/speech-to-text/docs/reference/rest/v1p1beta1/RecognitionConfig) object. This can be done via R lists which are converted to JSON via `library(jsonlite)` and an example is shown below: + +```r +## Use a custom configuration +my_config <- list(encoding = "LINEAR16", + diarizationConfig = list( + enableSpeakerDiarization = TRUE, + minSpeakerCount = 2, + maxSpeakCount = 3 + )) + +# languageCode is required, so will be added if not in your custom config +gl_speech(my_audio, languageCode = "en-US", customConfig = my_config) +``` + ## Asynchronous calls For speech files greater than 60 seconds of if you don't want your results straight away, set `asynch = TRUE` in the call to the API. diff --git a/vignettes/speech.html b/vignettes/speech.html index 187bea3..eb6dada 100644 --- a/vignettes/speech.html +++ b/vignettes/speech.html @@ -12,9 +12,9 @@ - + -Google Cloud Speech API +Google Cloud Speech-to-Text API @@ -299,14 +299,14 @@ -

Google Cloud Speech API

+

Google Cloud Speech-to-Text API

Mark Edmondson

-

2020-04-16

+

2020-04-19

-

The Google Cloud Speech API enables you to convert audio to text by applying neural network models in an easy to use API. The API recognizes over 80 languages and variants, to support your global user base. You can transcribe the text of users dictating to an application’s microphone or enable command-and-control through voice among many other use cases.

-

Read more on the Google Cloud Speech Website

+

The Google Cloud Speech-to-Text API enables you to convert audio to text by applying neural network models in an easy to use API. The API recognizes over 80 languages and variants, to support your global user base. You can transcribe the text of users dictating to an application’s microphone or enable command-and-control through voice among many other use cases.

+

Read more on the Google Cloud Speech-to-Text Website

The Cloud Speech API provides audio transcription. Its accessible via the gl_speech function.

Arguments include: