0

I have a data frame about voices and emotions. Using shiny I want to create a scatter plot graph with a tooltip which shows the name and type of emotions and runs the audio file. When people click on a point, I want to hear the audio of this emotion. However, I cannot find any solution to run an audio file. Audio files in wav format. Basically, I want to know how I add audio files into hoover or tooltip. I used hchart package for create graph.

This is server part of my shiny app

require(shinydashboard)
require(ggplot2)
require(dplyr)
require(highcharter) 
library(readxl)
require(tidyr)

server <- function(input, output) {  




  output$hcontainer <- renderHighchart ({

    data_frame <- data %>% filter(Language == input$language & acoustics == input$acoustic_parameter) 


    ##plot, ADD audio file for points
    hchart(data, "scatter", hcaes(x = Emotion , y = values, group = Vocalization)) %>%
      hc_exporting(enabled = TRUE) %>% 
      hc_tooltip(crosshairs = TRUE, backgroundColor = "#FCFFC5",
                 shared = TRUE, borderWidth = 2) %>%
      hc_title(text="Acoustic Parameter",align="center") %>%
      hc_subtitle(text="Emotion - Vocalization Graph",align="center") %>%
      hc_add_theme(hc_theme_elementary())

  })

}

This is the codes for ui

##required packages.

library(shinydashboard)
require(shiny)
require(highcharter)

##there is two input, language: Dutch, Chinese, acoustic parameter: 10 different, 

language <- c("Dutch", "Chinese") 
acoustic_parameter <- c("loudness_sma3_amean",
                        "loudness_sma3_pctlrange0-2",
                        "mfcc3_sma3_amean",
                        "F1amplitudeLogRelF0_sma3nz_amean",
                        "hammarbergIndexV_sma3nz_amean",
                        "F0semitoneFrom27.5Hz_sma3nz_percentile20.0",
                        "loudness_sma3_percentile50.0",
                        "mfcc1_sma3_amean",
                        "HNRdBACF_sma3nz_amean",
                        "F2amplitudeLogRelF0_sma3nz_amean")


dashboardPage(
  #defines header of dashboard
  skin = "red",
  dashboardHeader(
    title="Shiny Project Deneme" ,
    dropdownMenu()
  ),

  ##define sidebar 
  dashboardSidebar(
    sidebarMenu(
      menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
      menuItem("About", tabName = "about", icon = icon("th")),
      menuItem("Project",tabName="unions",icon=icon("signal"))

    )
  ),
  ##defines body

  dashboardBody(
    tags$head(
      tags$link(rel = "stylesheet", type = "text/css", href = "custom.css")
    ),

    #First TAB Menu-Dashboard  
    tabItem(tabName = "dashboard",

            fluidRow(




              column(12,
                     box(selectInput("language", label = "Language", choices = language))),
              column(12,
                     box(selectInput("acoustic_parameter", label = "acoustic parameter", choices = acoustic_parameter))),

              column(12,

                     box(

                       highchartOutput("hcontainer"),

                        width="12") #end of the box
              ), #close the column

          hr(),
          h4("Plot of the these Project", align = "center"),
          br(),
          column(12, 

                 box(
                   highchartOutput("hc2"), width=12
                 ))
            ), ## close the row 

          h4("First trial", strong("Alkim Karakurt")), 

    ), # close the first tab item 

    #second tab menu 
      tabItem(tabName = "about", 
              fluidPage(
      br(),
      br(),
      box(width = 12, height = "300px",
          p(style ="font-size:18px", strong("Center for Data Science"), "Project Type"),

          ) #close box
              ) #close fluid
      ), #close tab item


  )

)
patula
  • 136
  • 5
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. Be sure to explicitly list any non-base R packages you are using. – MrFlick Jan 15 '20 at 17:08
  • I updated, it is included my all codes. – patula Jan 15 '20 at 17:49
  • 1
    I ran into the same problem recently and developed a solution with the R package `ggiraph`. More details [here](https://petergill.shinyapps.io/shinyplay/). – Peter Jun 01 '20 at 10:14
  • This looks very nice. I cannot create a graph like that. I solved my problem creating some audio input and this input filtering with graphs points. But, your dashboard looks so nice. Good job! – patula Jun 03 '20 at 10:59

0 Answers0