Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be2f8ff
commit 2d101aa
Showing
5 changed files
with
70 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,5 +38,7 @@ Suggests: | |
rmarkdown, | ||
rvest, | ||
stringdist, | ||
shinyjs, | ||
tidyr, | ||
tuneR, | ||
xml2 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Title: Cloud Speech in Shiny | ||
Author: Mark Edmondson | ||
AuthorUrl: http://code.markedmondson.me | ||
License: MIT | ||
DisplayMode: Showcase | ||
Type: Shiny |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Google Cloud Speech API Shiny app | ||
|
||
This is a demo on using the [Cloud Speech API](https://cloud.google.com/speech/) with Shiny. | ||
|
||
It uses `library(tuneR)` to process the audio file, and a JavaScript audio library from [Web Audio Demos](https://webaudiodemos.appspot.com/AudioRecorder/index.html) to capture the audio in your browser. |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,56 @@ | ||
library(shiny) | ||
library(shinyjs) | ||
|
||
shinyUI( | ||
fluidPage( | ||
useShinyjs(), | ||
includeCSS("www/style.css"), | ||
includeScript("www/main.js"), | ||
includeScript("www/speech.js"), | ||
includeScript("www/audiodisplay.js"), | ||
|
||
titlePanel("Capture Speech"), | ||
|
||
a("Adapted from Web Audio Demos", | ||
href="https://webaudiodemos.appspot.com/AudioRecorder/index.html"), | ||
titlePanel("Capture audio and send to Google Speech API"), | ||
|
||
sidebarLayout( | ||
sidebarPanel( | ||
helpText("Click on the microphone to record, click again to send to Cloud Speech API"), | ||
img(id = "record", src = "mic128.png", onclick = "toggleRecording(this);"), | ||
helpText("Click on the microphone to record, click again to send to Cloud Speech API and wait for results."), | ||
img(id = "record", | ||
src = "mic128.png", | ||
onclick = "toggleRecording(this);", | ||
style = "display:block; margin:1px auto;"), | ||
hr(), | ||
div(id = "viz", | ||
tags$canvas(id = "analyser"), | ||
tags$canvas(id = "wavedisplay") | ||
) | ||
), | ||
br(), | ||
hr(), | ||
selectInput("language", "Add a languageCode", choices = c("English (UK)" = "en-GB", | ||
"English (Americans)" = "en-US", | ||
"Danish" = "da-DK", | ||
"French (France)" = "fr-FR", | ||
"German" = "de-DE", | ||
"Spanish (Spain)" = "es-ES", | ||
"Spanish (Chile)" = "es-CL", | ||
"Dutch" = "nl-NL", | ||
"Romainian" = "ro-RO", | ||
"Italian" = "it-IT", | ||
"Norwegian" = "nb-NO", | ||
"Swedish" = "sv-SE")), | ||
helpText("Many more languages are supported in the API but I couldn't be bothered to put them all in - see here:", | ||
a(href="https://cloud.google.com/speech/docs/languages", "Supported languages")) | ||
), | ||
|
||
mainPanel( | ||
h3("Transcription"), | ||
textOutput("result_text"), | ||
textOutput("the_time") | ||
helpText("Transcription will appear here when ready. (Can take 30 seconds +). Streaming support not implemented yet."), | ||
shinyjs::hidden( | ||
div(id = "api", | ||
p("Calling API - please wait", icon("circle-o-notch fa-spin fa-fw")) | ||
)), | ||
h3(textOutput("result_text")) | ||
) | ||
) | ||
), | ||
helpText( | ||
a("Adapted from Web Audio Demos", | ||
href="https://webaudiodemos.appspot.com/AudioRecorder/index.html")) | ||
)) |