## First specify the packages of interest packages = c("tidyverse", "ggplot2", "dplyr", "phonR", "gridExtra") ## Now load or install&load all package.check <- lapply( packages, FUN = function(x) { if (!require(x, character.only = TRUE)) { install.packages(x, dependencies = TRUE) library(x, character.only = TRUE) } } ) # read data from file setwd("/home/sven/dev/r-vowels") data.ljspeech <- read.csv('formants_LJSpeech.csv') data.nigeria <- read.csv('formants_Nigeria.csv') data.china <- read.csv('formants_GuoYa.csv') data.thchs <- read.csv('formants_THCHS_30-D6-utf8.csv', encoding="UTF-8") # filter missing data data.ljspeech <- subset(data.ljspeech, F1_20 != "--undefined--") data.ljspeech <- subset(data.ljspeech, F1_50 != "--undefined--") data.ljspeech <- subset(data.ljspeech, F1_80 != "--undefined--") data.ljspeech <- subset(data.ljspeech, F2_20 != "--undefined--") data.ljspeech <- subset(data.ljspeech, F2_50 != "--undefined--") data.ljspeech <- subset(data.ljspeech, F2_80 != "--undefined--") data.ljspeech <- subset(data.ljspeech, F3_20 != "--undefined--") data.ljspeech <- subset(data.ljspeech, F3_50 != "--undefined--") data.ljspeech <- subset(data.ljspeech, F3_80 != "--undefined--") data.nigeria <- subset(data.nigeria, F1_20 != "--undefined--") data.nigeria <- subset(data.nigeria, F1_50 != "--undefined--") data.nigeria <- subset(data.nigeria, F1_80 != "--undefined--") data.nigeria <- subset(data.nigeria, F2_20 != "--undefined--") data.nigeria <- subset(data.nigeria, F2_50 != "--undefined--") data.nigeria <- subset(data.nigeria, F2_80 != "--undefined--") data.nigeria <- subset(data.nigeria, F3_20 != "--undefined--") data.nigeria <- subset(data.nigeria, F3_50 != "--undefined--") data.nigeria <- subset(data.nigeria, F3_80 != "--undefined--") data.china <- subset(data.china, F1_20 != "--undefined--") data.china <- subset(data.china, F1_50 != "--undefined--") data.china <- subset(data.china, F1_80 != "--undefined--") data.china <- subset(data.china, F2_20 != "--undefined--") data.china <- subset(data.china, F2_50 != "--undefined--") data.china <- subset(data.china, F2_80 != "--undefined--") data.china <- subset(data.china, F3_20 != "--undefined--") data.china <- subset(data.china, F3_50 != "--undefined--") data.china <- subset(data.china, F3_80 != "--undefined--") data.thchs <- subset(data.thchs, F1_20 != "--undefined--") data.thchs <- subset(data.thchs, F1_50 != "--undefined--") data.thchs <- subset(data.thchs, F1_80 != "--undefined--") data.thchs <- subset(data.thchs, F2_20 != "--undefined--") data.thchs <- subset(data.thchs, F2_50 != "--undefined--") data.thchs <- subset(data.thchs, F2_80 != "--undefined--") data.thchs <- subset(data.thchs, F3_20 != "--undefined--") data.thchs <- subset(data.thchs, F3_50 != "--undefined--") data.thchs <- subset(data.thchs, F3_80 != "--undefined--") # convert frequencies because of missing data data.ljspeech$F1_20 <- as.numeric(data.ljspeech$F1_20) data.ljspeech$F1_50 <- as.numeric(data.ljspeech$F1_50) data.ljspeech$F1_80 <- as.numeric(data.ljspeech$F1_80) data.ljspeech$F2_20 <- as.numeric(data.ljspeech$F2_20) data.ljspeech$F2_50 <- as.numeric(data.ljspeech$F2_50) data.ljspeech$F2_80 <- as.numeric(data.ljspeech$F2_80) data.ljspeech$F3_20 <- as.numeric(data.ljspeech$F3_20) data.ljspeech$F3_50 <- as.numeric(data.ljspeech$F3_50) data.ljspeech$F3_80 <- as.numeric(data.ljspeech$F3_80) data.nigeria$F1_20 <- as.numeric(data.nigeria$F1_20) data.nigeria$F1_50 <- as.numeric(data.nigeria$F1_50) data.nigeria$F1_80 <- as.numeric(data.nigeria$F1_80) data.nigeria$F2_20 <- as.numeric(data.nigeria$F2_20) data.nigeria$F2_50 <- as.numeric(data.nigeria$F2_50) data.nigeria$F2_80 <- as.numeric(data.nigeria$F2_80) data.nigeria$F3_20 <- as.numeric(data.nigeria$F3_20) data.nigeria$F3_50 <- as.numeric(data.nigeria$F3_50) data.nigeria$F3_80 <- as.numeric(data.nigeria$F3_80) data.china$F1_20 <- as.numeric(data.china$F1_20) data.china$F1_50 <- as.numeric(data.china$F1_50) data.china$F1_80 <- as.numeric(data.china$F1_80) data.china$F2_20 <- as.numeric(data.china$F2_20) data.china$F2_50 <- as.numeric(data.china$F2_50) data.china$F2_80 <- as.numeric(data.china$F2_80) data.china$F3_20 <- as.numeric(data.china$F3_20) data.china$F3_50 <- as.numeric(data.china$F3_50) data.china$F3_80 <- as.numeric(data.china$F3_80) data.thchs$F1_20 <- as.numeric(data.thchs$F1_20) data.thchs$F1_50 <- as.numeric(data.thchs$F1_50) data.thchs$F1_80 <- as.numeric(data.thchs$F1_80) data.thchs$F2_20 <- as.numeric(data.thchs$F2_20) data.thchs$F2_50 <- as.numeric(data.thchs$F2_50) data.thchs$F2_80 <- as.numeric(data.thchs$F2_80) data.thchs$F3_20 <- as.numeric(data.thchs$F3_20) data.thchs$F3_50 <- as.numeric(data.thchs$F3_50) data.thchs$F3_80 <- as.numeric(data.thchs$F3_80) # convert some columns to factors data.ljspeech$phoneme <- as.factor(data.ljspeech$phoneme) data.ljspeech$file <- as.factor(data.ljspeech$file) data.nigeria$phoneme <- as.factor(data.nigeria$phoneme) data.nigeria$file <- as.factor(data.nigeria$file) data.china$phoneme <- as.factor(data.china$phoneme) data.china$file <- as.factor(data.china$file) data.thchs$phoneme <- as.factor(data.thchs$phoneme) data.thchs$file <- as.factor(data.thchs$file) # add speaker information for Nigeria data set # return string left of first dash followed by any character data.nigeria$speaker <- sub("-.*", "", data.nigeria$file) # define vowel sets arpabet_vowels = c('AA', 'AE', 'AH', 'AO', 'AW', 'AX', 'AY', 'EH', 'ER', 'EY', 'IH', 'IX', 'IY', 'OW', 'OY', 'UH', 'UW', 'UX') monophthongs = c('AA', 'AE', 'AH', 'AO', 'AX', 'EH', 'ER', 'IH', 'IX', 'IY', 'UH', 'UW', 'UX') diphthongs = c('AW', 'AY', 'EY', 'OW', 'OY') #selected_vowels = c('IH', 'IY') vowels.pinyin = c('a', 'o', 'e', 'u', 'v', 'i') diphthongs.pinyin = c('ei', 'ai', 'ou', 'ao', 've') ipa.symbols = c('ɑ', 'æ', 'ʌ', 'ɔ', 'aʊ', 'ə', 'aɪ', 'ɛ', 'ɝ', 'eɪ', 'ɪ', 'ɨ', 'i', 'oʊ', 'ɔɪ', 'ʊ', 'u', 'ʉ') monophthongs.ipa = c('ɑ', 'æ', 'ʌ', 'ɔ', 'ə', 'ɛ', 'ɝ', 'ɪ', 'ɨ', 'i', 'ʊ', 'u', 'ʉ') # only stressed vowels for GuoYa #vowels.china <- data.china %>% filter(grepl("1", phoneme)) #vowels.china <- vowels.china %>% filter(substr(phoneme, 1, 2)%in% monophthongs) # filter vowels vowels.ljspeech <- data.ljspeech %>% filter(substr(phoneme, 1, 2)%in% monophthongs) vowels.nigeria <- data.nigeria %>% filter(substr(phoneme, 1, 2)%in% monophthongs) vowels.china <- data.china %>% filter(substr(phoneme, 1, 2)%in% monophthongs) vowels.thchs <- data.thchs %>% filter(grepl("^.\\d$", phoneme)) vowels.thchs <- vowels.thchs %>% filter(substr(phoneme, 1, 1)%in% vowels.pinyin) # collapse tones in THCHS data # Note, this only works for one character vowels, not diphthongs etc. vowels.thchs.grouped <- vowels.thchs levels(vowels.thchs.grouped$phoneme) <- substr(levels(vowels.thchs.grouped$phoneme), 1, 1) # group vowels (collapse stress) vowels.ljspeech.grouped <- vowels.ljspeech vowels.nigeria.grouped <- vowels.nigeria vowels.china.grouped <- vowels.china levels(vowels.ljspeech.grouped$phoneme) <- substr(levels(vowels.ljspeech.grouped$phoneme), 1, 2) levels(vowels.nigeria.grouped$phoneme) <- substr(levels(vowels.nigeria.grouped$phoneme), 1, 2) levels(vowels.china.grouped$phoneme) <- substr(levels(vowels.china.grouped$phoneme), 1, 2) # calculate means of formant frequencies # note: this only makes sense for monophthongs vowels.ljspeech.grouped.means <- vowels.ljspeech.grouped vowels.ljspeech.grouped.means$F1.mean <- rowMeans(vowels.ljspeech.grouped[,c('F1_20','F1_50','F1_80')]) vowels.ljspeech.grouped.means$F2.mean <- rowMeans(vowels.ljspeech.grouped[,c('F2_20','F2_50','F2_80')]) vowels.ljspeech.grouped.means$F3.mean <- rowMeans(vowels.ljspeech.grouped[,c('F3_20','F3_50','F3_80')]) vowels.nigeria.grouped.means <- vowels.nigeria.grouped vowels.nigeria.grouped.means$F1.mean <- rowMeans(vowels.nigeria.grouped[,c('F1_20','F1_50','F1_80')]) vowels.nigeria.grouped.means$F2.mean <- rowMeans(vowels.nigeria.grouped[,c('F2_20','F2_50','F2_80')]) vowels.nigeria.grouped.means$F3.mean <- rowMeans(vowels.nigeria.grouped[,c('F3_20','F3_50','F3_80')]) vowels.china.grouped.means <- vowels.china.grouped vowels.china.grouped.means$F1.mean <- rowMeans(vowels.china.grouped[,c('F1_20','F1_50','F1_80')]) vowels.china.grouped.means$F2.mean <- rowMeans(vowels.china.grouped[,c('F2_20','F2_50','F2_80')]) vowels.china.grouped.means$F3.mean <- rowMeans(vowels.china.grouped[,c('F3_20','F3_50','F3_80')]) vowels.thchs.grouped.means <- vowels.thchs.grouped vowels.thchs.grouped.means$F1.mean <- rowMeans(vowels.thchs.grouped[,c('F1_20','F1_50','F1_80')]) vowels.thchs.grouped.means$F2.mean <- rowMeans(vowels.thchs.grouped[,c('F2_20','F2_50','F2_80')]) vowels.thchs.grouped.means$F3.mean <- rowMeans(vowels.thchs.grouped[,c('F3_20','F3_50','F3_80')]) # # filter outliners by using Hampel filter # # LJSpeech ljspeech.lower.boundf1 <- median(vowels.ljspeech.grouped.means$F1.mean) - 3 * mad(vowels.ljspeech.grouped.means$F1.mean) ljspeech.upper.boundf1 <- median(vowels.ljspeech.grouped.means$F1.mean) + 3 * mad(vowels.ljspeech.grouped.means$F1.mean) ljspeech.outlier.indices <- which(vowels.ljspeech.grouped.means$F1.mean < ljspeech.lower.boundf1 | vowels.ljspeech.grouped.means$F1.mean > ljspeech.upper.boundf1) ljspeech.lower.boundf2 <- median(vowels.ljspeech.grouped.means$F2.mean) - 3 * mad(vowels.ljspeech.grouped.means$F2.mean) ljspeech.upper.boundf2 <- median(vowels.ljspeech.grouped.means$F2.mean) + 3 * mad(vowels.ljspeech.grouped.means$F2.mean) ljspeech.outlier.indices <- append(ljspeech.outlier.indices, which(vowels.ljspeech.grouped.means$F2.mean < ljspeech.lower.boundf2 | vowels.ljspeech.grouped.means$F2.mean > ljspeech.upper.boundf2)) ljspeech.lower.boundf3 <- median(vowels.ljspeech.grouped.means$F3.mean) - 3 * mad(vowels.ljspeech.grouped.means$F3.mean) ljspeech.upper.boundf3 <- median(vowels.ljspeech.grouped.means$F3.mean) + 3 * mad(vowels.ljspeech.grouped.means$F3.mean) ljspeech.outlier.indices <- append(ljspeech.outlier.indices, which(vowels.ljspeech.grouped.means$F3.mean < ljspeech.lower.boundf3 | vowels.ljspeech.grouped.means$F3.mean > ljspeech.upper.boundf3)) # # we have to check if the outlier list is empty # # don't ask me why that rlang:: is needed, stackoverflow said so ^^ if(rlang::is_empty(ljspeech.outlier.indices) == TRUE) { vowels.ljspeech.grouped.means <- vowels.ljspeech.grouped.means } else { vowels.ljspeech.grouped.means <- vowels.ljspeech.grouped.means[-ljspeech.outlier.indices,] } # Nigeria nigeria.lower.boundf1 <- median(vowels.nigeria.grouped.means$F1.mean) - 3 * mad(vowels.nigeria.grouped.means$F1.mean) nigeria.upper.boundf1 <- median(vowels.nigeria.grouped.means$F1.mean) + 3 * mad(vowels.nigeria.grouped.means$F1.mean) nigeria.outlier.indices <- which(vowels.nigeria.grouped.means$F1.mean < nigeria.lower.boundf1 | vowels.nigeria.grouped.means$F1.mean > nigeria.upper.boundf1) nigeria.lower.boundf2 <- median(vowels.nigeria.grouped.means$F2.mean) - 3 * mad(vowels.nigeria.grouped.means$F2.mean) nigeria.upper.boundf2 <- median(vowels.nigeria.grouped.means$F2.mean) + 3 * mad(vowels.nigeria.grouped.means$F2.mean) nigeria.outlier.indices <- append(nigeria.outlier.indices, which(vowels.nigeria.grouped.means$F2.mean < nigeria.lower.boundf2 | vowels.nigeria.grouped.means$F2.mean > nigeria.upper.boundf2)) nigeria.lower.boundf3 <- median(vowels.nigeria.grouped.means$F3.mean) - 3 * mad(vowels.nigeria.grouped.means$F3.mean) nigeria.upper.boundf3 <- median(vowels.nigeria.grouped.means$F3.mean) + 3 * mad(vowels.nigeria.grouped.means$F3.mean) nigeria.outlier.indices <- append(nigeria.outlier.indices, which(vowels.nigeria.grouped.means$F3.mean < nigeria.lower.boundf3 | vowels.nigeria.grouped.means$F3.mean > nigeria.upper.boundf3)) # we have to check if the outlier list is empty # don't ask me why that rlang:: is needed, stackoverflow said so ^^ if(rlang::is_empty(nigeria.outlier.indices) == TRUE) { vowels.nigeria.grouped.means <- vowels.nigeria.grouped.means } else { vowels.nigeria.grouped.means <- vowels.nigeria.grouped.means[-nigeria.outlier.indices,] } # China china.lower.boundf1 <- median(vowels.china.grouped.means$F1.mean) - 3 * mad(vowels.china.grouped.means$F1.mean) china.upper.boundf1 <- median(vowels.china.grouped.means$F1.mean) + 3 * mad(vowels.china.grouped.means$F1.mean) china.outlier.indices <- which(vowels.china.grouped.means$F1.mean < china.lower.boundf1 | vowels.china.grouped.means$F1.mean > china.upper.boundf1) china.lower.boundf2 <- median(vowels.china.grouped.means$F2.mean) - 3 * mad(vowels.china.grouped.means$F2.mean) china.upper.boundf2 <- median(vowels.china.grouped.means$F2.mean) + 3 * mad(vowels.china.grouped.means$F2.mean) china.outlier.indices <- append(china.outlier.indices, which(vowels.china.grouped.means$F2.mean < china.lower.boundf2 | vowels.china.grouped.means$F2.mean > china.upper.boundf2)) china.lower.boundf3 <- median(vowels.china.grouped.means$F3.mean) - 3 * mad(vowels.china.grouped.means$F3.mean) china.upper.boundf3 <- median(vowels.china.grouped.means$F3.mean) + 3 * mad(vowels.china.grouped.means$F3.mean) china.outlier.indices <- append(china.outlier.indices, which(vowels.china.grouped.means$F3.mean < china.lower.boundf3 | vowels.china.grouped.means$F3.mean > china.upper.boundf3)) # we have to check if the outlier list is empty # don't ask me why that rlang:: is needed, stackoverflow said so ^^ if(rlang::is_empty(china.outlier.indices) == TRUE) { vowels.china.grouped.means <- vowels.china.grouped.means } else { vowels.china.grouped.means <- vowels.china.grouped.means[-china.outlier.indices,] } # THCHS thchs.lower.boundf1 <- median(vowels.thchs.grouped.means$F1.mean) - 3 * mad(vowels.thchs.grouped.means$F1.mean) thchs.upper.boundf1 <- median(vowels.thchs.grouped.means$F1.mean) + 3 * mad(vowels.thchs.grouped.means$F1.mean) thchs.outlier.indices <- which(vowels.thchs.grouped.means$F1.mean < thchs.lower.boundf1 | vowels.thchs.grouped.means$F1.mean > thchs.upper.boundf1) thchs.lower.boundf2 <- median(vowels.thchs.grouped.means$F2.mean) - 3 * mad(vowels.thchs.grouped.means$F2.mean) thchs.upper.boundf2 <- median(vowels.thchs.grouped.means$F2.mean) + 3 * mad(vowels.thchs.grouped.means$F2.mean) thchs.outlier.indices <- append(thchs.outlier.indices, which(vowels.thchs.grouped.means$F2.mean < thchs.lower.boundf2 | vowels.thchs.grouped.means$F2.mean > thchs.upper.boundf2)) thchs.lower.boundf3 <- median(vowels.thchs.grouped.means$F3.mean) - 3 * mad(vowels.thchs.grouped.means$F3.mean) thchs.upper.boundf3 <- median(vowels.thchs.grouped.means$F3.mean) + 3 * mad(vowels.thchs.grouped.means$F3.mean) thchs.outlier.indices <- append(thchs.outlier.indices, which(vowels.thchs.grouped.means$F3.mean < thchs.lower.boundf3 | vowels.thchs.grouped.means$F3.mean > thchs.upper.boundf3)) # # we have to check if the outlier list is empty # # don't ask me why that rlang:: is needed, stackoverflow said so ^^ if(rlang::is_empty(thchs.outlier.indices) == TRUE) { vowels.thchs.grouped.means <- vowels.thchs.grouped.means } else { vowels.thchs.grouped.means <- vowels.thchs.grouped.means[-thchs.outlier.indices,] } # lobanov normalization # group by file only makes sense if different files are different speakers I guess #vowels.ljspeech.lobanov = vowels.ljspeech.grouped.means %>% group_by(file) %>% mutate(f1scale = scale(F1.mean), f2scale = scale(F2.mean), f1lobanov = normLobanov(F1.mean), f2lobanov = normLobanov(F2.mean)) vowels.ljspeech.lobanov = vowels.ljspeech.grouped.means %>% mutate(f1scale = scale(F1.mean), f2scale = scale(F2.mean), f1lobanov = normLobanov(F1.mean), f2lobanov = normLobanov(F2.mean)) ljspeech.means.lobanov <- vowels.ljspeech.lobanov %>% group_by(phoneme) %>% summarise(mean_F1 = mean(f1lobanov), mean_F2 = mean(f2lobanov)) vowels.nigeria.lobanov = vowels.nigeria.grouped.means %>% group_by(speaker) %>% mutate(f1scale = scale(F1.mean), f2scale = scale(F2.mean), f1lobanov = normLobanov(F1.mean), f2lobanov = normLobanov(F2.mean)) #vowels.nigeria.lobanov = vowels.nigeria.grouped.means %>% mutate(f1scale = scale(F1.mean), f2scale = scale(F2.mean), f1lobanov = normLobanov(F1.mean), f2lobanov = normLobanov(F2.mean)) nigeria.means.lobanov <- vowels.nigeria.lobanov %>% group_by(phoneme) %>% summarise(mean_F1 = mean(f1lobanov), mean_F2 = mean(f2lobanov)) vowels.china.lobanov = vowels.china.grouped.means %>% mutate(f1scale = scale(F1.mean), f2scale = scale(F2.mean), f1lobanov = normLobanov(F1.mean), f2lobanov = normLobanov(F2.mean)) #vowels.china.lobanov = vowels.china.grouped.means %>% mutate(f1scale = scale(F1.mean), f2scale = scale(F2.mean), f1lobanov = normLobanov(F1.mean), f2lobanov = normLobanov(F2.mean)) china.means.lobanov <- vowels.china.lobanov %>% group_by(phoneme) %>% summarise(mean_F1 = mean(f1lobanov), mean_F2 = mean(f2lobanov)) vowels.thchs.lobanov = vowels.thchs.grouped.means %>% mutate(f1scale = scale(F1.mean), f2scale = scale(F2.mean), f1lobanov = normLobanov(F1.mean), f2lobanov = normLobanov(F2.mean)) thchs.means.lobanov <- vowels.thchs.lobanov %>% group_by(phoneme) %>% summarise(mean_F1 = mean(f1lobanov), mean_F2 = mean(f2lobanov)) # calculate min and max f1 and f2 to scale the axes. # Note: not sure if this is actually necessary with the current way of plotting. ljspeech.x.min <- min(vowels.ljspeech.lobanov$f2lobanov) ljspeech.x.max <- max(vowels.ljspeech.lobanov$f2lobanov) ljspeech.y.min <- min(vowels.ljspeech.lobanov$f1lobanov) ljspeech.y.max <- max(vowels.ljspeech.lobanov$f1lobanov) nigeria.x.min <- min(vowels.nigeria.lobanov$f2lobanov) nigeria.x.max <- max(vowels.nigeria.lobanov$f2lobanov) nigeria.y.min <- min(vowels.nigeria.lobanov$f1lobanov) nigeria.y.max <- max(vowels.nigeria.lobanov$f1lobanov) china.x.min <- min(vowels.china.lobanov$f2lobanov) china.x.max <- max(vowels.china.lobanov$f2lobanov) china.y.min <- min(vowels.china.lobanov$f1lobanov) china.y.max <- max(vowels.china.lobanov$f1lobanov) thchs.x.min <- min(vowels.thchs.lobanov$f2lobanov) thchs.x.max <- max(vowels.thchs.lobanov$f2lobanov) thchs.y.min <- min(vowels.thchs.lobanov$f1lobanov) thchs.y.max <- max(vowels.thchs.lobanov$f1loanov) abs.x.min <- min(c(nigeria.x.min, ljspeech.x.min, china.x.min, thchs.x.min)) abs.x.max <- max(c(nigeria.x.max, ljspeech.x.max, china.x.max, thchs.x.max)) abs.y.min <- min(c(nigeria.y.min, ljspeech.y.min, china.y.min, thchs.y.min)) abs.y.max <- max(c(nigeria.y.max, ljspeech.y.max, china.y.max, thchs.y.max)) # set default data set to NULL and specify data set for each geom # add geom for each data set # ggplot(NULL, aes(x = f2lobanov, y = f1lobanov, color = phoneme, label = phoneme)) + # # LJSpeech # #geom_point(data = vowels.ljspeech.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # stat_ellipse(data = vowels.ljspeech.lobanov, level = 0.67, size = 2, alpha = 0.2) + # geom_label(data = ljspeech.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10, alpha = 0.2) + # # Nigeria # #geom_point(data = vowels.nigeria.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # stat_ellipse(data = vowels.nigeria.lobanov, level = 0.67, size = 2) + # geom_label(data = nigeria.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10) + # xlim(abs.x.max, abs.x.min) + # ylim(abs.y.max, abs.y.min) + # scale_color_discrete(breaks = c("IY", "IH", "EY", "EH", "AE", # "AA", "AO", "OW", "UH", "UW", "AH")) + # guides(color = FALSE) + # theme_classic() + # theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + # #labs(title = "Pilot Test Subject Vowel Plot", subtitle = "Hampel filtered, Lobanov normalized, 67% confidence intervals", x = "F2", y = "F1") # labs(x = "F2", y = "F1") + # coord_fixed() # # xlim(abs_max_x, abs_min_x) + # # ylim(abs_max_y, abs_min_y) + # # geom_point(data = vowels_lobanov_china, aes(color = phoneme),alpha = 1, size = 2) + # # stat_ellipse(data = vowels_lobanov_china, level = 0.67, size = 2) + # # geom_label(data = means_lobanov_china, aes(x = mean_F2, y = mean_F1), size = 10) #+ # #scale_x_reverse() + scale_y_reverse() # try some side by side plotting plot.ljspeech <- ggplot(NULL, aes(x = f2lobanov, y = f1lobanov, color = phoneme, label = phoneme)) + # LJSpeech geom_point(data = vowels.ljspeech.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + stat_ellipse(data = vowels.ljspeech.lobanov, level = 0.67, size = 2, alpha = 1.0) + geom_label(data = ljspeech.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10, alpha = 1.0) + # Nigeria #geom_point(data = vowels.nigeria.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + #stat_ellipse(data = vowels.nigeria.lobanov, level = 0.67, size = 2) + #geom_label(data = nigeria.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10) + xlim(abs.x.max, abs.x.min) + ylim(abs.y.max, abs.y.min) + scale_color_discrete(breaks = c("IY", "IH", "EY", "EH", "AE", "AA", "AO", "OW", "UH", "UW", "AH")) + guides(color = FALSE) + theme_classic() + theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + labs(title = "LJSpeech", subtitle = "Hampel filtered, Lobanov normalized", x = "F2", y = "F1") + #labs(x = "F2", y = "F1") + coord_fixed() # plot.nigeria <- ggplot(NULL, aes(x = f2lobanov, y = f1lobanov, color = phoneme, label = phoneme)) + # # LJSpeech # #geom_point(data = vowels.ljspeech.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # #stat_ellipse(data = vowels.ljspeech.lobanov, level = 0.67, size = 2, alpha = 0.2) + # #geom_label(data = ljspeech.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10, alpha = 0.2) + # # Nigeria # geom_point(data = vowels.nigeria.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # stat_ellipse(data = vowels.nigeria.lobanov, level = 0.67, size = 2) + # geom_label(data = nigeria.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10) + # xlim(abs.x.max, abs.x.min) + # ylim(abs.y.max, abs.y.min) + # scale_color_discrete(breaks = c("IY", "IH", "EY", "EH", "AE", # "AA", "AO", "OW", "UH", "UW", "AH")) + # guides(color = FALSE) + # theme_classic() + # theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + # labs(title = "Nigeria", subtitle = "Hampel filtered, Lobanov normalized, 67% confidence intervals", x = "F2", y = "F1") + # #labs(x = "F2", y = "F1") + # coord_fixed() # grid.arrange(plot.ljspeech, plot.nigeria, ncol=2, respect=TRUE) # let's plot some raw frequencies to investigate the apparent cut-off in the normalized plot # nigeria.means.raw <- vowels.nigeria.lobanov %>% # group_by(phoneme) %>% # summarise(mean_F1 = mean(F1.mean), # mean_F2 = mean(F2.mean)) # ggplot(NULL, aes(x = F2.mean, y = F1.mean, color = phoneme, label = phoneme)) + # # LJSpeech # #geom_point(data = vowels.ljspeech.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # #stat_ellipse(data = vowels.ljspeech.lobanov, level = 0.67, size = 2, alpha = 0.2) + # #geom_label(data = ljspeech.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10, alpha = 0.2) + # # Nigeria # geom_point(data = vowels.nigeria.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # stat_ellipse(data = vowels.nigeria.lobanov, level = 0.67, size = 2) + # geom_label(data = nigeria.means.raw, aes(x = mean_F2, y = mean_F1), size = 10) + # # xlim(abs.x.max, abs.x.min) + # # ylim(abs.y.max, abs.y.min) + # scale_color_discrete(breaks = c("IY", "IH", "EY", "EH", "AE", # "AA", "AO", "OW", "UH", "UW", "AH")) + # guides(color = FALSE) + # theme_classic() + # theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + # #labs(title = "Pilot Test Subject Vowel Plot", subtitle = "Hampel filtered, Lobanov normalized, 67% confidence intervals", x = "F2", y = "F1") # labs(x = "F2", y = "F1") + # coord_fixed() + scale_x_reverse() + scale_y_reverse() # # ljspeech.means.raw <- vowels.ljspeech.lobanov %>% # group_by(phoneme) %>% # summarise(mean_F1 = mean(F1.mean), # mean_F2 = mean(F2.mean)) # ggplot(NULL, aes(x = F2.mean, y = F1.mean, color = phoneme, label = phoneme)) + # # LJSpeech # #geom_point(data = vowels.ljspeech.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # #stat_ellipse(data = vowels.ljspeech.lobanov, level = 0.67, size = 2, alpha = 0.2) + # #geom_label(data = ljspeech.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10, alpha = 0.2) + # # ljspeech # geom_point(data = vowels.ljspeech.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # stat_ellipse(data = vowels.ljspeech.lobanov, level = 0.67, size = 2) + # geom_label(data = ljspeech.means.raw, aes(x = mean_F2, y = mean_F1), size = 10) + # # xlim(abs.x.max, abs.x.min) + # # ylim(abs.y.max, abs.y.min) + # # scale_color_discrete(breaks = c("IY", "IH", "EY", "EH", "AE", # # "AA", "AO", "OW", "UH", "UW", "AH")) + # guides(color = FALSE) + # theme_classic() + # # theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + # #labs(title = "Pilot Test Subject Vowel Plot", subtitle = "Hampel filtered, Lobanov normalized, 67% confidence intervals", x = "F2", y = "F1") # # labs(x = "F2", y = "F1") + # scale_x_reverse() + scale_y_reverse() # ggplot(NULL, aes(x = f2lobanov, y = f1lobanov, color = phoneme, label = phoneme)) + # # LJSpeech # #geom_point(data = vowels.ljspeech.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # #stat_ellipse(data = vowels.ljspeech.lobanov, level = 0.67, size = 2, alpha = 0.2) + # #geom_label(data = ljspeech.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10, alpha = 0.2) + # # ljspeech # geom_point(data = vowels.ljspeech.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # stat_ellipse(data = vowels.ljspeech.lobanov, level = 0.67, size = 2) + # geom_label(data = ljspeech.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10) + # # xlim(abs.x.max, abs.x.min) + # # ylim(abs.y.max, abs.y.min) + # # scale_color_discrete(breaks = c("IY", "IH", "EY", "EH", "AE", # # "AA", "AO", "OW", "UH", "UW", "AH")) + # guides(color = FALSE) + # theme_classic() + # # theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + # #labs(title = "Pilot Test Subject Vowel Plot", subtitle = "Hampel filtered, Lobanov normalized, 67% confidence intervals", x = "F2", y = "F1") # # labs(x = "F2", y = "F1") + # scale_x_reverse() + scale_y_reverse() # # nigeria.means.raw <- vowels.nigeria.lobanov %>% # group_by(phoneme) %>% # summarise(mean_F1 = mean(F1.mean), # mean_F2 = mean(F2.mean)) # ggplot(NULL, aes(x = F2.mean, y = F1.mean, color = phoneme, label = phoneme)) + # # nigeria # #geom_point(data = vowels.nigeria.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # #stat_ellipse(data = vowels.nigeria.lobanov, level = 0.67, size = 2, alpha = 0.2) + # #geom_label(data = nigeria.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10, alpha = 0.2) + # # nigeria # geom_point(data = vowels.nigeria.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # stat_ellipse(data = vowels.nigeria.lobanov, level = 0.67, size = 2) + # geom_label(data = nigeria.means.raw, aes(x = mean_F2, y = mean_F1), size = 10) + # # xlim(abs.x.max, abs.x.min) + # # ylim(abs.y.max, abs.y.min) + # # scale_color_discrete(breaks = c("IY", "IH", "EY", "EH", "AE", # # "AA", "AO", "OW", "UH", "UW", "AH")) + # guides(color = FALSE) + # theme_classic() + # # theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + # #labs(title = "Pilot Test Subject Vowel Plot", subtitle = "Hampel filtered, Lobanov normalized, 67% confidence intervals", x = "F2", y = "F1") # # labs(x = "F2", y = "F1") + # scale_x_reverse() + scale_y_reverse() # ggplot(NULL, aes(x = f2lobanov, y = f1lobanov, color = phoneme, label = phoneme)) + # # nigeria # #geom_point(data = vowels.nigeria.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # #stat_ellipse(data = vowels.nigeria.lobanov, level = 0.67, size = 2, alpha = 0.2) + # #geom_label(data = nigeria.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10, alpha = 0.2) + # # nigeria # geom_point(data = vowels.nigeria.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # stat_ellipse(data = vowels.nigeria.lobanov, level = 0.67, size = 2) + # geom_label(data = nigeria.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10) + # # xlim(abs.x.max, abs.x.min) + # # ylim(abs.y.max, abs.y.min) + # # scale_color_discrete(breaks = c("IY", "IH", "EY", "EH", "AE", # # "AA", "AO", "OW", "UH", "UW", "AH")) + # guides(color = FALSE) + # theme_classic() + # # theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + # #labs(title = "Pilot Test Subject Vowel Plot", subtitle = "Hampel filtered, Lobanov normalized, 67% confidence intervals", x = "F2", y = "F1") # # labs(x = "F2", y = "F1") + # scale_x_reverse() + scale_y_reverse() # # # raw side-by-side # plot.ljspeech.raw <- ggplot(NULL, aes(x = F2.mean, y = F1.mean, color = phoneme, label = phoneme)) + # # LJSpeech # geom_point(data = vowels.ljspeech.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # stat_ellipse(data = vowels.ljspeech.lobanov, level = 0.67, size = 2, alpha = 1.0) + # geom_label(data = ljspeech.means.raw, aes(x = mean_F2, y = mean_F1), size = 10, alpha = 1.0) + # # Nigeria # #geom_point(data = vowels.nigeria.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # #stat_ellipse(data = vowels.nigeria.lobanov, level = 0.67, size = 2) + # #geom_label(data = nigeria.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10) + # # xlim(abs.x.max, abs.x.min) + # # ylim(abs.y.max, abs.y.min) + # scale_color_discrete(breaks = c("IY", "IH", "EY", "EH", "AE", # "AA", "AO", "OW", "UH", "UW", "AH")) + # guides(color = FALSE) + # theme_classic() + # theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + # #labs(title = "Pilot Test Subject Vowel Plot", subtitle = "Hampel filtered, Lobanov normalized, 67% confidence intervals", x = "F2", y = "F1") # labs(x = "F2", y = "F1") + # scale_x_reverse() + scale_y_reverse() # # plot.nigeria.raw <- ggplot(NULL, aes(x = F2.mean, y = F1.mean, color = phoneme, label = phoneme)) + # # LJSpeech # #geom_point(data = vowels.ljspeech.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # #stat_ellipse(data = vowels.ljspeech.lobanov, level = 0.67, size = 2, alpha = 0.2) + # #geom_label(data = ljspeech.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10, alpha = 0.2) + # # Nigeria # geom_point(data = vowels.nigeria.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # stat_ellipse(data = vowels.nigeria.lobanov, level = 0.67, size = 2) + # geom_label(data = nigeria.means.raw, aes(x = mean_F2, y = mean_F1), size = 10) + # # xlim(abs.x.max, abs.x.min) + # # ylim(abs.y.max, abs.y.min) + # scale_color_discrete(breaks = c("IY", "IH", "EY", "EH", "AE", # "AA", "AO", "OW", "UH", "UW", "AH")) + # guides(color = FALSE) + # theme_classic() + # theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + # #labs(title = "Pilot Test Subject Vowel Plot", subtitle = "Hampel filtered, Lobanov normalized, 67% confidence intervals", x = "F2", y = "F1") # labs(x = "F2", y = "F1") + # scale_x_reverse() + scale_y_reverse() # # grid.arrange(plot.ljspeech.raw, plot.nigeria.raw, ncol=2, respect=TRUE) #plot daniel vs ibukun vowels.daniel <- vowels.nigeria.lobanov %>% filter(speaker == 'daniel') vowels.ibukun <- vowels.nigeria.lobanov %>% filter(speaker == 'ibukun') # ggplot(NULL, aes(x = f2lobanov, y = f1lobanov, color = phoneme, label = phoneme)) + # # LJSpeech # #geom_point(data = vowels.ljspeech.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # stat_ellipse(data = vowels.ljspeech.lobanov, level = 0.67, size = 2, alpha = 0.2) + # geom_label(data = ljspeech.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10, alpha = 0.2) + # # Nigeria # #geom_point(data = vowels.nigeria.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + # stat_ellipse(data = vowels.nigeria.lobanov, level = 0.67, size = 2) + # geom_label(data = nigeria.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10) + # xlim(abs.x.max, abs.x.min) + # ylim(abs.y.max, abs.y.min) + # scale_color_discrete(breaks = c("IY", "IH", "EY", "EH", "AE", # "AA", "AO", "OW", "UH", "UW", "AH")) + # guides(color = FALSE) + # theme_classic() + # theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + # #labs(title = "Pilot Test Subject Vowel Plot", subtitle = "Hampel filtered, Lobanov normalized, 67% confidence intervals", x = "F2", y = "F1") # labs(x = "F2", y = "F1") + # coord_fixed() # # xlim(abs_max_x, abs_min_x) + # # ylim(abs_max_y, abs_min_y) + # # geom_point(data = vowels_lobanov_china, aes(color = phoneme),alpha = 1, size = 2) + # # stat_ellipse(data = vowels_lobanov_china, level = 0.67, size = 2) + # # geom_label(data = means_lobanov_china, aes(x = mean_F2, y = mean_F1), size = 10) #+ # #scale_x_reverse() + scale_y_reverse() # try some side by side plotting nigeria.means.lobanov.daniel <- vowels.daniel %>% group_by(phoneme) %>% summarise(mean_F1 = mean(f1lobanov), mean_F2 = mean(f2lobanov)) nigeria.means.lobanov.ibukun <- vowels.ibukun %>% group_by(phoneme) %>% summarise(mean_F1 = mean(f1lobanov), mean_F2 = mean(f2lobanov)) plot.nigeria.daniel <- ggplot(NULL, aes(x = f2lobanov, y = f1lobanov, color = phoneme, label = phoneme)) + # LJSpeech #geom_point(data = vowels.ljspeech.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + #stat_ellipse(data = vowels.ljspeech.lobanov, level = 0.67, size = 2, alpha = 0.2) + #geom_label(data = ljspeech.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10, alpha = 0.2) + # Nigeria geom_point(data = vowels.daniel, aes(color = phoneme),alpha = 0.1, size = 1) + stat_ellipse(data = vowels.daniel, level = 0.67, size = 2) + geom_label(data = nigeria.means.lobanov.daniel, aes(x = mean_F2, y = mean_F1), size = 10) + xlim(abs.x.max, abs.x.min) + ylim(abs.y.max, abs.y.min) + scale_color_discrete(breaks = c("IY", "IH", "EY", "EH", "AE", "AA", "AO", "OW", "UH", "UW", "AH")) + guides(color = FALSE) + theme_classic() + theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + labs(title = "Daniel", subtitle = "Hampel filtered, Lobanov normalized", x = "F2", y = "F1") + #labs(x = "F2", y = "F1") + coord_fixed() plot.nigeria.ibukun <- ggplot(NULL, aes(x = f2lobanov, y = f1lobanov, color = phoneme, label = phoneme)) + # LJSpeech #geom_point(data = vowels.ljspeech.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + #stat_ellipse(data = vowels.ljspeech.lobanov, level = 0.67, size = 2, alpha = 0.2) + #geom_label(data = ljspeech.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10, alpha = 0.2) + # Nigeria geom_point(data = vowels.ibukun, aes(color = phoneme),alpha = 0.1, size = 1) + stat_ellipse(data = vowels.ibukun, level = 0.67, size = 2) + geom_label(data = nigeria.means.lobanov.ibukun, aes(x = mean_F2, y = mean_F1), size = 10) + xlim(abs.x.max, abs.x.min) + ylim(abs.y.max, abs.y.min) + scale_color_discrete(breaks = c("IY", "IH", "EY", "EH", "AE", "AA", "AO", "OW", "UH", "UW", "AH")) + guides(color = FALSE) + theme_classic() + theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + labs(title = "Ibukun", subtitle = "Hampel filtered, Lobanov normalized", x = "F2", y = "F1") + #labs(x = "F2", y = "F1") + coord_fixed() # test plot with fewer data because it looks strange #vowels.china.lobanov <- vowels.china.lobanov %>% filter(grepl('guoya-004', file)) plot.china <- ggplot(NULL, aes(x = f2lobanov, y = f1lobanov, color = phoneme, label = phoneme)) + # LJSpeech #geom_point(data = vowels.ljspeech.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + #stat_ellipse(data = vowels.ljspeech.lobanov, level = 0.67, size = 2, alpha = 0.2) + #geom_label(data = ljspeech.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10, alpha = 0.2) + # china geom_point(data = vowels.china.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + stat_ellipse(data = vowels.china.lobanov, level = 0.67, size = 2) + geom_label(data = china.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10) + xlim(abs.x.max, abs.x.min) + ylim(abs.y.max, abs.y.min) + scale_color_discrete(breaks = c("IY", "IH", "EY", "EH", "AE", "AA", "AO", "OW", "UH", "UW", "AH")) + guides(color = FALSE) + theme_classic() + theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + labs(title = "Guo Ya", subtitle = "Hampel filtered, Lobanov normalized", x = "F2", y = "F1") + #labs(x = "F2", y = "F1") + coord_fixed() # grid.arrange(plot.nigeria.daniel, plot.nigeria.ibukun, ncol=2, respect=TRUE) plot.thchs <- ggplot(NULL, aes(x = f2lobanov, y = f1lobanov, color = phoneme, label = phoneme)) + # thchs geom_point(data = vowels.thchs.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + stat_ellipse(data = vowels.thchs.lobanov, level = 0.67, size = 2, alpha = 1.0) + geom_label(data = thchs.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10, alpha = 1.0) + # Nigeria #geom_point(data = vowels.nigeria.lobanov, aes(color = phoneme),alpha = 0.1, size = 1) + #stat_ellipse(data = vowels.nigeria.lobanov, level = 0.67, size = 2) + #geom_label(data = nigeria.means.lobanov, aes(x = mean_F2, y = mean_F1), size = 10) + xlim(abs.x.max, abs.x.min) + ylim(abs.y.max, abs.y.min) + #scale_color_discrete(breaks = c("IY", "IH", "EY", "EH", "AE", # "AA", "AO", "OW", "UH", "UW", "AH")) + guides(color = FALSE) + theme_classic() + theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + labs(title = "THCHS-D6", subtitle = "Hampel filtered, Lobanov normalized", x = "F2", y = "F1")+ #labs(x = "F2", y = "F1") + coord_fixed() grid.arrange(plot.thchs, plot.china, plot.nigeria.daniel, plot.nigeria.ibukun, plot.ljspeech, ncol=2, respect=TRUE) # F1-F2 Trajectory # LJSpeech vowels.ljspeech2 <- data.ljspeech %>% filter(substr(phoneme, 1, 2)%in% diphthongs) vowels.ljspeech.grouped2 <- vowels.ljspeech2 levels(vowels.ljspeech.grouped2$phoneme) <- substr(levels(vowels.ljspeech.grouped2$phoneme), 1, 2) vowels.ljspeech.tall <- vowels.ljspeech.grouped2 %>% # Relevel the vowels mutate(phoneme = factor(phoneme, levels = c("IY", "EH", "AO", "UW", "AW", "IH", "AE", "OW", "AH", "OY", "EY", "AA", "UH", "AY"))) %>% # Summarize by vowel group_by(phoneme) %>% summarize_at(vars(F1_20,F1_50,F1_80,F2_20,F2_50,F2_80), median, na.rm = TRUE) %>% # Turn it into tall data gather("formant_percent", "hz", starts_with("F")) %>% separate(formant_percent, into = c("formant", "percent"), extra = "drop") %>% spread(formant, hz) ljspeech.onset.labels <- vowels.ljspeech.tall %>% filter(percent == 20) plot.ljspeech.diphthongs <- ggplot(vowels.ljspeech.tall, aes(F2, F1, color = phoneme, group = phoneme)) + geom_path(arrow = arrow(ends = "last", type = "closed", length = unit(0.1, "inches"))) + geom_label(data = ljspeech.onset.labels, aes(label = phoneme)) + labs(title = "LJSpeech", subtitle = "Raw Frequencies")+ scale_x_reverse() + scale_y_reverse() + theme_classic() + theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + guides(color = FALSE) # china vowels.china2 <- data.china %>% filter(substr(phoneme, 1, 2)%in% diphthongs) vowels.china.grouped2 <- vowels.china2 levels(vowels.china.grouped2$phoneme) <- substr(levels(vowels.china.grouped2$phoneme), 1, 2) vowels.china.tall <- vowels.china.grouped2 %>% # Relevel the vowels mutate(phoneme = factor(phoneme, levels = c("IY", "EH", "AO", "UW", "AW", "IH", "AE", "OW", "AH", "OY", "EY", "AA", "UH", "AY"))) %>% # Summarize by vowel group_by(phoneme) %>% summarize_at(vars(F1_20,F1_50,F1_80,F2_20,F2_50,F2_80), median, na.rm = TRUE) %>% # Turn it into tall data gather("formant_percent", "hz", starts_with("F")) %>% separate(formant_percent, into = c("formant", "percent"), extra = "drop") %>% spread(formant, hz) china.onset.labels <- vowels.china.tall %>% filter(percent == 20) plot.china.diphthongs <- ggplot(vowels.china.tall, aes(F2, F1, color = phoneme, group = phoneme)) + geom_path(arrow = arrow(ends = "last", type = "closed", length = unit(0.1, "inches"))) + geom_label(data = china.onset.labels, aes(label = phoneme)) + labs(title = "Guo Ya", subtitle = "Raw Frequencies")+ scale_x_reverse() + scale_y_reverse() + theme_classic() + theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + guides(color = FALSE) # thchs vowels.thchs2 <- data.thchs %>% filter(substr(phoneme, 1, 2)%in% diphthongs.pinyin) vowels.thchs.grouped2 <- vowels.thchs2 levels(vowels.thchs.grouped2$phoneme) <- substr(levels(vowels.thchs.grouped2$phoneme), 1, 2) vowels.thchs.tall <- vowels.thchs.grouped2 %>% # Relevel the vowels #mutate(phoneme = factor(phoneme, levels = c("IY", "EH", "AO", "UW", # "AW", "IH", "AE", "OW", # "AH", "OY", "EY", "AA", "UH", "AY"))) %>% # Summarize by vowel group_by(phoneme) %>% summarize_at(vars(F1_20,F1_50,F1_80,F2_20,F2_50,F2_80), median, na.rm = TRUE) %>% # Turn it into tall data gather("formant_percent", "hz", starts_with("F")) %>% separate(formant_percent, into = c("formant", "percent"), extra = "drop") %>% spread(formant, hz) thchs.onset.labels <- vowels.thchs.tall %>% filter(percent == 20) plot.thchs.diphthongs <- ggplot(vowels.thchs.tall, aes(F2, F1, color = phoneme, group = phoneme)) + geom_path(arrow = arrow(ends = "last", type = "closed", length = unit(0.1, "inches"))) + geom_label(data = thchs.onset.labels, aes(label = phoneme)) + labs(title = "THCHS-D6", subtitle = "Raw Frequencies")+ scale_x_reverse() + scale_y_reverse() + theme_classic() + theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + guides(color = FALSE) # nigeria.daniel data.nigeria.daniel <- data.nigeria %>% filter(speaker == 'daniel') vowels.nigeria.daniel2 <- data.nigeria.daniel %>% filter(substr(phoneme, 1, 2)%in% diphthongs) vowels.nigeria.daniel.grouped2 <- vowels.nigeria.daniel2 levels(vowels.nigeria.daniel.grouped2$phoneme) <- substr(levels(vowels.nigeria.daniel.grouped2$phoneme), 1, 2) vowels.nigeria.daniel.tall <- vowels.nigeria.daniel.grouped2 %>% # Relevel the vowels mutate(phoneme = factor(phoneme, levels = c("IY", "EH", "AO", "UW", "AW", "IH", "AE", "OW", "AH", "OY", "EY", "AA", "UH", "AY"))) %>% # Summarize by vowel group_by(phoneme) %>% summarize_at(vars(F1_20,F1_50,F1_80,F2_20,F2_50,F2_80), median, na.rm = TRUE) %>% # Turn it into tall data gather("formant_percent", "hz", starts_with("F")) %>% separate(formant_percent, into = c("formant", "percent"), extra = "drop") %>% spread(formant, hz) nigeria.daniel.onset.labels <- vowels.nigeria.daniel.tall %>% filter(percent == 20) plot.nigeria.daniel.diphthongs <- ggplot(vowels.nigeria.daniel.tall, aes(F2, F1, color = phoneme, group = phoneme)) + geom_path(arrow = arrow(ends = "last", type = "closed", length = unit(0.1, "inches"))) + geom_label(data = nigeria.daniel.onset.labels, aes(label = phoneme)) + labs(title = "Daniel", subtitle = "Raw Frequencies")+ scale_x_reverse() + scale_y_reverse() + theme_classic() + theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + guides(color = FALSE) # nigeria.ibukun data.nigeria.ibukun <- data.nigeria %>% filter(speaker == 'ibukun') vowels.nigeria.ibukun2 <- data.nigeria.ibukun %>% filter(substr(phoneme, 1, 2)%in% diphthongs) vowels.nigeria.ibukun.grouped2 <- vowels.nigeria.ibukun2 levels(vowels.nigeria.ibukun.grouped2$phoneme) <- substr(levels(vowels.nigeria.ibukun.grouped2$phoneme), 1, 2) vowels.nigeria.ibukun.tall <- vowels.nigeria.ibukun.grouped2 %>% # Relevel the vowels mutate(phoneme = factor(phoneme, levels = c("IY", "EH", "AO", "UW", "AW", "IH", "AE", "OW", "AH", "OY", "EY", "AA", "UH", "AY"))) %>% # Summarize by vowel group_by(phoneme) %>% summarize_at(vars(F1_20,F1_50,F1_80,F2_20,F2_50,F2_80), median, na.rm = TRUE) %>% # Turn it into tall data gather("formant_percent", "hz", starts_with("F")) %>% separate(formant_percent, into = c("formant", "percent"), extra = "drop") %>% spread(formant, hz) nigeria.ibukun.onset.labels <- vowels.nigeria.ibukun.tall %>% filter(percent == 20) plot.nigeria.ibukun.diphthongs <- ggplot(vowels.nigeria.ibukun.tall, aes(F2, F1, color = phoneme, group = phoneme)) + geom_path(arrow = arrow(ends = "last", type = "closed", length = unit(0.1, "inches"))) + geom_label(data = nigeria.ibukun.onset.labels, aes(label = phoneme)) + labs(title = "Ibukun", subtitle = "Raw Frequencies")+ scale_x_reverse() + scale_y_reverse() + theme_classic() + theme(axis.line = element_line(colour = 'black', size = 2), text = element_text(size = 20), plot.title = element_text(face = "bold", hjust = 0.5), legend.position="none", plot.subtitle = element_text(hjust = 0.5)) + guides(color = FALSE) grid.arrange(plot.thchs.diphthongs, plot.china.diphthongs, plot.nigeria.daniel.diphthongs, plot.nigeria.ibukun.diphthongs, plot.ljspeech.diphthongs, ncol=2, respect=TRUE)