|
| 1 | + |
| 2 | + |
| 3 | +# zipf-plots |
| 4 | + |
| 5 | +wav_orig <- dir('vtl_corpus1.0/wav_original/') |
| 6 | +tokens_orig <- tools::file_path_sans_ext(wav_orig) # remove .wav |
| 7 | +tokens_orig <- substring(tokens_orig, 8) # remove numbers in the beginning |
| 8 | + |
| 9 | +types_orig <- table(tokens_orig) |
| 10 | +types_orig <- sort(types_orig, decreasing=T) |
| 11 | + |
| 12 | +wav_synth <- dir('vtl_corpus1.0/wav_synthesized/') |
| 13 | +tokens_synth <- tools::file_path_sans_ext(wav_synth) # remove .wav |
| 14 | +tokens_synth <- substring(tokens_synth, 8) # remove numbers in the beginning |
| 15 | + |
| 16 | +types_synth <- table(tokens_synth) |
| 17 | +types_synth <- sort(types_synth, decreasing=T) |
| 18 | + |
| 19 | +pdf('figs/zipf.pdf', height=4, width=8) |
| 20 | +par(mfcol=c(1,2)) |
| 21 | + |
| 22 | +plot(log10(types_orig), log='x', axes=F, xlab="words", ylab="occurrences", main='Recorded') |
| 23 | +axis(1, at=1:length(types_orig), labels=names(types_orig)) |
| 24 | +yticks <- c(1:9, 1:9*10, 1:9*100, 1:2*1000) |
| 25 | +axis(2, at=log10(yticks), labels=yticks) |
| 26 | + |
| 27 | +plot(log10(types_synth), log='x', axes=F, xlab="words", ylab="occurrences", main='Synthesized') |
| 28 | +axis(1, at=1:length(types_synth), labels=names(types_synth)) |
| 29 | +yticks <- c(1:9, 1:9*10, 1:9*100, 1:2*1000) |
| 30 | +axis(2, at=log10(yticks), labels=yticks) |
| 31 | +dev.off() |
| 32 | + |
| 33 | + |
| 34 | +# durations |
| 35 | + |
| 36 | +dur_orig <- rep(NA, length(wav_orig)) |
| 37 | + |
| 38 | +for (ii in 1:length(wav_orig)) { |
| 39 | + name <- wav_orig[ii] |
| 40 | + wav <- readWave(paste0('vtl_corpus1.0/wav_original/', name)) |
| 41 | + dur_orig[ii] <- length(wav@left) / wav@samp.rate |
| 42 | +} |
| 43 | + |
| 44 | +dur_synth <- rep(NA, length(wav_synth)) |
| 45 | + |
| 46 | +for (ii in 1:length(wav_synth)) { |
| 47 | + name <- wav_synth[ii] |
| 48 | + wav <- readWave(paste0('vtl_corpus1.0/wav_synthesized/', name)) |
| 49 | + dur_synth[ii] <- length(wav@left) / wav@samp.rate |
| 50 | +} |
| 51 | + |
| 52 | + |
0 commit comments