# projectPart3prep.R # Begin by setting the working directory to the folder where you have # put the Table files from Group Awesome, which have the duration measure # that they added to everyone's Table file. setwd('c:/Lx286/projectParts/termProjectPart3/TableFilesFromGroupAwesome') # Set up a list of files in the directory by using grep() to identify the # file names returned by the dir() command which include the regular # expression ".Table" which all of the Table files include in their names. filenames=grep(".Table",dir(),value=T) # Read the first of the files (which is Alexa.Table) into the variable # classVows, and then ... classVows=read.table(filenames[1],as.is=T,header=T) # Loop through the rest of the files, reading in each one in turn and # appending it as the next 10 rows of the classVows data frame using # the rbind() (for "bind by rows") command. for (i in 2:length(filenames)) { classVows=rbind(classVows, read.table(filenames[i],as.is=T,header=T)[, c("speaker","word","vowel","F1","F2","duration")]) # We're explicitly specifying only these six columns, because # Leo's file has an F3 column and won't match the data frame # structure if we don't exclude that column by not naming it # in this list of named columns to take. } # Now set the working directory to the folder where you have put the # file with the corrected values for the F1 and F2 in and # that Group A provided. setwd('c:/Lx286/projectParts/termProjectPart3') # Write out a list of talker names for the Praat script. write.table(unique(classVows$speaker), file="talkers.txt", row.names=F, col.names=F, quote=F) # Read that file into the variable x and loop through its rows identifying # the appropriate cells of classVows to change. x=read.table("correctedproductiondatatable.txt", header=T, as.is=T) for (i in 1:dim(x)[1]) { classVows$F1[(tolower(classVows$speaker)==x$speaker[i] & classVows$word=="hawed")]=x$hawed.f1[i] classVows$F2[(tolower(classVows$speaker)==x$speaker[i] & classVows$word=="hawed")]=x$hawed.f2[i] classVows$F1[(tolower(classVows$speaker)==x$speaker[i] & classVows$word=="hod")]=x$hod.f1[i] classVows$F2[(tolower(classVows$speaker)==x$speaker[i] & classVows$word=="hod")]=x$hod.f2[i] } # Check out the other formant values by looking first at the summary # stats for the first and second formants. summary(classVows[,c("F1","F2")]) # F1 F2 # Min. : 76.83 Min. : 353 # 1st Qu.: 449.83 1st Qu.:1318 # Median : 578.89 Median :1667 # Mean : 602.65 Mean :1750 # 3rd Qu.: 743.00 3rd Qu.:2108 # Max. :2095.41 Max. :3261 # # That min of 77 Hz for F1 is too low. The formant tracker must have # been picking up the fundamental frequency instead of the first formant # frequency. And that min of 353 for F2 must be the first formant then. subset(classVows, F1 < 250) # speaker word vowel F1 F2 duration # 108 Elyse whod u 76.83 1629.08 0.273 # 1016 Robert whod u 234.00 1554.00 0.216 subset(classVows, F2 < 800) # speaker word vowel F1 F2 duration # 117 Stephanie heed i 743 353 0.307 # Check out the other formant values by plotting each class member's vowel # space and seeing whether they make sense. windows(width=6, height=6, pointsize=12) par(family="serif", oma=rep(0,4), mar=c(3,3,0.1,0.1), mgp=c(1.5,0.8,0), type="s", ask=T) talkers=unique(classVows$speaker) for (i in 1:length(talkers)) { x=subset(classVows, speaker==talkers[i]) plot(F1 ~ F2, data=x, xlim=c(3300,350), ylim=c(2100,75),pch=x$vowel) mtext(talkers[i],side=1,line=-1) } # Fix these values and rerun. classVows$F1[classVows$speaker=="Brandon" & classVows$vowel=="i"]=269 classVows$F2[classVows$speaker=="Brandon" & classVows$vowel=="i"]=2025 classVows$F1[classVows$speaker=="Brandon" & classVows$vowel=="u"]=291 classVows$F2[classVows$speaker=="Brandon" & classVows$vowel=="u"]=1238 classVows$F2[classVows$speaker=="Caroline" & classVows$vowel=="e"]=2866 classVows$F1[classVows$speaker=="Carrie" & classVows$vowel=="i"]=409 classVows$F2[classVows$speaker=="Carrie" & classVows$vowel=="i"]=2901 classVows$F1[classVows$speaker=="Carrie" & classVows$vowel=="e"]=520 classVows$F2[classVows$speaker=="Carrie" & classVows$vowel=="e"]=2747 classVows$F1[classVows$speaker=="Carrie" & classVows$vowel=="I"]=578 classVows$F2[classVows$speaker=="Carrie" & classVows$vowel=="I"]=2354 classVows$F1[classVows$speaker=="Carrie" & classVows$vowel=="E"]=779 classVows$F2[classVows$speaker=="Carrie" & classVows$vowel=="E"]=2173 classVows$F1[classVows$speaker=="Carrie" & classVows$vowel=="a"]=908 classVows$F2[classVows$speaker=="Carrie" & classVows$vowel=="a"]=1942 classVows$F1[classVows$speaker=="Carrie" & classVows$vowel=="u"]=390 classVows$F2[classVows$speaker=="Carrie" & classVows$vowel=="u"]=1728 classVows$F1[classVows$speaker=="Carrie" & classVows$vowel=="o"]=528 classVows$F2[classVows$speaker=="Carrie" & classVows$vowel=="o"]=1414 classVows$F1[classVows$speaker=="Carrie" & classVows$vowel=="v"]=826 classVows$F2[classVows$speaker=="Carrie" & classVows$vowel=="v"]=1538 classVows$F1[classVows$speaker=="cj" & classVows$vowel=="O"]=905 classVows$F2[classVows$speaker=="cj" & classVows$vowel=="O"]=1470 classVows$F1[classVows$speaker=="Elyse" & classVows$vowel=="u"]=406 classVows$F2[classVows$speaker=="Joe" & classVows$vowel=="u"]=1582 classVows$F1[classVows$speaker=="Leo" & classVows$vowel=="o"]=360 classVows$F2[classVows$speaker=="Leo" & classVows$vowel=="o"]=832 classVows$F1[classVows$speaker=="Leo" & classVows$vowel=="u"]=363 classVows$F2[classVows$speaker=="Leo" & classVows$vowel=="u"]=843 classVows$F1[classVows$speaker=="Mike" & classVows$vowel=="O"]=740 classVows$F2[classVows$speaker=="Mike" & classVows$vowel=="O"]=1096 classVows$F1[classVows$speaker=="Stephanie" & classVows$vowel=="i"]=400 classVows$F2[classVows$speaker=="Stephanie" & classVows$vowel=="i"]=3069 classVows$F1[classVows$speaker=="Stephanie" & classVows$vowel=="u"]=406 classVows$F2[classVows$speaker=="Stephanie" & classVows$vowel=="u"]=1410 classVows$F1[classVows$speaker=="Stephanie" & classVows$vowel=="o"]=544 classVows$F2[classVows$speaker=="Stephanie" & classVows$vowel=="o"]=1184 summary(classVows$F1) # Min. 1st Qu. Median Mean 3rd Qu. Max. # 234.0 426.0 564.9 583.4 716.8 1142.0 summary(classVows$F2) # Min. 1st Qu. Median Mean 3rd Qu. Max. # 832 1284 1619 1703 2042 3069 for (i in 1:length(talkers)) { x=subset(classVows, speaker==talkers[i]) plot(F1 ~ F2, data=x, xlim=c(3070,830), ylim=c(1150,230),pch=x$vowel) mtext(talkers[i],side=1,line=-1) } write.table(classVows, file="classVowels.txt", row.names=F)