I'd like to try to distinguish two speakers in a wav file. The most straightforward way seems like it should be to extract frequency info from the file, and use time to match frequency with a given part of the file. I don't see a function in tuneR or seewave to easily extract a dataframe like this. What's the easiest way to do it? Thanks!
Here's something that might help. The spectro
function returns time, frequency and amplitude and with some manipulation using functions in reshape2
and dplyr
you can get a data frame.
library(seewave)
library(tuneR)
library(reshape2)
library(dplyr)
data("pellucens")
writeWave(pellucens, "pellucens.wav")
wav = readWave("pellucens.wav")
ss = spectro(wav, plot = F)
mm =
melt(ss$amp, value.name = "Amplitude") %>%
dplyr::select(FrequencyIndex = Var1, TimeIndex = Var2, Amplitude)
ff =
melt(ss$freq, value.name = "Frequency") %>%
dplyr::mutate(FrequencyIndex = row_number(), Frequency = Frequency * 1000)
tt =
melt(ss$time, value.name = "Time") %>%
dplyr::mutate(TimeIndex = row_number())
sp =
mm %>%
dplyr::left_join(ff, by = "FrequencyIndex") %>%
dplyr::left_join(tt, by = "TimeIndex") %>%
dplyr::select(Time, Frequency, Amplitude)
# head(sp)
# Time Frequency Amplitude
#1 0 0.00000 -57.72730
#2 0 21.53320 -63.55554
#3 0 43.06641 -85.05077
#4 0 64.59961 -91.29989
#5 0 86.13281 -83.86144
#6 0 107.66602 -81.54240
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.