Author Archives: Maria Gouskova

Using Praat Scripts

Goal: Before you attempt to write your own Praat script, you will probably try to use one of the many existing scripts. This guide is not going to teach you how to write your own scripts, or even how to modify existing scripts in minor ways for your own needs. All it covers is how to use scripts that someone else wrote. It is intended for students in an introductory phonetics course, who usually have little to no background in working with scripts or programming languages.

The point of Praat scripting is to automate tasks, so you, the human, can do all the smart stuff, and leave the computer to do repetitive boring stuff. For example, suppose you are working on a study where your interest is in measuring durations of certain consonants. Praat cannot accurately label the edges of those consonants for you–that task falls under “smart stuff” that requires human eyes and ears. But Praat can rapidly collect the durations of labeled intervals from a TextGrid for you, if you prepare the right sort of TextGrid and tell Praat exactly what you want.

The most basic thing you will do with a Praat script is make it run and tell it to do something to a file you provide, and then save the result to your computer. The confidence builder exercise below talks you through that.

But first…

Praat vs. the internet and your phone

Praat cannot read your mind.

If you are like most students taking an introductory phonetics course right now (I’m writing in 2021), the internet has always existed for you, and it isn’t your mom’s internet of 2002. Most of the apps on your phone are fronts for web apps–they allow you to interact with a website or a distributed network. Thus, your familiarity with computers is intimately tied with how the internet has evolved. Websites and web apps are designed to try to read the user’s mind, and to fail gracefully in the face of typos and missing pages. They keep your stuff organized for you, so that you can search for pictures or music or videos and somehow always find it. All the magic is hidden. One side effect of this is that kids these days can’t find things on their computers.

By contrast, Praat was originally written in the late 1990s. It has been continually maintained, and features have been added to it, but its basic nature is very 90’s. It is meant for people who know their way around their computer and who understand how to get the computer to do things the old-fashioned way. The challenge before you, then, is to learn how to talk to a 90’s computer. You need to tell the computer exactly where stuff is. (You need to tell the computer the order in which to do things, too. If you’re working with existing scripts, as in this tutorial, you generally don’t have to worry about that.)

Another side effect of Praat’s not knowing how to read your mind is that you have to be very careful with typos and whitespace. (I’ll explain what “whitespace” means below.) Approximate is not good enough; you have to be precise. You need to be extremely attentive to detail.

You are eventually going to encounter some situations where things go wrong, but Praat doesn’t tell you why. See, Praat cannot read your mind, but you have to read its mind. This is what we call debugging. You need to decompose the situation that leads to failure into steps that you can change, one at a time, to isolate the step that is causing problems. This requires an analytic approach that can be a lot of fun, as long as you frame the problem correctly.

A confidence builder

Let’s try a simple script, which is known to run on a pre-chosen audio file. The script we’ll use is Mietta Lennes’s mark pauses, and the audio file is Newgatenovelist’s reading of Her Hair, a poem from the free Librivox project. You can hear the original mp3 at the linked page; here is the .wav file I made (I used ffmpeg). As a rule, you should be working with .wav files in Praat, not .mp3 files, because the time stamps in mp3 files are not accurate.

  1. First, go to your Desktop and make a folder there named pauses. [Mac instructions][Windows instructions]
  2. Save the .wav file to that folder. Once the file is on your computer, you can view its properties by right-clicking on it (Mac users, hit Control+click). The properties will give you the location of the file, as well as its size and other details.
  3. Download the script file to the same folder.
  4. Open Praat, and load the audio file into it as a LongSound object. To do this, from Praat, go to Open>Open long sound fIle. The newest sound object opened should be selected by default. If it isn’t, click on it to select it. This will become important in a sec.
  5. Now open the script: click on Praat>Open Praat script.... You’ll see a boring-looking text file, like this:
  6. Hit “Run”. You now see a dialog window called "Run script: Give the parameters for pause analysis."
  7. Okay, now it’s time to edit something. Pay attention! You need to change the path in the last field, the one called Save TextGrid file to folder:, to the location of your audio file. If you put it in pauses on your Desktop, then the path will end in Desktop/pauses/ if you’re on a Mac or Linux machine (or Chromebook?), and Desktop\pauses\ if you’re on Windows. The part before that will be your home directory; look at the path to the file as explained in step 2 if you don’t know how to find your home directory. The slash at the end of that is important–and if you make any typos, things will break.
  8. When you’re ready, hit OK. If you did everything correctly, you should see a white Praat Info window that says Ready! The TextGrid file was saved as /wherever/you/told/Praat/to/save/it.TextGrid. If not, well, it’s time to debug things, so read the rest of this page and come back to step 7.
  9. You should also be able to see a new TextGrid object in your Praat object window. Open it together with the sound file, and you’ll see that there is a TextGrid with a “sentence” level that has intervals marked. The intervals are silences longer than 0.6 seconds. Look at the Run script window again and you’ll see that this is a default value defined in the third field of that dialog. You can also figure out how the script identified pauses by looking at that window: there is an intensity threshold (59 decibels) that defines a pause.

Okay, so what was the point of that? If you look at Mietta Lennes’s other scripts, you begin to see how this might be useful. There is a script on that page that will label a TextGrid with labels from a text file. For example, your poem. You will need to edit the TextGrid to make sure that the pauses coincide with line breaks, but it’s a lot quicker to do than to doing it from scratch. In the case of this recording, you just need to remove some interval boundaries.

There is also a script that will save labeled intervals to separate audio files, and create matching TextGrids to boot. I hope you can see how that would be useful for the final project I’ve assigned you.

A random list of problems and solutions

  1. Many problems can be fixed by starting with a clean Praat session. Remove all objects from the Object window, and start afresh. Praat scripts often operate by putting objects in the window and doing stuff to them; if there are already objects there, and they are of the wrong type, it can break the script.
  2. Unable to save file“… If you get errors about files not being found, you messed up your path somehow. Maybe you left out a slash at the end of path, or added a slash when you shouldn’t have. Maybe you skipped a crucial directory in your path. Check everything–and use the information about file locations that you get from looking at their properties, as described above.
  3. Script works on some files but breaks on others. For scripts that are supposed to work on a bunch of files: if the script is working for some of your files and failing for others, you should examine closely those text grids where the script is having trouble. That will give you an idea of what could be going wrong (for example, one of the interval boundaries might be missing in that file, but not in the others–that can break a script.)
  4. The script is asking you to enter a non-zero value, and you don’t know what to enter. (The default value in the “save labeled intervals to wav files” script is 0.000, which I normally change to 0.0001.) Try a few different numbers and see what the output looks like. The script doesn’t modify your original data, so there’s no harm in experimenting. That’s how you learn what the script does.
  5. The script giving you undefined values for some of your intervals. This could be because you mis-segmented your text grids–if you placed the boundary on something that isn’t a vowel and has no formants to measure, then of course the script will not be able to measure your formants. (Ditto for intensity, possibly.) Solution: make sure your segmentation identifies vowels.
  6. Are you running the script on the wrong file? You’re having trouble running the formant/intensity/duration collecting script on your large data file with a single text grid. That’s because the script is intended for a bunch of small individual files paired with text grids. Make sure you read the homework instructions carefully, don’t skip steps.
  7. Empty results.txt file. This one has many causes, but probably the chief one is that you’re telling the script to look for files in the wrong location. Did you change the paths to ones for you computer, or did you leave them as the defaults that were already there? On a Mac, your path probably should start with “/Users”; on a Windows machine, with “C:”. The paths below are from my Linux machine; your paths will need to be different.
    1. collect_data_dialog
  8. The script break on files that have spaces in their names. Your labeled intervals have spaces in them. Your sound files and your text grid files do not have matching names, so the script chokes. What’s the solution? Respect whitespace! See below.
  9. You’re running your data collection script on empty text grids. This is another source of the “empty results.txt file” problem. Did you save the TextGrid files after you changed their contents? Remember, Praat doesn’t save files automatically for you, like other programs you’re used to. There is no autosave of changed objects in the Object Window. You have to overwrite the files in the directory where Praat is looking for annotated text grids.

Some other gotchas in Praat scripting

  • Praat itself will warn you if you try to overwrite an existing file, but a Praat script will not. Always test a script in such a way that there is no danger of it overwriting important work.
    • Solution: create a copy of the directory with your text grids and run the script on the copy, so there is no danger of screwing up your originals. If all goes well, you can delete the originals.
  • A Praat script might be configured to have a default file name for a text grid or an audio file it created, so if you want to save multiple audio files cut out of a single big audio file, it may overwrite the same file with new content without telling you.
    • Solution: If you end up with one file but you expected several, and the one file you see is the last file you expected to be created, then the answer to your problem lies in how files are named.
  • A typo in a key location will break things. There’s no solution here but to pay attention; see also below.
  • Praat will not give you interpretable error messages unless the script you’re running provided for them. Again, there’s no solution other than to be careful.
  • There are no helpful mouseover (or finger press) hints that explain what buttons do. Once you hit that “Run” button, you might be running a risk of losing stuff. So check everything many times before you run a script.
  • There might be technical problems with a particular measurement: for some acoustic analyses, the time window has to be of a certain length, so if your vowel, say, is too short, a Praat script measuring it will fail for inexplicable reasons.
    • Solution: attempt to do the measurement by hand at the point where the script is failing.

Respecting spelling and whitespace

What is whitespace, you ask? It’s all the stuff that looks white on a screen (or black, if you like Dark Mode) but contains invisible characters that the computer does not ignore.

Examples of whitespace:

  • An actual space, as in between words.
  • A tab, like what you use in a word processor. It’s usually 4-5 spaces wide, but it’s distinct from a sequence of spaces. Just ask a Python programmer to explain this to you.
  • An end-of-line character. There are actually several of these, and they differ depending on the operating system. This is one of the reasons why simple .txt files sometimes look insane when they travel from a Windows computer to a Linux or a Mac computer.
  • A truly diabolical example of a whitespace character is a letter that is rendered in a font color that matches the background. Select the line below with your mouse, and you’ll see.

Hahaha! I am whitespace in white color! I got you, sucka!

Why are we talking about whitespace so much? Because Praat does not like spaces. In the olden days, many computers could not handle spaces in file names at all. This is the reason why oldsters such as myself use underscores for readability, as in, sound_and_language_syllabus.pdf. Behind the scenes, spaces in file names have to be modified; in URLs, for example, spaces are replaced with other character sequences. Look at the URL of any website and you will not see spaces in it. This is because computers treat spaces as meaningful breaks between objects.

So, if you open a file in Praat with spaces in the filename, Praat will automatically convert them to underscores in the name of an object. Try it! If you ignore the underscores in your handling of files, which I think many non-programmers tend to do, you will be punished for your carelessness. You’ll wonder why you have what looks like duplicates, or wonder where your file went, or, if you have spaces in the names of your folders, things might not work at all.

Solution: Do not use spaces in file names. Use a concatenation of lower and uppercase letters, as in SoundLangSyllabus.pdf, or, better, use underscores, as above.

Capital vs. Lowercase

Speaking of capitals: capital and lowercase letters are not the same characters to a computer. Whenever a program seems to treat upper- and lowercase as the same, it was explicitly told to do this. So, make sure to respect that difference.

Differences between symbols that look the same to you

Now we get to some really old-school stuff, like the ASCII vs. non-ASCII distinction. The ASCII character set (pronounced “ass key”) is the oldest, designed for English. Even commonly used Western European characters such as <ñ> and <ü> are not part of the basic ASCII set of 127 (see it here, if you need to). The oldest programs do not know how to deal with anything other than ASCII.

And this includes Praat. If you want to annotate a TextGrid, Praat will not let you enter IPA characters in Unicode; you can enter them using deadkey combinations, as explained in the manual, but you cannot paste them in directly from your word processor that uses a proper, modern IPA font.

Where this becomes a problem in working with Praat scripts is if your script depends on labels matching something. For example, if you want to extract all the intervals labeled “g”, but some of your “g” labels are IPA [ɡ], and others are regular font [g]. (Look carefully and you’ll see a difference in those symbols.) For me, some problems I’ve run into involved Russian script ” а” vs ASCII “a”; they look identical but are different to a computer. (There were scam URLs a while back that capitalized on Latin and Cyrillic using some similar looking letters… You think you’re visiting Amazon.com, but really you’re somewhere in the middle of the Azov sea. But I digress.)

Ready to go beyond these basics?

In the confidence builder example, you didn’t change the script text itself, and we did not look at the contents of the scripts. But all the Praat scripts linked above were created by people who weren’t Praat programmers (Boersma and Weenink)–and most can be modified by users such as yourself. You can take these scripts, look at their contents, and change them to suit your needs.

For another confidence builder, then, open the mark_pauses.Praat script as in the instructions above, but before you hit “Run”, do the following: go to “search”, enter “lennes”. That will take you to a line that says

text folder /home/lennes/

Change this line to /home/yourname/, and save the script. Now run it–what do you see in the field at the bottom of the dialog?

What you did is modify the form that the script generates. That window is part of the script, and the field is pre-populated by a default value. All of the form values can be defined either in the form when you run the script or by changing the script itself.

Once you understand that the contents of that file is not magic, you can take on the Praat scripting tutorial in Praat itself, or check out the various resources written by other people.

I like Eleanor Chodroff’s Praat scripting tutorial here. She has some other nice resources on her page.

And now, the obligatory metaphor

If you’ve taken classes with me, you know how I like tortured metaphors. And similes.

The way young people use computers is sort of like Hermione’s magic bag from the Harry Potter and the Deathly Hallows book. It’s a tiny bag, magically crammed with stuff, and she often uses the Accio charm to get things out of it. This is a summoning charm that just find the right thing in the mess–sort of like that search function you rely on. Hermione doesn’t bother to organize books, Muggle clothing, essence of Dittany, and all the rest of the junk in the bag because it’s bound to fall over anyway. And why bother, when you have a magic summoning charm? When you rely on search to find stuff on your computer, or on the internet, it’s pretty much like using the Accio charm.

[Another tortured metaphor: relying on the internet to keep your stuff for you is pretty much Leprechaun gold territory. Internet stuff disappears. You can practice a Zen-like non-attachment to your stuff, or you can keep it locally, and organized, if you want it to be around for years to come.]

To an older person, hearing about this Search approach is akin to learning that you keep your socks and your forks and your toothpaste and your books just randomly piled all over your room, jumbled together. We keep things in separate cabinets and drawers. We know where to find forks not because we have a magic summoning charm, but because we put the forks into the place where forks go.

The way computers actually work in reality is that you have to tell them were the fork drawer is, in explicit detail, without typos. Even when you have an operating system that can search through your files, this becomes useless if you don’t know what to search for. And believe me, a time will come when you won’t remember what you called that one file, or where on the internet you saw that one thing.

Because you see, the search-for-it approach is only good if you know what to search for.

Back to Praat. In setting up an experimental project, there are a few common-sense, fork-drawer-organizing things you should consider doing:

  • Put files into directories. For example, have a “raw_audio” directory where you keep the unsegmented data, and a “segmented_audio” and maybe “textgrids” for the eponymous things.
  • Give files sensible names without spaces. Just ask yourself–would I be able to figure out what all these files are 10 years from now?
  • Keep a small local “readme.txt” file that explains what order you did things in, and what each folder is for, in case you forget (because believe me, you will… it’s not just a matter of how well your brain works but also how much stuff is cluttering your memory; the more you know, the harder it is to recall things, paradoxically).

Okay, I’m done hectoring you for now! Did this help? Do you have any tips to include here, or anything you ran into that I didn’t cover above? Let me know.

Comments Off on Using Praat Scripts

Filed under Uncategorized

Cyrillic encodings

It seems to be increasingly uncommon for programs to have an easy way to guess encodings correctly and to manipulate them gracefully. Or maybe this is just a Linux problem. In any case, I’ve found myself looking this up repeatedly, after failing to get the right results in various text editors (VIM, Gedit, xed). This used to be so easy in Mac OS’s TextWrangler–there’s an actual menu item, “Reopen using encoding…”, with a drop-down list. You just pecked around the Cyrillic options until you saw something other than alphabet salad.

Anyway, here is the way to view and change encoding. One common source of problems is that the encoding in the file’s metadata is often wrong. For example, Sharoff’s frequency lists are encoded in CP-1251, which he says himself here. But the files claim to be in ISO-8859.

 


$ file lemma_al.txt
lemma_al.txt: ISO-8859 text, with CRLF line terminators

 

This mismatch is what causes VIM and its ilk to display trash instead of Cyrillic. Since the original information is lost, you have to do some guessing. In this case, the following command worked on first try:

$ iconv -f cp1251 -t utf8 lemma_al.txt -o lemma_al_utf8.txt

This converts -f from encoding CP-1251 -t to encoding UTF-8, taking the next argument as the input and the -o argument as the output. Open it in a text editor to see if it did the trick.

Now, CP-1251 is just one encoding. What others might you have to try? There is a good review here. The usual legacy encodings are koi8r, koi8u, cp866, ruscii, cp1251, iso8859. They are known under different names sometimes, so you might have to do some digging to get it right.

Comments Off on Cyrillic encodings

Filed under Uncategorized

Gouskova 2021

Gouskova, Maria. 2021. Phonological asymmetries between roots and affixes. Submitted to the Blackwell Companion to Morphology, Eds. Peter Ackema, Sabrina Bendjaballah, Eulàlia Bonet, and Antonio Fábregas.

This review surveys the phonological asymmetries between roots and non-roots (affixes, clitics). It starts with an extraphonological, structural definition of roots, and considers those non-phonological properties that are phonologically relevant: they are easily borrowed, and they are most deeply embedded. The empirical portion of the review concentrates on templaticism and size restrictions, asymmetries in segmental contrast/inventories, the properties of multi-root words (compounds), and accentual characteristics that differ between roots and affixes. The theoretical section surveys theories that account for these properties: Prosodic Morphology, Positional Faithfulness, the cycle and its analogs, and Anti-Faithfulness. I then critically review several recent and not-so-recent proposals that blur the line between affixes and roots, using the ‘root’ designation diacritically or recasting diacritic distinctions as structural distinctions. The
concluding section discusses the role of roots in phonological learnability.

Comments Off on Gouskova 2021

Filed under Uncategorized

Gouskova and Bobaljik 2021

Gouskova, Maria and Jonathan David Bobaljik. 2021/to appear. The lexical core of a complex functional affix: Russian baby-diminutive -onok. Natural Language and Linguistic Theory. [pdf]

Like other syntactic elements, affixes are sometimes said to be heads or modifiers. In Russian, one
suffix,-onok, can be either: as a head, it is a size diminutive denoting baby animals, and as a modifier,
it is an evaluative with a dismissive/affectionate flavor. Various grammatical properties of this suffix
differ between the two uses: gender, declension class, and interaction with suppletive alternations,
both as target and trigger. We explore a reductionist account of these differences: the baby diminutive
comprises a lexical morpheme plus a functional nominalizing head, while the evaluative affix is the
lexical morpheme alone. We contend that our account is superior to two conceivable alternatives:
first, the view that these are homophonous but unrelated affixes, and second, a cartographic alternative,
whereby diminutives attach at different levels in a universal structure.

Comments Off on Gouskova and Bobaljik 2021

Filed under Uncategorized

Sounds of the World

These are some resources for phonetics students who want to know what languages have certain sounds, how these sounds are produced, and where in the world the languages are spoken.

  • World Atlas of Linguistic Structures: this is a resource on linguistic typology–classification of languages according to various characteristics. There is a page listing features of interest, and the atlas can be searched for specific language names, as well. Here is the page on the velar nasal, for example:

As with any typological resource, it is a good starting point, but you should always look at primary sources for further research.

  • The UCLA Phonetics Vowels and Consonants page: A classic resource that goes with Peter Ladefoged’s books A Course in Phonetics and Vowels and Consonants. For many languages, there are audio files of minimal pairs illustrating unusual contrasts. The audio was often recorded in the field so the quality is sometimes fuzzy. A newer version of the same materials can be accessed on Keith Johnson’s website.
  • International Dialects of English Archive: this has recordings of English speakers reading the same two texts. For American dialects, there are multiple speakers from each state, and their age and some other demographic information is given:

screenshot of dialect archive page

  • Articulatory IPA: A great collection of short MRI, ultrasound, and schematic videos illustrating various sounds.

  • Illustrations of the IPA: From the Cambridge University Press Journal of the International Phonetics Association, a series of articles that do sketches of individual languages’ sound systems. Search the journal contents by language name or sound type. Many of the articles are open source, and they come with audio files of high quality that go with the transcriptions in the book. To see the audio files for an article, click on its “Supplementary Materials” tab.
  • UPSID: the UCLA Phonological Segment Inventory Database. This is one of the older databases, with just 451 languages, but it is supposed to be balanced geographically and genetically (that is, related languages are not overrepresented). It’s a good starting point for researching the typology of sound inventories.

Comments Off on Sounds of the World

Filed under Uncategorized

PhoNE workshops

PhoNE (Phonology in the NorthEast) is the current incarnation of a series of annual workshops, mostly on phonology, which have been meeting on the East Coast for over two decades.

Historically, the names were acronyms based on the participating schools:

RUMMIT was the Rutgers-UMass-MIT phase of the meeting. This name was used from 2009 until 2014 or so.
UMMM was the UMass-MIT Meeting on phonology, a.k.a. MUMM. These names were used 2008-9.
HUMDRUM stood for “Hopkins, U of Maryland, Rutgers, Umass”. This name was used in 2000-2009.
RUMJCLaM was the “Rutgers-UMass Joint Class Meeting”. Before that, RUMD. These names were used in the 1990’s.

Here are the locations and dates of previous meetings. Corrections are welcome, and thanks to Juliet Stanton for help in tracking these down!

2020: NYU
2019: Yale, April 13
2018: MIT, March 31
2017: UMass, April 8
2016: NYU, April 9
2015: Yale, April 2
2014: MIT, April 26
2013: UMass, April 6
2011: Rutgers, May 16
2010: MIT, December 4
2009: UMass, November 1
2009: MIT, May 9
2008: UMass, November 22
2008: MIT, March 29
2008: Rutgers, April 26
2006: Hopkins
2006: MIT
2005: UMass
2004: Rutgers
2002: UMass
2001: Hopkins
2000: Rutgers
1999: Rutgers
1998: UMass (RUMJClaM)
1997: MIT (as Bay and Berkshires Phonology)

Comments Off on PhoNE workshops

Filed under Uncategorized

Features in phonology

This is a 30-page overview of phonological features, which I wrote for the phonology classes I teach at NYU. It is intended to be accessible to both undergraduates and graduates; I usually ask the undergrads to read sections 1-4 and 9, and the grads to read the whole thing. If you would like to cite this review in your work, refer to it as follows:

Gouskova, Maria. 2016. Features in Phonology. [pdf] Ms., New York University.

Comments Off on Features in phonology

Filed under Uncategorized

Drawing linguistic structure trees

The LaTeX way

I use LaTeX to make my trees—the qtree package for simple trees, and xyling for anything more complicated like prosodic structures, Hasse diagrams, etc. For detailed instructions and links, see the LyX Wiki for Linguists. This page explains not only how to do syntax trees but also how to draw moraic structures, how to include IPA in a syntax tree, and so on.

Standalone applications

There are several standalone programs, both webapps and desktop apps, that you can use to enter tree structures, and they will render the structures as pictures for you. I like  phpSyntaxTree: Given the input [S [NP [N Trees]] [VP [V grow] [PP in apps]]], this produces a PDF with the following image.

php syntax tree demo

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

It also supports Unicode now so you can use IPA in your trees as well as have math symbols in your labels.

For desktop apps specific to your OS, do a search–there is definitely stuff out there for Windows and Macs, although there may no longer be support for the apps because they tend to be a labor of love sort of thing.

The Fingerpainting Method

In Libre Office, Microsoft Office, and no doubt other programs, you can draw the trees by tabbing the words into position and adding the lines using the line drawing tool. Here is what I got when I did this in Libre Office. (In order to make it look like that, I had to individually right-click on every line and change the color to black, because it defaults to blue and I couldn’t stand that and I could not be assed to figure out where the defaults are.) So, as you can see, the method is slow and ugly, but it has some benefits.

libre office line drawn tree

  1. It works when you do not have an internet connection.
  2. The tree is entirely contained in your document and uses the same fonts as your text, so even though you get an ugly tree, the fonts match
  3. There is no need to worry about embedding fonts in your PDF file, unlike the Arboreal method (next).
  4. You do not have to learn even the rudimentary bracketing syntax that phpSyntaxTree and others require, so if you are really afraid of any sort of structure and notations, this method is for you. Then again, if you are this afraid of structure, you should probably give up because linguistics might not be for you.

 

 

 

Arboreal and Moraic

This is an old approach to drawing trees. You tab or space your words into position and switch to the font, which provides characters that look like lines at different angles. There’s a triangle or two. The output looks more consistent than the fingerpainting method above. Notice that the screenshot on the right has the red spellchecker underline–it’s because the lines are actually characters, and the LibreOffice spellchecker treats them as (ill-formed) text. The red lines would not be visible in the PDF.

 

 

 

 

 

This method has many downsides, however.

  1. The fonts are proprietary and cost $20 each.
  2. These predate Unicode so modern computers don’t know what to do with them unless they have been converted to pictures first. So these fonts need to be explicitly embedded in the PDF or else they render as capital Gs, etc.
  3. The limitations of the characters restrict what types of trees you can draw—for example, the triangles only come in a few sizes.
  4. I spent about 10 minutes henpecking around the keyboard looking for the right characters to show you, and the font kept switching back to the default text font. The key map on my OS did not even know how to render these characters, so I was flying blind.

 

Comments Off on Drawing linguistic structure trees

Filed under international phonetic alphabet, trees, tutorials

International Phonetic Alphabet fonts and keyboards

Introduction

This page explains how to set up International Phonetic Alphabet IPA fonts and keyboard layouts on your computer.

Keyboard layouts allow you to enter IPA fonts directly by hitting key combinations, as explained below. I work with the IPA a lot, so I find  keyboard entry indispensable.

Which font to get?

  • Most modern computers should already have some fonts that can display IPA characters. But what you sometimes see is some characters appearing in a different font than the rest of the text, like this:

lucida_grande_switch

  • This is because many fonts only have a partial Unicode character set, which covers the standard (Latin alphabet) ASCII set but not much more. Your computer will substitute a more comprehensive font if its default font lacks the IPA characters. On Mac OS, this is Lucida Grande, for example.
  • I like Linux Libertine and Linux Biolinum. The fonts are freely distributed under a GNU Public License, and they work on any OS.

libertine

  • Another popular font is Doulos SIL. See the SIL webpage for details. I think it’s kind of ugly.

How to use the fonts: Web interface

  • This is the slow but universal way. It even works on iOS and Android.
  • Go to ipa.typeit.org. You can point and click on any IPA symbol with your mouse or finger, and the character will appear in the text box.
  • From there, you can copy and paste the transcriptions into your document writing program, then change the font of the doc to Linux Libertine if you like, and you’re done.

IPAtypeit

OS-specific Methods

These are much faster and more efficient. Invest some time into learning them and you will save yourself time in the long run.

Windows

  • Check out this page, ipa4linguists. It explains how to use the Character Map, and also covers the various quirks of Windows.
  • I found one IPA keyboard layout for Windows. I cannot vouch for this thing, but if it works, that is by far the most efficient way of working with IPA fonts (see the next section on Macs).

Mac OS

The IPA-SIL keyboard layout

  • These instructions should be current as of Mac OS 10.8x and 10.9x.
  • I use the IPA-SIL keyboard layout, which I am providing it for download here since SIL is no longer distributing or supporting it. The zip file includes a PDF with more detailed documentation.
  • The keyboard layout allows you to type in IPA without using “dead keys” (keystroke sequences that turn into a single character, for example, typing “i” and then “=” gives you “ɪ”). Ain’t nobody got time for that.
  • Here is the workflow:
    • hitting Cmd+Space switches the input method from English to IPA-SIL.
    • Once in IPA-SIL mode, you can type normal lowercase Latin characters without doing anything.
    • If you press the Shift key while typing s, i, f, d, t, q, n, you get  ʃ, ɪ, ɤ, ɾ, ð, θ, æ, ŋ respectively (The keyboard map shows you which keys do what, though you do not need to use the keyboard map to enter the keys):

What your keyboard will type in IPA-SIL when "Shift" is depressed

What your keyboard will type in IPA-SIL when “Shift” is depressed

  • Pressing Alt+Shift accesses these:

Alt+Shift on the IPA-SIL keyboard layout

Alt+Shift on the IPA-SIL keyboard layout

  • And Alt alone accesses these:

Alt on the IPA-SIL keyboard

  • For anything else, you can use the Character Viewer on Mac OS. Just open it from your Input Methods menu (which can be enabled from Settings>Keyboard).

Installing the IPA-SIL Keyboard

  • There are more detailed instructions in the PDF inside the zip file linked above.
  • The basic procedure is:
    • put the IPA-SIL.keylayout file into Users/yourusername/Library/Keyboard Layouts. Put the IPA-SILicns icon file there as well.
    • then enable the IPA-SIL keyboard by going to Settings>Language & Text > Input sources. Scroll down the long list of keyboards until you see IPA-SIL; if you don’t see it, you might need to restart the machine. Then check it.
    • Check on “Show input menu in menu bar”.
  •  Mac OS likes to take away features, especially ones that allow you to customize the system. If you cannot see the Library folder inside your Users/yourusername directory, go to your favorite search engine and look for the solution that is specific to your version of Mac OS.

Linux

  • The only method I was able to get going on Linux is ipa-x-sampa. It’s reasonably user-friendly and does not require a million steps that result in failure, like SIL’s Keyman thing. In order to use ipa-x-sampa, you need to enable IBus, and then
    apt install ibus-table-ipa-x-sampa

    If that fails, there is also Character Map type thing that you can use.

  • For some non-IPA characters that linguists use, it was suprisingly difficult to figure out how to enter them on Linux. The crucial bit (on Linux Mint, anyway, but probably others too) is to enable a “Compose Key” in your keyboard layout. Go to Preferences>Keyboard>Layouts, select “English (US)”, then Options, then find “Position of Compose Key”. I chose Caps Lock for mine. What this does is allow you to type various characters like é and ü by pressing the Compose Key together with ‘ or “, etc. A list of all the default key combinations enabled in Linux can be downloaded as a tab-separated text file here.

iOS and Android

  • Go to your “App store” or whatever and search for “IPA keyboard”, or “IPA phonetics”.

Comments Off on International Phonetic Alphabet fonts and keyboards

Filed under international phonetic alphabet, tutorials

Praat tutorial

Introduction

  • Praat is a freely available program written by Paul Boersma and David Weenink.
  • It is primarily intended for acoustic analysis of speech, but it has some additional functions such as speech synthesis and some constraint-based grammar learners. It can even run some basic perceptual experiments.
  • The program is very powerful and has many features, with new ones being added all the time. There are only a few features that a beginning phonetician would need; this tutorial covers them.

Installing Praat

  • Go to http://www.fon.hum.uva.nl/praat/ and follow the instructions for your operating system.
  • Mac users–drag the Praat.app file into your Applications folder. You may then add a link to the program onto your dock so you can enjoy looking at this icon every day. [EDIT 2020/2021: it is with great sadness that I learned that Praat authors finally changed the icon. It still has a mouth and an ear, though. I am keeping this here for historical reasons. It’s too important.]

Praat

  • Not enough space on your disk? This is an issue that Chrome OS users sometimes report. (Chrome OS stores everything in the cloud so the machines often have very little physical storage.)
    • Try to free up space on your machine. I would start with your browser’s data, which can be huge.
    • Chrome OS runs Praat inside a Linux installation, which you might already have. If not, see the instructions here for how to do it.
    • My Linux installation of Praat is 25MB, plus another 25 for the no-GUI version (my installation is on Linux Mint, not inside Chrome OS, so your mileage might vary).

Praat basics

The two windows

  • When you open Praat, two windows appear: the Objects window and the Picture window. You won’t need the Picture window most of the time, so close it. We’ll come back to it at the end of this tutorial.
  • The Objects window starts out empty, but once you open sound files and manipulate them, it will contain sounds, spectrograms, text grids and any other objects that you work with:

The Praat object window on a Mac.

The Praat object window on a Mac.

  • Important: the objects in the Object window are temporary and only exist in Praat’s working memory. If you change the content of an audio file using Praat, it won’t automatically save the changes. If you try quitting without saving the objects, Praat will prompt you to do so.

Opening, playing, recording, and editing audio files in Praat

Opening an existing sound file

  • Open Praat, click on “Open”, then “Read from file”. You will see a “Sound” object appear in the window, which you can then “View and Edit”.
  • In Mac OS, you can also drag your audio file or files onto the Praat icon. All of the files will then appear as sound objects in the list at once. See if your OS supports drag-and-drop opening of files.
  • Depending on the length of the recording, you will see either the waveform with an empty window below it or a waveform above the spectrogram.

Converting stereo to mono

  • If you are seeing two waveforms, your file is in stereo (was recorded with two microphones):

stereo_waveform

The two lines of black squiggles labeled “Channel 1” and “Channel 2” are your two stereo channels.

mono_waveform

Here, we extracted just one channel (the top one, recorded with the “left” microphone). Now we have a mono sound.

  • For speech analysis, you do not need stereo, since the vast majority of humans have only one mouth.
  • To get a mono file, you can extract one of the audio channels, like this:
  1. Return to the Objects window.
  2. Select the stereo Sound object.
  3. Click on “Convert”.
  4. Select “Extract one channel”. Unless the two channels are really different from each other, you can just accept the default, “1/left” channel.
  5. The new object will have the same name as the old but with “_ch1” appended at the end. Don’t forget to save it if you want to use it again.

Recording an audio file right into Praat

  • You can record right into Praat, as long as your computer has a built-in microphone. Most likely the recording will not be of awesome quality, but it’s fine for practicing with the program.
  • To record a sound, click on “New>Record Mono Sound”, and hit “Record” in the window that opens. You can accept all the defaults in that window.
  • One tip about recording: if you are using your laptop, you might not know exactly where the microphone is on it. I have no idea where the mic is on my laptop, actually. I just leaned in and talked close to the laptop. Here is the resulting recording of me saying a sentence in Russian, [napʲisənə lʲdotʲexnʲikə pʲatʲ ras] “The word ‘ice technology’ is written five times.”

ljdotexnika_me

A waveform and spectrogram of a sentence I recorded straight into my MacBook Air using Praat.

Recording: a note about clipping

  • When you record audio for speech analysis, you want the signal to be as loud as possible without exceeding the range of your microphone’s sensitivity.
  • Look at the black number in the upper left-hand corner of the screen, next to the waveform. Your recording should get as close to 1 as possible, but the waveform should not protrude above it. If the amplitude of the recording exceeds the range of the microphone, you get clipping.
  • A clipped recording is missing parts of the signal, and it sounds awful. Avoid.
  • Here is what clipping looks and sounds like. I had to pretty much yell at my laptop to get this to happen, so you’ve been warned. Your Praat recording widget has a meter display that stays green while you’re in good range and turns red when you are in the clipping range.

The last "clipping" is clipped. See how the waveform extends outside the waveform window?

The last “clipping” is clipped. See how the waveform extends outside the waveform window?

Playing audio

  • Once you have a Sound object, you could just hit “Play”. Usually, we want to play only portions of a file, sometimes repeatedly as we try to transcribe or determine the boundaries of a segment.
  • To play portions of a file, click on “View & Edit”, and make a selection with your mouse.
  • The playback options are in the “View” menu. Yep. I actually had to look for this just now because I usually play back the selection using the Tab key. Tab will also stop playback. Shift+Tab plays the visible window.
  • For Mac users: I’ve used a Mac for over a decade now but I still cannot keep track of the little symbols that apps use for keys. Here is a reference.

Editing a file

  • There are many things you can do to edit a file. Perhaps the most basic function, and one that you might find useful long after this class ends, is to cut out parts of a file.
  • First, open the Sound object of your file in the View & Edit window.
  • Make a selection you want to keep, using the mouse.
  • If you want to make a really neat cut, you can “Move start of selection to nearest zero crossing”–this is an option at the bottom of the “Select” menu. Then do the same for the end of the selection. What this will do is adjust the selection so that it starts and ends with a silence (zero amplitude).
  • Then click on “File”, and you have several options here.
    • You can put the selected sound into its own sound object, if you want to keep doing things to it (“Extract selected sound”, either preserving the time markings from the original file or resetting them to zero seconds).
    • You can also save the file to disk. There is a range of options, but a .WAV extension is the basic one.
  • The options above do not alter the original file or the Sound object in Praat’s memory.
  • If you want to modify the Sound object or the file, you can cut a portion of it out–useful if you have a long period of silence, or if you want to make someone say “got” instead of “Scott” or whatever. This is done via “Edit>Cut”.
  • Once you cut a portion out, it is placed on your clipboard (computer’s working memory); if you then save the Sound object to the original file again, the file will be permanently altered. If you do not want that, save it under a new name instead.
  • You’ll see other options in the menus, which are more or less self-explanatory. Feel free to play around with them, and remember that nothing is permanent until you save to disk.

Viewing spectrograms, pitch tracks, formants

  • Praat can only display spectrograms for relatively small chunks of audio, so if you want to see a spectrogram for a word, zoom in on it.
  • You can select a part of the recording with the mouse, and then use the View menu to zoom to that selection. The View menu is fairly self-explanatory.
  • There are keyboard shortcut hints in the View menu and many other places in Praat! Use them. I use Cmd+N to view the selections on Mac OS.
  • Here is a waveform and a spectrogram of a female Russian speaker (not me) saying [napʲisənə lʲdotʲexnʲikə pʲatʲ ras] “The word “ice technology” is written five times.” This sentence is a bit over 2 seconds long.

ljdotexnika_spectrogram

A waveform and a spectrogram of a 2-second Russian sentence.

Making a spectrogram look good

  • If you are working with a fresh install of Praat, your spectrograms most likely will look a lot more gray than the ones you see above. This is because the dynamic range is set very high in Praat by default–at 70 db. You want something like 30-50 for a recording that has some background noise.
  • The obligatory metaphor: Dynamic range refers to how low the cut-off is for the volume of frequencies that the spectrogram visualizes. The lower the number, the less you see. Think of it as taking pond water out of a bucket. The deeper you dip, the more muck you’ll scoop up. If your pond (=recording) is very clean, then you can dip pretty low (i.e., have a high number dynamic range). If your pond is mucky and dirty, then you better skim from the top (i.e., have a low number in your dynamic range).
  • Of course, just because you are skimming from the top doesn’t mean you have clean water. Here is what the laptop audio I recorded looks like with the defaults. You can clearly see two bands of air conditioner noise, the lower of which is around 2400 Hz. This kind of noise really interferes with acoustic analysis of speech:

The same recording of me saying that "ice technology" sentence, with a default dynamic range of 70 db. The two bands of noise are from the air conditioner in the background.

The same recording of me saying that “ice technology” sentence, with a default dynamic range of 70 db. The two bands of noise are from the air conditioner in the background.

  • To set the dynamic range, click on “Spectrum>Spectrogram settings”. Change it in 5 db increments until it looks good.
  • You can also change how high the frequencies go in the spectrogram display. The default is 0-5000 Hz. You can expand it quite a bit–some fricatives have noise at frequencies above 12000 Hz.

Viewing pitch tracks, intensity, and formants

  • Pitch.
    • This is pretty simple. While you have the Sound object open, click on “Pitch>Show pitch”. You will see a curvy blue line appear in the spectrogram window.
    • In Pitch Settings, click on “drawing method” and select “speckles”. I think it looks better than Praat’s default, “automatic”.
  • Intensity.
    • Click on “Intensity>Show intensity”. A yellow line will appear in the spectrogram window.
  • Formants.
    • Praat can also show you formants, and you can probably figure out the procedure for those on your own.
    • There is one thing you will have to change in the Formant settings depending on whether you are looking at a male or female voice: the maximum formant should be set for 5500 Hz for female speakers, and 5000 Hz for male ones.
    • These formant dots are estimated by Praat; you cannot always trust them.
  • Pulses.
    • This method visualizes glottal pulses that show up in voicing. If you turn “view pulses” on, you’ll see vertical blue lines wherever Praat thinks the glottal pulses occur.
  • Here is the Russian word [bʲitonəmʲiʂalkə] ‘concrete mixer’ with the pitch track, intensity, formants, and pulses turned on. You would rarely need to see all of these things at once, this is just for demonstration.

betonomeshalka

Pitch track: blue line, intensity: yellow line/green numbers, formants: red dots, glottal pulses: blue vertical lines in the waveform window.

Annotating an audio file with TextGrids

  • A TextGrid object allows you to mark certain periods or time points in a sound file.
  • You can have several tiers in a TextGrid: one to mark word boundaries, another to mark consonants, vowels, whatever you want.
  • You can type into the TextGrid using IPA fonts. See this page for more information on how to set up your computer so that you can do this painlessly and quickly.
  • Praat distinguishes between “point tiers” and interval tiers.
  • To create a TextGrid, start from the Objects window. Select your sound object and click on the “Annotate” button to the right.
  • You’ll see this window. Why the program suggests “Mary John bell” as the default tier names is a mystery to me.

Default TextGrid dialog

Default TextGrid dialog

  • You can either name all your tiers at once, as shown here, or name the first one and add more later.
  • I named my three tiers “word, segments, vowels”–you see them in the screenshot below.
  • Now comes one of the Praat gotchas: “View & edit with sound” is highlighted, and you would think that this would allow you to view your sound file and edit the TextGrid at the same time, but no. Clicking on that button just tells you that in order to do what you want to do, you have to select both the sound and the TextGrid in the objects window and click on the “View & Edit” button.
  • You can select the TextGrid and Sound objects with the mouse or with your keyboard keys. On a Mac, Shift + arrow (up, down) will let you select two adjacent objects in the window.
  • If you have more than one object in the list, make sure you select the TextGrid that goes with your sound file!
  • Once you are in TextGrid edit mode, you can add text on tiers, copy interval boundaries from one tier to another, and navigate between tiers and between intervals using either the mouse or just your keyboard–make sure to poke around the “Select”, “Interval”, and “Boundary” menus to see all the options.

textgrid

A TextGrid with three interval tiers, labeled in the International Phonetic Alphabet.

  • Make sure you save your TextGrid when you are done. By default, the TextGrid will be given the same name as your sound file, and the extension is .TextGrid.
  • Advanced note for the computationally curious: open a TextGrid in a text editor such as TextWrangler, and you’ll see that it’s just a Unicode text file with detailed information about the time points when a tier begins and ends, and its label and type. It looks like this:
File type = "ooTextFile"
Object class = "TextGrid"

xmin = 0 
xmax = 1.2121237048836804 
tiers? <exists> 
size = 3 
item []: 
    item [1]:
        class = "IntervalTier" 
        name = "word" 
        xmin = 0 
        xmax = 1.2121237048836804 
        intervals: size = 2 
        intervals [1]:
            xmin = 0 
            xmax = 1.1468403366828597 
            text = "bʲitonəmʲiʂalkə" 
        intervals [2]:
            xmin = 1.1468403366828597 
            xmax = 1.2121237048836804 
            text = "" 
  • Can you guess what “xmin” and “xmax” refer to, and how you might collect information about interval duration automatically by script? More on that below.

That Picture window

  • Finally, we get to the mysterious Picture window. The point of the Picture window is to make professional, publication-quality images from your spectrograms, waveforms, and whatever other aspect of speech that you use Praat to visualize.
  • Whenever you see a “Draw” or “Paint” option associated with an object, it refers to the Picture window.
  • For example, open a sound file and click on the Spectrum menu–you’ll see “Paint visible spectrogram” as an option. The same “paint” option is available for intensity, pitch, formants, and other views.
  • To make a spectrogram picture with a pitch track overlaid on top, I “painted the visible spectrogram” and then “painted the visible pitch” while unchecking the “erase first” box. This superimposes the pitch track on top of the spectrogram picture.
  • Poke around the menus, check out the options, and see what “Garnish” does.

picture_window_editing

Screen shot of the picture window in action

betonomeshalka

A nice picture of the word [bʲitonəmʲiʂalkə], with a speckled pitch track superimposed in black.

Beyond basics

  • To get a sense of the full power of this program, you can just look at the various collections of Praat scripts that people have made available.
  • Praat uses its own scripting language, which is based on the commands in the program’s menus.
  • You can automate a lot of tasks:
    • Record a word list, cut it up into smaller files at silences automatically and label all the smaller files from a text file you specify.
    • Normalize the intensity of a bunch of different audio files, so they all sound approximately equally loud
    • If you have to label a lot of audio files, you can automate opening and TextGrid creation.
    • You can also automate the collection of durations, intensities/pitch at various time points, Praat-estimated formant values, and so on.
  • To get a sense of all the options, do a web search for “Praat scripts”. I really like Mietta Lennes’ page, but there are many others, such as this Google Sites archive.
  • There is also the actual Praat Help, which you can search.

Comments Off on Praat tutorial

September 3, 2016 · 14:53