-
Notifications
You must be signed in to change notification settings - Fork 42
/
ui.R
84 lines (80 loc) · 4.15 KB
/
ui.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
library(shiny)
library(shinyjs)
shinyUI(
fluidPage(
useShinyjs(),
includeCSS("www/style.css"),
includeScript("www/main.js"),
includeScript("www/speech.js"),
includeScript("www/audiodisplay.js"),
titlePanel("Shiny Babelfish"),
sidebarLayout(
sidebarPanel(
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", "Language input", 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("You can also add a call to the Google Translation API by selecting an output below"),
selectInput("translate", "Translate output", choices = c("No Translation" = "none",
"English" = "en",
"Danish" = "da",
"French" = "fr",
"German" = "de",
"Spanish" = "es",
"Dutch" = "nl",
"Romainian" = "ro",
"Italian" = "it",
"Norwegian" = "nb",
"Swedish" = "sv")),
helpText("Send the text to the Natural Language API for NLP analysis below."),
selectInput("nlp", "Perform NLP", choices = c("No NLP" = "none",
"NLP" = "input"
#,
#"On Translated Text" = "trans"
)
),
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(
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"))
)),
h2("Transcribed text"),
p(textOutput("result_text")),
h2("Translated text"),
p(textOutput("result_translation")),
h2("NLP"),
tableOutput("nlp_sentences"),
tableOutput("nlp_tokens"),
tableOutput("nlp_entities"),
tableOutput("nlp_misc"),
htmlOutput("talk")
)
),
helpText(
a("Adapted from Web Audio Demos",
href="https://webaudiodemos.appspot.com/AudioRecorder/index.html"))
))