9 Do it yourself

In the previous chapter, we did the analysis of effect that different tasks have on the speech intensity level. Here, we will use the same dataset to investigate how these tasks affect the fundamental frequency of the speakers. Recall that the pitch data is now stored in the pitchData dataset.

##       speaker time pitch task condition gender goal comm
## 87426    s2_1 30.6   332    D     noise Female   no  yes
## 87427    s2_1 30.6   335    D     noise Female   no  yes
## 87428    s2_1 30.6   338    D     noise Female   no  yes
## 87429    s2_1 30.6   337    D     noise Female   no  yes
## 87430    s2_1 30.6   332    D     noise Female   no  yes
## 87431    s2_1 30.6   320    D     noise Female   no  yes

9.1 Things to consider:

  • Male and female speakers have different pitch range. Does this show up in the data? (hint: use hist())

  • There are many ways to normalize pitch variation. Here, we will convert the pitch in Hz to semitones from the median frequency of each speaker. So, first we need to find those medians and include them in our dataframe:

##   speaker mF0
## 1    s2_1 244
## 2    s2_2 265
## 3    s3_2 222
## 4    s7_1 116
## 5    s7_2 138
## 6    s8_1 124
## 7    s8_2 138
## 8    s9_1 234
## 9    s9_2 120
  • ddply() is a function of the library plyr useful for manipulate dataframes. In this example, it computes the median of pitch per speaker.

  • na.rm = F removes NA values from the computation. In case that our dataframe had some, the results of mean, median, etc. would be also NA.

##   speaker time pitch task condition gender goal comm mF0
## 1    s2_1 30.6   332    D     noise Female   no  yes 244
## 2    s2_1 30.6   335    D     noise Female   no  yes 244
## 3    s2_1 30.6   338    D     noise Female   no  yes 244
## 4    s2_1 30.6   337    D     noise Female   no  yes 244
## 5    s2_1 30.6   332    D     noise Female   no  yes 244
## 6    s2_1 30.6   320    D     noise Female   no  yes 244
  • merge() merges the two dataframes by its common columns (i.e., speaker).

Now we have a new factor in the dataframe that contains the median F0 value per speaker. A semitone \(s\) is given by the formula \[ s = 12 \log_2\left(\frac{f0}{f0_{ref}}\right)\] We can use the newly created factor to express pitch as semitones:

Now the pitch data expressed in semitones from the median of each speaker is stored in the factor relPitch. We can now use this factor to perform an RM-ANOVA on pitch. Go a head and give it a try!