# NOT RUN {
target = soundgen(sylLen = 500, formants = 'a',
pitchAnchors = data.frame(time = c(0, 0.1, 0.9, 1),
value = c(100, 150, 135, 100)),
temperature = 0)
targetSpec = soundgen:::getMelSpec(target, samplingRate = 16000)
parsToTry = list(
list(formants = 'i', # wrong
pitchAnchors = data.frame(time = c(0, 1), # wrong
value = c(200, 300))),
list(formants = 'i', # wrong
pitchAnchors = data.frame(time = c(0, 0.1, 0.9, 1), # right
value = c(100, 150, 135, 100))),
list(formants = 'a', # right
pitchAnchors = data.frame(time = c(0,1), # wrong
value = c(200, 300))),
list(formants = 'a',
pitchAnchors = data.frame(time = c(0, 0.1, 0.9, 1), # right
value = c(100, 150, 135, 100))) # right
)
sounds = list()
for (s in 1:length(parsToTry)) {
sounds[[length(sounds) + 1]] = do.call(soundgen,
c(parsToTry[[s]], list(temperature = 0, sylLen = 500)))
}
method = c('cor', 'cosine', 'pixel', 'dtw')
df = matrix(NA, nrow = length(parsToTry), ncol = length(method))
colnames(df) = method
df = as.data.frame(df)
for (i in 1:nrow(df)) {
df[i, ] = compareSounds(
target = NULL, # can use target instead of targetSpec...
targetSpec = targetSpec, # ...but faster to calculate targetSpec once
cand = sounds[[i]],
samplingRate = 16000,
padWith = NA,
penalizeLengthDif = TRUE,
method = method,
summary = FALSE
)
}
df$av = rowMeans(df, na.rm = TRUE)
df # row 1 = wrong pitch & formants, ..., row 4 = right pitch & formants
# }
Run the code above in your browser using DataLab