knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ini0 <- Sys.time()
https://github.com/filipezabala/voice
# Install devtools package if necessary if(!'devtools' %in% rownames(installed.packages())) install.packages('devtools') # Install the stable development versions from GitHub devtools::install_github('filipezabala/voice') devtools::install_github('mccarthy-m-g/embedr')
# packs library(voice) # get path to audio file wavDir <- list.files(system.file('extdata', package = 'wrassp'), pattern = glob2rx('*.wav'), full.names = TRUE)
# minimal usage M <- voice::extract_features(wavDir) M
# creating Extended synthetic data E <- dplyr::tibble(subject_id = c(1,1,1,2,2,2,3,3,3), wav_path = wavDir) E # minimal usage voice::tag(E) # canonical data voice::tag(E, groupBy = 'subject_id')
url0 <- 'https://github.com/filipezabala/voiceAudios/blob/main/mp3/doremi.mp3?raw=true' download.file(url0, paste0(tempdir(), '/doremi.mp3'), mode = 'wb') embedr::embed_audio(url0)
cmd <- paste0('cd ', tempdir(), ';', ' for i in *.[Mm][Pp]3; do ffmpeg -i "$i" -ac 1 "./${i%.*}.wav"; done') system(cmd)
M <- voice::extract_features(tempdir()) summary(M)
voice::piano_plot(M, 0) # f0 voice::piano_plot(M, 0:1) # f0 + f1
(f0_spn <- voice::assign_notes(M, fmt = 0, min_points = 22, min_percentile = .85)) # f0 (f1_spn <- voice::assign_notes(M, fmt = 1, min_points = 22, min_percentile = .85)) # f1 (f2_spn <- voice::assign_notes(M, fmt = 2, min_points = 22, min_percentile = .85)) # f2
library(gm) line_0 <- gm::Line(as.character(f0_spn)) m0 <- gm::Music() + gm::Meter(4, 4) + line_0 gm::show(m0, to = c('score', 'audio'))
line_0 <- gm::Line(as.character(f0_spn)) line_1 <- gm::Line(as.character(f1_spn)) m1 <- gm::Music() + gm::Meter(4, 4) + line_0 + line_1 gm::show(m1, to = c('score', 'audio'))
line_0 <- gm::Line(as.character(f0_spn)) line_1 <- gm::Line(as.character(f1_spn)) line_2 <- gm::Line(as.character(f2_spn)) m2 <- gm::Music() + gm::Meter(4, 4) + line_0 + line_1 + line_2 gm::show(m2, to = c('score', 'audio'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.