20 March 2023

Marking segments and annotating TextGrids in Praat

Praat is a powerful acoustic analysis software application used by phoneticians, speech scientists, linguists, audiologists, and anyone interested in measuring or manipulating speech. It was created by Paul Boersma and David Weenink who are two extremely smart, and odd (in the best possible sense), language scientists. As you use Praat, you will come to realise that the interface and design decisions reflect the personalities of its creators.

Upon launching Praat, you are presented with two windows: Praat Objects and Praat Picture. I would say that 99% of time, the user immediately closes Praat Picture. Praat Objects is where the action lies. At first glance, there isn’t a lot going on: an empty Objects list, and not many buttons showing. Unlike most software apps, the command buttons available to the user change depending on the currently selected Object type. So, in order to get started, you need to load or “read in” a file. In most instances, this will be a Sound file (such as a WAV or AIFF).


To read in a sound file, click Open then Read from file… and select the file that you want to open. That file will be loaded into Praat as a Sound object and a number of command buttons will appear on the right side of the Praat Objects window.



Our task is to mark and annotate speech segments in a TextGrid. With the Sound object selected, click on the Annotate button and then To TextGrid… You should see the Sound: To TextGrid dialog box appear and the tier names field will be pre-populated with Mary John bell and you will note that bell is a point tier. Oh the wonderful conversations I’ve had with students over the years trying to explain why Mary John bell are there! Remember that like its creators, Praat is a bit weird. Mary, John and bell are not functions or keywords or special in any way. They are merely placeholders that should be deleted immediately and replaced with whatever you want to call your tier(s). In many cases, a single tier will do. Fun fact: I usually call mine t1 (an old habit back from when tier names could not begin with a number) and almost never use point tiers. 




Once you have named your tier(s) and left the point tier field blank, click OK to create the TextGrid object. Note that it has the same name as your Sound object, which is an important convention within the world of Praat as all scripts assume that Sounds and TextGrids have identical names. Also notice that when a new object is created it is automatically selected, and the command buttons in the Praat Objects window change accordingly. 




In order to segment a Sound object and add annotations it is necessary to open the Sound and TextGrid objects together in the Praat Editor. Do this by selecting both objects (for Mac use Cmd+click; for Windows use Ctrl+click) and then click on the new View & Edit command button that will appear on the right. This will open the Editor and you will see 3 panes: 

1. the acoustic waveform, or oscillogram, on top

2. the spectrogram in the middle (which will only be visible when you zoom in, more on that below)

3. the TextGrid at the bottom (it will look yellow)




Becoming familiar with working within the Praat Editor

When working with Sound and TextGrid objects, there are essentially 3 things you can do: 

1. Navigate (zoom in and out, move left and right)

2. Add and remove boundaries to a TextGrid tier  

3. Add/edit text annotations between boundaries


Navigating in the Praat Editor

Working with Sound objects in Praat requires you to zoom in so that you can make precise decisions. So, you need to get comfortable with zooming in and out, and moving left and right. 



Zooming is relatively straightforward. You can Zoom in, Zoom out, Zoom to selection, or Show all. There are 3 ways that you can access these zoom commands: by clicking on the zoom buttons in the bottom left corner of the Praat Editor window (sometimes useful), by clicking on the View menu and then selecting the desired Zoom command (not very useful, pretty slow, but useful if you’ve forgotten the keyboard shortcut), or by using the keyboard shortcuts (the best!), which are Ctrl+I = Zoom in, Ctrl+O = Zoom out, Ctrl+N = Zoom to selection, or Ctrl+A = Show all (replace Ctrl with Cmd for Mac).



Moving left or right to earlier or later sections of the Sound object can be achieved by: dragging the horizontal scrollbar at the bottom of the Praat Editor window (least accurate); using the PageUp and PageDown keys (more accurate, and quite usefu); or titling the scroll wheel of your mouse left or right (my personal favourite, especially for small moves). Hot tip: Swiping left or right with two fingers on a Mac will achieve the same thing.


Listening to audio

When working with TextGrids and Sound objects, wearing a good pair of headphones and listening to audio is a must. There are multiple ways to listen to segments of audio. When a portion of the audio is selected, the upper most bar at the bottom of the Praat Editor window will split the window into three. Clicking on one of the three portions of the bar will play only that segment (super useful; keyboard shortcut: Tab). Clicking on the middle bar will play the visible part that you can see in your window (this is often useful; keyboard shortcut: Shift+Tab). And clicking on the lower bar will play the Total duration (usually too long to be useful). You can also play audio from the menu by clicking on View then Play or stop or Play window. To my knowledge no one has ever done it this way, so do not be the first. Click on the upper most bar at the bottom of the Editor window or use Tab. 



Marking boundaries

Now that we know how to navigate and listen to audio, we need to learn how to add, manipulate, and remove boundaries so that we can add text annotations. Adding boundaries is relatively easy. The thing that can be dificult is deciding where the boundary should go. But that will depend on the the goal that you are trying to achieve. For our purposes, we are trying to segment a large audio recording into individual sentences for stimulus playback. So, we want to be quite generous when marking boundaries so as not to cut off the speaker when they are finishing their utterance. We also want to begin and end on a zero crossing to ensure a lovely, smooth listening experience for our future participants. 


Bonus: What is a zero crossing?

The waveform or oscillogram represents the movement of the microphone/speaker over time. The line down the centre, the position where the mic/speaker rests during silence, is zero. A zero crossing is the point where the waveform crosses zero. When editing audio, cutting at zero crossings will ensure a seamless onset and offset free of unpleasant audible clicks.


In the Praat Editor, you may move your cursor to the nearest zero crossing by clicking Select then Move cursor to nearest zero crossing, or by using the keyboard shortcut Cmd+0 (Mac) or Ctrl+0 (Windows).


(Back to) Adding boundaries

Now, let’s add some boundaries. Once again, there are multiple ways to do this. Once you have zoomed in and are satisfied that you have located the correct part of the sentence, you may add a boundary by performing a single click on the waveform or spectrogram, which will place your cursor at that point, and you will see a red dotted line running vertically at that location. To add a boundary, you may: click the circle at the top of the TextGrid tier; click Boundary then Add on selected tier; or press the Return/Enter key.


Annotating segments is relatively straightforward. Simply type or paste the text that you want to appear. Note that if you need to edit the text annotation, you should direct your attention to the white editable area above the waveform, near the top left of the Praat Editor window. If I had a dollar for every student who yelled at Praat because they were trying to select the text in the yellow portion on the TextGrid tier, I’d be a rich man.



Removing boundaries is relatively easy too (once you know how). Essentially, there are two things you need to do. First, make sure that the correct boundary is selected. The selected boundary is red; all others are blue. With the correct boundary selected, you may either click on Boundary then Remove, or use the keyboard shortcut (Mac: Option+Delete; Windows: Alt+Backspace).


A final (but important!) note

Praat does not autosave your work. It barely prompts you or warns you when you are going to quit and lose all your work. So, please for the love of God, make sure that you save your TextGrids as you go. Within the Praat Editor, click File then Save TextGrid as text file… (or Mac: Cmd+S; Windows Ctrl+S) to make sure that you do not lose your work.






15 August 2022

Things 3: Keyboard shortcut to assign tasks to projects

Things by Cultured Code is a fantastic task manager. I've been using it for years. I love it. It's simple when you want it to be. And powerful when you need it to be. It combines the best elements of a paper and pencil list, with the convenience of a digital app. And it has the best support for keyboard shortcuts. Entering tasks is so fast in Things because your hands never need to leave the keyboard. It is a joy to use.

Things is flexible enough to accommodate different ways of working. I tend to assign tasks to Projects (or sometimes Areas). This can be done by dragging the task to the Project in the left pane. But, I usually have the left pane hidden, and don't want to lift my hands from the keyboard. There isn't a keyboard shortcut for assigning tasks to Projects. 

But.. there is a sequence of keyboard commands that can assign a task to a Project.

Step 1: Cmd+Shift+M will bring up the Move menu.



Step 2: Type the name of the Project/Area you want to move the task to. As you type, the list will filter in real time with each keystroke. Usually, a few keystrokes will do the trick. Once you've found the Project/Area you want, hit Return and you're done.



21 June 2018

Australasian International Conference on Speech Science and Technology (SST) referencing style for Zotero

Zotero supports the open source Citation Style Language standard and it is really useful for formatting in-text citations and reference lists to the exact specifications of journals that you are submitting your work to. But, it can be a little tricky to find the right citation style for conference papers.

The Australasian International Conference on Speech Science and Technology (SST) is the biennial conference of the Australasian Speech Science and Technology Association (ASSTA). The conference accepts submissions for 1-page abstracts and 4-page papers, the latter of which are published in the conference proceedings.

SST papers use a modified IEEE referencing style.


I have modified the IEEE referencing style in the Zotero Styles Repository to create a custom SST reference style to take the pain out of preparing SST paper submissions.

Download SST reference style for Zotero

22 May 2018

A productive Zotero setup

I was an early adopter of Zotero (my first references were imported on 8 November 2006) and I have been a long time user. Originally released as a Firefox plug-in, Zotero is now available as a stand-alone app with connectors for most popular browsers.

I use Safari as my default browser. I use Chrome whenever Flash is required. I use Firefox as my research browser when gathering references.


I have the homepage and default search engine set to Google Scholar. I have bookmarks pointing to a few university libraries, the Zotero styles page, the NLM Catalog (for looking up journal abbreviations), and the Resolve a DOI page.

You can use Zotero with word processors such as Microsoft Word and LibreOffice by installing the word processor plugin.

Download links:

Firefox - https://www.mozilla.org/en-US/firefox/?utm_medium=referral&utm_source=firefox-com

Zotero - https://www.zotero.org/

Zotero styles - https://www.zotero.org/styles

Journal abbreviations - https://www.ncbi.nlm.nih.gov/nlmcatalog/journals

DOI lookup - https://dx.doi.org/

Zotero word processor plugins - https://www.zotero.org/support/word_processor_integration

04 June 2017

How to find the correct SMTP server settings so that you can Send Mail As from Office365 in Gmail

One of Gmail's (many) cool features is that it lets you check mail from other non-Gmail addresses and send mail from other addresses that you own. This allows you to manage all of your email from a single interface, and extends all of the benefits of Gmail to mail from your other non-Gmail accounts (labels, Google-powered search, etc.).


Set up Send Mail As

Here are Google's instructions for how to set up sending emails from a different address in Gmail:

Step 1: Add an address you own
  1. On your computer, open Gmail.
  2. In the top right, click Settings.
  3. Click the Accounts and Import or Accounts tab.
  4. In the "Send mail as" section, click Add another email address.
  5. Enter your name and the address you want to send from.
  6. Click Next Step.
  7. Enter the SMTP server (for example, smtp.domain.com) and the username and password on that account.
  8. Click Add Account.
Step 2: Confirm the address
  1. Sign in to the account you added.
  2. Open the confirmation message you got from Gmail.
  3. Click the link.
Step 3: Change the "From" address
  1. In the message, click the "From" line.
    (If you don't see this, click the space next to the recipient's email.)
  2. Select the address to send from.


Uh-oh, errors

When it works, it is a thing of beauty. The problem is that for some email addresses, these default steps do not cut it. This is particularly the case for Microsoft Exchange or the newer Office365 email addresses. Users with Microsoft work email addresses tend to run into trouble at step 1.7 when attempting to specify the SMTP server.

I have come across two errors. The first appears when using the default SMTP address without making any changes:
Couldn't reach server. Please double-check the server and port number.

Another error message came up when I used the recommended SMTP server for Office365 users (which is smtp.office365.com):
Authentication failed. Please check your username/password.
Server returned an error: "334 VXNlcm5hbWU6 334 UGFzc3dvcmQ6 535 5.7.3 Authentication unsuccessful [CY4PR16CA0035.namprd16.prod.outlook.com] code(535) "

Some people claim to have come across an error saying Server response: read error code(0), although I have not seen that error, myself.


So, what's the problem?

The problem is obviously that I was not specifying the correct SMTP server. You might think that the first step should be to contact IT support at work to obtain the correct SMTP address. IT Support do not understand what you are trying to do. They might tell you to use the recommended email client (most likely Outlook). You re unlikely to find a solution this way.

For me, this was very frustrating and led to a lot of searching and trawling through forums, trying to find a solution. The issue arises from the fact that the recommended SMTP server (smtp.office365.com) is not the final destination, but rather redirects to another SMTP server address based on your location (similar to how typing in Google.com will redirect you to Google.co.uk in England, but to Google.com.au in Australia).


How to find your Office365 SMTP server

In order to find your SMTP server, you must ping the smtp.office365.com address. And it is really easy to do.

On Mac, open Network Utility, click on the Ping tab, then enter the network address to ping, and click the Ping button. After a few seconds, a report will be generated, and at the top it will output something like this:
Ping has started…

PING outlook-au.office365.com

You could also open a Terminal window and type ping smtp.office365.com and then press Enter. After a few seconds it will start generating output. On the top line will be something like this:
PING outlook-au.office365.com

On Windows, open a Command Prompt window and type ping smtp.office365.com and then press Enter. It will start generating output, and the top line will look something like this:
Pinging outlook-au.office365.com

My particular SMTP server is outlook-au.office365.com. Entering this address as the SMTP server, my full Office365 email address as the username, and password worked when adding my Office365 address to Gmail.


07 April 2017

How to use Pivot Tables in Excel

Excel can be used to conduct some pretty advanced statistical analyses and data visualisations. My favourite, and most commonly used feature is the Pivot Table. The data in a Pivot Table can be restructured very easily and counts, averages and other calculations can be worked out quickly. It is often desirable to enter data from scientific experiments into a Pivot Table so that different conditions can be compared, some conditions or participants or trials can be excluded, and data can be collapsed or combined in a number of ways. But, for all of their usefulness, getting the data in to a format that can be read by a Pivot Table can be time consuming. Some experiment presentation/management programs, such as E-Prime, generate result files for individual participants. In order to generate a Pivot Table report, all data needs to be entered into a single Excel worksheet.

Here are the steps necessary to generate a Pivot Table in Excel:

1. Export the results files into a format that can be imported into Excel
Some experimental software outputs results in plain text format or as .csv files. These can be imported into Excel without any extra work. However, some software outputs results in a proprietary format that must be converted before Excel can read the data.

E-Prime: Open the .edat2 file in E-DataAid, and export to Excel format. For example, you would export participant1.edat2 as participant1.edat2.txt.

Hint: If you have many E-Prime data files, open these in E-Merge and create a merge file containing data for all of the participants. Then open the merge file using E-DataAid and export it to Excel format.

2. Open the text file in ExcelOpen the new .txt files in Excel (you can either select File | Open or drag and drop the file into Excel).

3. Go through the Text Import Wizard


In Step 1, select Delimited and click Next.




In Step 2, check the Tab option from the list of Delimiters and click Finish.

4. Delete Row 1
By default, E-Prime outputs the file path in the first line of the .txt file, which becomes row 1 when you import it into Excel. Delete it. This will cause row 2 to move up. Now row 1 contains your column headings which will become your Pivot Table fields.

5. Create a Pivot Table
Select all active columns. To do this, click on column A (by clicking on the A) and hold down the Shift key and click on the column label of the right most column (mine is HZ). This can be done using the keyboard by pressing Command+Shift+right arrow while column A is selected.


Click on the Insert ribbon and then Pivot Table. When the Create Pivot Table dialog appears, click OK.

6. Build your Pivot Table
Drag the fields that you are interested in into the Rows, Columns or Values areas. Subject/participant normally goes into the Rows area. The measures of interest (e.g., accuracy or reaction time data) usually go into Values.

When you first drag a field into Values, Excel will show you the count of how many data points there are. Click on the "i" next to the field within the Values area to show the Pivot Table Field window.


This gives you options to calculate the sum, average, maximum, minimum, standard deviation and so on. For experimental data, most of the time, we are interested in averages.

Spend time playing around with the fields in the Pivot Table Builder. You can explore your data in powerful ways, such as by isolating particular subjects, conditions, or cases.



Clicking on the inverted triangle next to Row Labels brings up the Row window which permits you to sort the rows, add filters, and exclude individual cases. This can be handy for exploring potential outliers (when looking at subjects), or examining performance for particular conditions or stimulus tokens.

Pivot Tables are great tools for exploring your data. They offer a degree of flexibility that is unmatched. They are very useful for answering "What happens if..." questions, and the calculations can be done very quickly.

25 January 2017

Zotero minimalist referencing style for grant applications

I use a custom Zotero referencing style when writing grant applications. It is designed to save space, and uses the following features:

  • In-text citations are denoted by superscript numerals
  • Reference list has single line spacing
  • No journal article titles
  • Journal names are abbreviated
  • No journal issue numbers
  • ≥ 3 author names are listed as "et al."

After each reference, I have inserted two forward slashes to demarcate separate references. I have also bolded the numeral that precedes each reference.

Once the reference list has been created, you may delete the carriage returns so that each reference does not take a new line.

My grant writing Zotero referencing style can be downloaded here.

19 December 2016

Calculate age in years (and months) in Excel

It is often desirable to calculate a person's age from their date of birth relative to some other date (e.g., the date when they completed some test). This is pretty easy to do in Excel.

Calculating age in years
The simplest way to do this is using the following formula

=yearfrac(start_date,end_date,1)

where start_date is the cell containing the person's date of birth.

Using the above formula for someone with a D.O.B. of 20/3/1990 who was tested on 19/9/2016 will return the value 26.5017238, which may be reduced to fewer decimal points if so desired.

Calculating age in years and months
To calculate age in years and months, rather than using a decimal point, use the following formula

=concatenate(datedif(start_date,end_date,"Y"," years, ",datedif(start_date,end_date,"YM")," months")

Using this formula will return the value 26 years, 5 months. This formula can be modified to return other commonly used formats such as 26;5.


11 June 2015

How to set up Tweetbot iCloud sync across iOS and OS X

Tapbots recently released their much anticipated v.2 update for their Mac OS X Yosemite version of their Twitter client, Tweetbot. One of the most touted features is the ability to sync timeline position across devices using iCloud. However, a quick Google search reveals that many people are experiencing issues with getting iCloud sync to work. Some of the more detailed guides I came across are:

How To Get Tweetbot to Sync to iCloud on iPhone (Fix) via Apptactics

Tweetbot and that f*cking iCloud sync via Coupaman's New Digs

Unfortunately, neither of the above guides solved my iCloud timeline sync issues. In the end, the thing that fixed the problem was signing out of iCloud on my iPhone and then signing back in.

Steps:

1. In iOS, tap Settings, then iCloud.

2. Scroll down to the bottom and tap Sign Out, and then confirm when prompted.

3. Sign back in to iCloud.

That's what did it for me. I hope that this is helpful for those who are experiencing similar issues.

09 December 2014

How to fix the no sound issue on a MacBook

I have been experiencing some sound output issues on my MacBook Air recently, and a quick Google search revealed that many people have been experiencing the same problem. Here is a short description of the the problem and my solution.

What's the problem?
I like to use ear phones with my MacBook. The sound works fine when I first boot up, however, if I am away from the computer and it goes to sleep (e.g., during lunch), the volume icon is greyed out when I wake the computer. The sound does not work and I cannot adjust the volume. Very annoying.

Troubleshooting
Sound is affected on a system-wide level. This is not restricted to a single app. Rebooting the computer resolves the issue, but this is not something I want to be doing all the time. Other users recommend flushing PRAM and doing all sorts of weird things in the Terminal that I don't want to be part of my regular workflow. Ideally, I'd like to do something once that fixes the problem for good.

The solution
When the volume icon is greyed out, click System Preferences | Sound | Output and select Headphone port as your device for sound output. That's it.

And there you have it. A simple solution to a persistent and complex problem.