Skip to content

Instantly share code, notes, and snippets.

@monogenea

monogenea/7-audioClass.R

Last active Apr 6, 2020
Embed
What would you like to do?
# Plot spectrogram from random training sample - range is 0-22.05 kHz
image(train$X[sample(dim(train$X)[1], 1),,,],
xlab = "Time (s)",
ylab = "Frequency (kHz)",
axes = F)
# Generate mel sequence from Hz points, standardize to plot
freqs <- c(0, 1, 5, 15, 22.05)
mels <- 2595 * log10(1 + (freqs*1e3) / 700) # https://en.wikipedia.org/wiki/Mel_scale
mels <- mels - min(mels)
mels <- mels / max(mels)
axis(1, at = seq(0, 1, by = .2), labels = seq(0, 10, by = 2))
axis(2, at = mels, las = 2,
labels = round(freqs, 2))
axis(3, labels = F); axis(4, labels = F)
#### Save ####
save(train, val, test, file = "prepAudio.RData")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment