Here you'll find a small collection of random scripts, tutorials, and other oddities that I've written to supposedly make life easier for myself and hopefully for you.
Note: This section has not been updated since 2017, and likely won't be updated any time soon.
Disclaimer: I've only tested the contents found on this page on my own computer (currently Win 11) and on my previous computers (with Win 10 & 7) at the time that I wrote them. You might have to make adjustments for different operating systems or software versions. You might want to check the publication dates I have posted and figure out which software version was out at that time if things aren't working. If something is not working, let me know and I'll do my best to fix it (no guarantees). If your computer implodes using something on this site, all responsibility and liability is disclaimed, though I'd really like to see a picture of my handy work.
Contents
- Interactive 3D density plots for vowel visualisation using PLOTLY and the MASS libraries
- Importing Sound Data from Praat to R: Plotting Waves, Intensity & TextGrids
- Move all boundaries to the nearest zero crossing
- Very basic tips for manipulating data frames in R for non-programmers
- Importing multiple files into R to create a single large data frame
- Vowel charts in Excel
- Fricatives, Fricatives, Fricatives
- Save all the sound files in your object's window
- Nasality!
- ELAN 1 & 2 from CoLang 2014
- Automatically adding text to blank ELAN annotations
- Media Lengua Database
- Vowel charts in R
- VOT, vowel duration, F0 F1, F2, F3, word, 1st 7 formant points (F1 F2 & F3) Updates (Feb, 2017)!
- Synthetic 10 step continuum between minimal pairs
- Praat basics for analyzing prosody
- Troubleshooting video playback in ELAN for Windows and hardcoding subtitles
Interactive 3D density plots for vowel visualisation with the PLOTLY and MASS libraries
Jesse Stewart
March 25, 2017
I'm not going to waste your time with a tutorial on this one. There's only 7 lines of code and the MASS and PLOTLY libraries really do all the work. I figure since I've already posted two vowel plotting tutorials, a third isn't necessary.
Practice data
Vowels.txt
R code
#Loads the data set. Be sure the change the working directory
Vdata=read.table("%DIRECTORY%/Vowels.txt", header=T)
#Changes the name of the first column
colnames(Vdata)[1]="Vowels"
#Creates a density matrix from the vowel data. It needs to be converted to a data frame to remove the first two unwanted columns. Then the data needs to be converted to a 'matrix'. plot_ly
plots the data.
iDensity=kde2d(Vdata$F1, Vdata$F2, lims=c(range(Vdata$F1),range(Vdata$F2)))
iDensity2=as.data.frame(iDensity)
iDensity3=iDensity2[,-1:-2]
iDensity4=data.matrix(iDensity3, rownames.force=NA)
plot_ly(z = ~iDensity4) %>% add_surface()
PLOTLY: https://plot.ly/r/3d-surface-plots/
The plot may take a moment to load.
Jesse Stewart
March 25, 2017
I'm not going to waste your time with a tutorial on this one. There's only 7 lines of code and the MASS and PLOTLY libraries really do all the work. I figure since I've already posted two vowel plotting tutorials, a third isn't necessary.
Practice data
Vowels.txt
R code
#Loads the data set. Be sure the change the working directory
Vdata=read.table("%DIRECTORY%/Vowels.txt", header=T)
#Changes the name of the first column
colnames(Vdata)[1]="Vowels"
#Creates a density matrix from the vowel data. It needs to be converted to a data frame to remove the first two unwanted columns. Then the data needs to be converted to a 'matrix'. plot_ly
plots the data.
iDensity=kde2d(Vdata$F1, Vdata$F2, lims=c(range(Vdata$F1),range(Vdata$F2)))
iDensity2=as.data.frame(iDensity)
iDensity3=iDensity2[,-1:-2]
iDensity4=data.matrix(iDensity3, rownames.force=NA)
plot_ly(z = ~iDensity4) %>% add_surface()
PLOTLY: https://plot.ly/r/3d-surface-plots/
The plot may take a moment to load.
Importing Sound Data from Praat to R:
Plotting Wave Forms, Intensity, and Time Aligning TextGrid data
Jesse Stewart
June 10, 2016
Plotting Wave Forms, Intensity, and Time Aligning TextGrid data
Jesse Stewart
June 10, 2016
This tutorial/ guide/ code (or whatever you want to call it) details how to export sound data from Praat and plot it using R. This method was originally developed for a paper I co-authored with Martin Kohlberger (currently in-press) to analyse nasality data. The code provided in the appendix of this paper details how to normalise two wave forms and superimpose them for analysis using different colours. This tutorial doesn't. If you're interested in normalisation etc., feel free to contact me. This code will also deconstruct a Praat textGrid file and time align any annotations therein to the wave form or intensity curve. The code herein involves four general steps (1) saving a WAV file (or intensity file) and textGrid as text, (2) using regular expressions to strip away the metadata, (3) plotting the data using R's default plotting functions (4) taking an ungodly amount of time to align the textGrid data. This code was developed using R v 3.2.1.
Tutorial
Practice file (WAV)
Practice textGrid file
Tutorial
Practice file (WAV)
Practice textGrid file
Move all boundaries to the nearest zero crossing
Jesse Stewart
April 26, 2016
This script removes all boundaries in a given tier and replaces them with new boundaries at the nearest zero crossing to the left of the original boundary.
Script
Jesse Stewart
April 26, 2016
This script removes all boundaries in a given tier and replaces them with new boundaries at the nearest zero crossing to the left of the original boundary.
Script
Very basic tips for manipulating data frames (datasets) in R for non-programmers
Jesse Stewart
December 26th, 2015
It's all in the name. I'll try an update it as I discover more about the pain which is R.
Contents
1.) Importing and exporting your data into and from R
2.) Visualizing/ getting familiar with your data in R
3.) Changing how R reads your data
4.) Subsetting your data in R
5.) Combining data frames
6.) Replace/rename/remove data (not using RegEx)
7.) IF statements in R
8.) FOR LOOPS in R
9.) Regular Expressions in R
'Tutorial' (If that's what you want to call it.)
Jesse Stewart
December 26th, 2015
It's all in the name. I'll try an update it as I discover more about the pain which is R.
Contents
1.) Importing and exporting your data into and from R
2.) Visualizing/ getting familiar with your data in R
3.) Changing how R reads your data
4.) Subsetting your data in R
5.) Combining data frames
6.) Replace/rename/remove data (not using RegEx)
7.) IF statements in R
8.) FOR LOOPS in R
9.) Regular Expressions in R
'Tutorial' (If that's what you want to call it.)
Importing multiple text/Excel files and appending them automatically in R to made a single large data frame.
Jesse Stewart
December 18th, 2015
I'd like to create a large data frame in R based on multiple smaller data frames. In my specific case I have about 76 Excel spreadsheets that were created from a perceptual experiment, each one with about 300 rows of data. I didn't want to copy and paste each spreadsheet one after another, and Excel (specially older versions) has a tendency to bog down with large data frames; and with 6 columns with 22,800 rows of data, 'bogging' is still an issue, even with Excel 2010.
Excel version
Text file version
Jesse Stewart
December 18th, 2015
I'd like to create a large data frame in R based on multiple smaller data frames. In my specific case I have about 76 Excel spreadsheets that were created from a perceptual experiment, each one with about 300 rows of data. I didn't want to copy and paste each spreadsheet one after another, and Excel (specially older versions) has a tendency to bog down with large data frames; and with 6 columns with 22,800 rows of data, 'bogging' is still an issue, even with Excel 2010.
Excel version
Text file version
Vowel charts in Excel
Jesse Stewart
June 10th, 2015
I was recently asked how to make vowel charts in Excel. While I still prefer R, Excel does a decent job too. This tutorial covers: formatting your data, plotting the vowels in a scatter plot, adjusting axes, adding labels, editing labels, adding/ removing titles, and gridlines etc.
Tutorial
Example dataset
Jesse Stewart
June 10th, 2015
I was recently asked how to make vowel charts in Excel. While I still prefer R, Excel does a decent job too. This tutorial covers: formatting your data, plotting the vowels in a scatter plot, adjusting axes, adding labels, editing labels, adding/ removing titles, and gridlines etc.
Tutorial
Example dataset
Fricatives, Fricatives, Fricatives
Jesse Stewart
Version 1.0 - September 24th, 2014
If your textGrids are setup correctly, and as always, if quantum flux is not materializing unwanted bogons into your CPU, this script should, for all intents and purposes give you the following data:
Code (optional), Gender, File name, Word, Overall duration, Initial transition duration, Steady state duration, Final transition duration, Initial transition max intonation, Initial transition min intonation, Initial transition max pitch (F0), Initial transition min pitch, Initial transition max F1, Initial transition min F1, Initial transition max F2, Initial transition min F2, Initial transition max F3, Initial transition min F3, Steady state max intonation, Steady state min intonation, Steady state max pitch (F0), Steady state min pitch, Steady state max F1, Steady state min F1, Steady state max F2, Steady state min F2, Steady state max F3, Steady state min F3, Final transition max intonation, Final transition min intonation, Final transition max pitch (F0), Final transition min pitch, Final transition max F1, Final transition min F1, Final transition max F2, Final transition min F2, Final transition max F3, Final transition min F3, Segment, Mid intensity, Mid Pitch, Mid F1, Mid F2, Mid F3, Centre of gravity, Standard deviation, Skewness, Kurtosis, Central movement
PS. This script was a real pain to write.
Script
Jesse Stewart
Version 1.0 - September 24th, 2014
If your textGrids are setup correctly, and as always, if quantum flux is not materializing unwanted bogons into your CPU, this script should, for all intents and purposes give you the following data:
Code (optional), Gender, File name, Word, Overall duration, Initial transition duration, Steady state duration, Final transition duration, Initial transition max intonation, Initial transition min intonation, Initial transition max pitch (F0), Initial transition min pitch, Initial transition max F1, Initial transition min F1, Initial transition max F2, Initial transition min F2, Initial transition max F3, Initial transition min F3, Steady state max intonation, Steady state min intonation, Steady state max pitch (F0), Steady state min pitch, Steady state max F1, Steady state min F1, Steady state max F2, Steady state min F2, Steady state max F3, Steady state min F3, Final transition max intonation, Final transition min intonation, Final transition max pitch (F0), Final transition min pitch, Final transition max F1, Final transition min F1, Final transition max F2, Final transition min F2, Final transition max F3, Final transition min F3, Segment, Mid intensity, Mid Pitch, Mid F1, Mid F2, Mid F3, Centre of gravity, Standard deviation, Skewness, Kurtosis, Central movement
PS. This script was a real pain to write.
Script
Save all the sound files in your object's window
Jesse Stewart
Version 1.0 - August 9th, 2014
The title's it in a nutshell. Select all your sound files in the object's window, and run the script.
Script
Jesse Stewart
Version 1.0 - August 9th, 2014
The title's it in a nutshell. Select all your sound files in the object's window, and run the script.
Script
Course: ELAN 1 & 2 from CoLang 2014
Nicole Rosen & Jesse Stewart
June 2014
In this class students learn how to use the ELAN software to link transcriptions to audio and video media. We also talk extensively about how to conceptualize tiers (layers of linguistic analysis and glossing in your transcription) so that students can create annotations flexible enough for a range of configurations of speakers and languages. This class will be useful for students working with extended spontaneous speech recordings, including narratives and conversation. Topics in this course include: Annotation, tires, linguistic types, associating tiers with linguistic types, setting up hierarchies, subtitling, automatically adding text to blank ELAN annotations, templates, controlled vocabularies, regular expressions and others.
ELAN 1
ELAN 2
Nicole Rosen & Jesse Stewart
June 2014
In this class students learn how to use the ELAN software to link transcriptions to audio and video media. We also talk extensively about how to conceptualize tiers (layers of linguistic analysis and glossing in your transcription) so that students can create annotations flexible enough for a range of configurations of speakers and languages. This class will be useful for students working with extended spontaneous speech recordings, including narratives and conversation. Topics in this course include: Annotation, tires, linguistic types, associating tiers with linguistic types, setting up hierarchies, subtitling, automatically adding text to blank ELAN annotations, templates, controlled vocabularies, regular expressions and others.
ELAN 1
ELAN 2
Tutorial: Automatically adding text to blank ELAN annotations
Sky Onosson & Jesse Stewart
March 29th, 2014
I am annotating a number of audio files which are recordings of speakers reading from a wordlist. The wordlist itself is saved as a text file with spaces between the words. I wanted to segment out the words as annotations without having to re-type the entire wordlist, instead loading it in to the blank annotations directly from the wordlist file.
What you'll need:
ELAN v.4.6.2
TextEdit v.1.9 / Notepad
Microsoft Excel 2011 v.14.0.0.0
Download PDF Guide
Sky Onosson & Jesse Stewart
March 29th, 2014
I am annotating a number of audio files which are recordings of speakers reading from a wordlist. The wordlist itself is saved as a text file with spaces between the words. I wanted to segment out the words as annotations without having to re-type the entire wordlist, instead loading it in to the blank annotations directly from the wordlist file.
What you'll need:
ELAN v.4.6.2
TextEdit v.1.9 / Notepad
Microsoft Excel 2011 v.14.0.0.0
Download PDF Guide
Windows executable: Media Lengua Database
Jesse Stewart
Version 1.0 (Beta) - February 22nd, 2014
It's official. I have just finished compiling the beta version of my Media Lengua database into a nice executable (with some sloppy Access databases and wave files hanging around). If you're interested in working with this Media Lengua data - just send me an e-mail and we can chat.
Description :
This dataset contains almost 2000 elicited sentences from the Pijal dialect of Media Lengua. This data was gathered by me during several field trips from 2010-2014.
Forthcoming (This dataset is still in its beta phase):
1.) Translations for the 'Translation' textbox have yet to be made. In the mean time, please refer to the 'Elicitation' and 'comment' textboxes for rough translations of the sentences.
2.) Spanish translations in the comment field are at times quite literal and may not make much sense to Spanish speakers with little knowledge of Quichua or Media Lengua
3.) The sound files are not directly accessible from the dataset. I'm working on this.
Jesse Stewart
Version 1.0 (Beta) - February 22nd, 2014
It's official. I have just finished compiling the beta version of my Media Lengua database into a nice executable (with some sloppy Access databases and wave files hanging around). If you're interested in working with this Media Lengua data - just send me an e-mail and we can chat.
Description :
This dataset contains almost 2000 elicited sentences from the Pijal dialect of Media Lengua. This data was gathered by me during several field trips from 2010-2014.
Forthcoming (This dataset is still in its beta phase):
1.) Translations for the 'Translation' textbox have yet to be made. In the mean time, please refer to the 'Elicitation' and 'comment' textboxes for rough translations of the sentences.
2.) Spanish translations in the comment field are at times quite literal and may not make much sense to Spanish speakers with little knowledge of Quichua or Media Lengua
3.) The sound files are not directly accessible from the dataset. I'm working on this.
R Code: Vowel charts in R
Jesse Stewart
Version 1.0 - January 26th 2014
The tutorial isn't really an in-depth 'guide' to making vowel charts in R since the majority of people are often just interested in copying and pasting code. I do however, breakdown the code a bit in case you'd like to better understand it or personalize your chart. At some point I will add something resembling to add 3D density/surface/contour plot o this tutorial so stay tuned.
What you'll need:
R CRAN Project
Aplpack library
(Open R --> Menu: Packages --> Install Package(s) --> Chose country --> aplpack --> OK)
Vowels.txt
Vowela.txt
Download PDF guide
Jesse Stewart
Version 1.0 - January 26th 2014
The tutorial isn't really an in-depth 'guide' to making vowel charts in R since the majority of people are often just interested in copying and pasting code. I do however, breakdown the code a bit in case you'd like to better understand it or personalize your chart. At some point I will add something resembling to add 3D density/surface/contour plot o this tutorial so stay tuned.
What you'll need:
R CRAN Project
Aplpack library
(Open R --> Menu: Packages --> Install Package(s) --> Chose country --> aplpack --> OK)
Vowels.txt
Vowela.txt
Download PDF guide
Praat Script: VOT, vowel duration, midpoints (pitch F1, F2, F3), word, and the 1st seven formant transitions (F1 F2 & F3)
Jesse Stewart
Version 1.0 - January 20th, 2014
If your textGrids are setup correctly and quantum flux is not materializing unwanted bogons into your CPU, this script should, for all intensive purposes give you (1) the duration between two intervals on tier 1 for measuring VOT. Based on the intervals in tier two, it should also register (2) the mid-point values of the pitch, F1, F2, F3 frequencies and (3) the duration of vowel. Based on the same intervals in tier two, it should also (4) register the frequencies of the first seven formant values (F1, F2 & F3) in order to analyze the transition patterns following VOT. This is achieved by reading the value of the first formant point located at the initial interval then subsequently shifting to the following point based on the time step duration between the formants. Any information placed on the third tier e.g., 'word' or speaker name will (5) also be registered to the output file (named dats.txt).
As a bonus, you get to select the gender of the speaker which will change the view range frequency (Hz) to 5000 for men and 5500 for women. At the same time, by selecting gender, the pitch will be changed to 75-500 Hz for women and to 50-300 Hz for men. You shouldn't need to have multiple files since this script will run through both a large segmented files with multiple intervals or small individual files with a single interval on each tier. Any feedback is appreciated.
Download V 1.0
Jesse Stewart
Version 1.0 - January 20th, 2014
If your textGrids are setup correctly and quantum flux is not materializing unwanted bogons into your CPU, this script should, for all intensive purposes give you (1) the duration between two intervals on tier 1 for measuring VOT. Based on the intervals in tier two, it should also register (2) the mid-point values of the pitch, F1, F2, F3 frequencies and (3) the duration of vowel. Based on the same intervals in tier two, it should also (4) register the frequencies of the first seven formant values (F1, F2 & F3) in order to analyze the transition patterns following VOT. This is achieved by reading the value of the first formant point located at the initial interval then subsequently shifting to the following point based on the time step duration between the formants. Any information placed on the third tier e.g., 'word' or speaker name will (5) also be registered to the output file (named dats.txt).
As a bonus, you get to select the gender of the speaker which will change the view range frequency (Hz) to 5000 for men and 5500 for women. At the same time, by selecting gender, the pitch will be changed to 75-500 Hz for women and to 50-300 Hz for men. You shouldn't need to have multiple files since this script will run through both a large segmented files with multiple intervals or small individual files with a single interval on each tier. Any feedback is appreciated.
Download V 1.0
Guide: One way to make a synthetic 10 step continuum between minimal pairs made from natural speech: Pitch, duration, formant transitions, VOT & other natural speech add-ons.
Jesse Stewart
Version 1.0 Beta
Once upon a time there was a great Praat add-on called Akustyk that would do much of the grunt work found in this guide, but it appears to have since vanished from the inter-nets. This guide provides step-by-step explanations of how to manually build a continuum without Akustyk (something I've also found to be quite scant on the inter-webs). I've also added an Excel spreadsheet that does a lot of the mathies for you. Whether you are building a continuum between [b] & [p], [b] & [d], or [i] & [e], this guide might be useful (or you may end up hating me). I'm slowly but surely attempting to automate some of the processes with Praat scripts, but until I finish, consider it a learning experience ;-).
*Before you begin, take a look at these animated gifs below and listen to the sound files. I'd hate for you to get to the end and realize this is not what you expected.
Jesse Stewart
Version 1.0 Beta
Once upon a time there was a great Praat add-on called Akustyk that would do much of the grunt work found in this guide, but it appears to have since vanished from the inter-nets. This guide provides step-by-step explanations of how to manually build a continuum without Akustyk (something I've also found to be quite scant on the inter-webs). I've also added an Excel spreadsheet that does a lot of the mathies for you. Whether you are building a continuum between [b] & [p], [b] & [d], or [i] & [e], this guide might be useful (or you may end up hating me). I'm slowly but surely attempting to automate some of the processes with Praat scripts, but until I finish, consider it a learning experience ;-).
*Before you begin, take a look at these animated gifs below and listen to the sound files. I'd hate for you to get to the end and realize this is not what you expected.
|
|
Download Excel spreadsheet
Download PDF guide - draft
______________________________
VOT Continuum:
Beta scripts for automating parts of the process related to modifying stop consonants
Pitch portion
Duration portion
Formant portion
In case you're having issues with the above Formant script, try this one:
Formant portion II
You can cite one of the following papers which has used this method:
Stewart, J., F. Meakins, C. Algy, & A. Joshua (2018). The Development of
Phonological Stratification: Evidence from Stop Voicing Perception in Gurindji Kriol
and Roper Kriol. Journal of Language Contact, 11(1): 71-112 10.1163/19552629-01101003
[paper]
Stewart, J. (2015). Production and Perception of Stop Consonants in Spanish, Quichua, and Media
Lengua. DSpace: University of Manitoba, August 24, 2015
Vowel Continuum:
Note: These scripts are still being beta tested. Use the sound sample with the shortest vowel duration as the default. The empty text files must be in the same directory as the scripts.
Pitch portion
Formant portion
Duration portion
dats.txt
cdats.txt
dats1.txt
You can cite one of the following papers which have used this method:
Stewart, J. (2018). A comparative analysis of Media Lengua, Quichua, Spanish vowel
perception. Journal of Phonetics, 71: 117-193 https://doi.org/10.1016/j.wocn.2018.08.005
Download PDF guide - draft
______________________________
VOT Continuum:
Beta scripts for automating parts of the process related to modifying stop consonants
Pitch portion
Duration portion
Formant portion
In case you're having issues with the above Formant script, try this one:
Formant portion II
You can cite one of the following papers which has used this method:
Stewart, J., F. Meakins, C. Algy, & A. Joshua (2018). The Development of
Phonological Stratification: Evidence from Stop Voicing Perception in Gurindji Kriol
and Roper Kriol. Journal of Language Contact, 11(1): 71-112 10.1163/19552629-01101003
[paper]
Stewart, J. (2015). Production and Perception of Stop Consonants in Spanish, Quichua, and Media
Lengua. DSpace: University of Manitoba, August 24, 2015
Vowel Continuum:
Note: These scripts are still being beta tested. Use the sound sample with the shortest vowel duration as the default. The empty text files must be in the same directory as the scripts.
Pitch portion
Formant portion
Duration portion
dats.txt
cdats.txt
dats1.txt
You can cite one of the following papers which have used this method:
Stewart, J. (2018). A comparative analysis of Media Lengua, Quichua, Spanish vowel
perception. Journal of Phonetics, 71: 117-193 https://doi.org/10.1016/j.wocn.2018.08.005
Praat Guide: Praat basics for analyzing prosody - TextGrids, Pitch, Drawing Pictures
Jesse Stewart
Version 1.0 - February 24th 2013
This guide covers the basics of using Praat to analyze pitch. Here I cover the basics of opening and/ or recording new files, the view & edit window, zooming, sound details, textGrids, 'cleaning up' the pitch track, and drawing pictures using the Praat picture window.
What you'll need:
Praat (installs a single executable file)
Practice files: Wave file & TextGrid file
Download PDF Guide
Jesse Stewart
Version 1.0 - February 24th 2013
This guide covers the basics of using Praat to analyze pitch. Here I cover the basics of opening and/ or recording new files, the view & edit window, zooming, sound details, textGrids, 'cleaning up' the pitch track, and drawing pictures using the Praat picture window.
What you'll need:
Praat (installs a single executable file)
Practice files: Wave file & TextGrid file
Download PDF Guide
ELAN Guide: Installing ELAN on Windows, Troubleshooting Video Issues, and Adding Hardcoded Subtitles to Your Video
Jesse Stewart
Version 1.0 - October 7th 2011
The randomness of the title stems from the fact adding hardcoded subtitles was a necessary step for course project which involved installing ELAN and dealing with video playback issues for those using Windows O/Ss. This guide was written with Win 7 in mind, but will probably work on XP and Vista as well. This guide offers a step-by-step explanation of how to (1) install QuickTime, (2) ELAN, (3) Codec packages, and (4) XviD4PSP while exporting and hardcoding subtitles (made in ELAN) to your video.
What you'll (probably) need:
QuickTime
K-Lite Codec Pack or XP Codec Pack for XP users
XviD4PSP
OptimFrog.dll
Download PDF guide
Jesse Stewart
Version 1.0 - October 7th 2011
The randomness of the title stems from the fact adding hardcoded subtitles was a necessary step for course project which involved installing ELAN and dealing with video playback issues for those using Windows O/Ss. This guide was written with Win 7 in mind, but will probably work on XP and Vista as well. This guide offers a step-by-step explanation of how to (1) install QuickTime, (2) ELAN, (3) Codec packages, and (4) XviD4PSP while exporting and hardcoding subtitles (made in ELAN) to your video.
What you'll (probably) need:
QuickTime
K-Lite Codec Pack or XP Codec Pack for XP users
XviD4PSP
OptimFrog.dll
Download PDF guide