Notes from a Linguistic Mystic

I’d like to take a writing break to point out an absolutely killer Garden Path sentence that Ars Technica just dropped:

"Fake browser warning your uncle might fall for delivers malicious trojan"

The headline, reading “Fake browser warning your uncle might fall for delivers malicious trojan”, is a wonderful example of a Garden Path sentence, a fully grammatical sentence whose structure is misleading, and seems like it should be read one way until later in the sentence the real structure is revealed, when it’s already too late.

These have a tendency to crash human brains. Try these on for size:

  • The horse raced past the barn fell.
  • The old man the boat.
  • The headline read with difficulty failed

Those should be read as “The horse who was raced past the barn fell down”, and “The oldest people on the boat run (“man”) it”, and that last one just isn’t as rough, as we all understand that headlines cannot read.

Ars’ little Garden Path bomb is particularly spectacular. We start off thinking that there is a fake browser, which is warning us that our uncles may fall, but then the delivers hits. At this point, we think we’ve already hit the verb (“warning”), so we’re puzzled by “delivers”.

Only once we go back and read “Fake browser warning your uncle might fall for” as a single noun-phrase can we understand that this fake warning is delivering a malicious trojan.

These sentences are spectacular, and it’s fairly rare to see such a blatant example in the wild (as a Syntactician friend put it, “this one is a doozy”), so, when I saw it, I just had to comment.

Finally, I must point out that my goal isn’t to mock the author. More likely than not, the reporter worked hard missed it.

(Sorry)

~ ə ~

I’ve been too busy teaching, dissertating, and preparing for my Post-Doc to post regularly, but I just figured I’d post a quick update and respond to current events.

I’ve been running the Yosemite beta for a month or so now, and have had no problems at all. The OS is good, my previous tutorial on using IPA fonts with Mac OS X still works, my P2FA install guide still works, and Praat is good-to-go.

Putting aside the strangeness of 10.10 not being the same thing as “10.1” or just “11”, Mac OS X 10.10 “Yosemite” gets my seal of approval.

Seal of Approval

~ ə ~

I’ve just learned a wonderful term for a common state of mind: “precarious manhood”.

The authors report 5 studies that demonstrate that manhood, in contrast to womanhood, is seen as a precarious state requiring continual social proof and validation. Because of this precariousness, they argue that men feel especially threatened by challenges to their masculinity. (from this paper)

This term (and idea), first publicized by J.A. Vandello, describes the feeling that your very masculinity is always under threat, and that, much like the cooties of yore, one is liable to catch femininity from any association with the feminine (or effeminate).

I just happened upon a wonderful example of this fear in action. Below are two small pocketknives, both by Spyderco, a Colorado knifemaker:

Image from ‘dyril’ on EDCForums

They are both made of the same materials. They’re about the same size (although the bottom one is marginally bigger). They have the same function, mechanism, and overall design (although again, the bottom is slightly wider). What’s the difference, you may ask?

The top knife is a popular model from Spyderco, the “Ladybug”. The bottom is a recent addition to the lineup, called the “Manbug”.

What is a “manbug”? Google returns no results except for the knife, so it’s clearly not an insect. Well, as explained on Spyderco’s website for the Manbug:

Anyone who has ever used a LadyBug knows that it cuts with an authority far beyond its size. However, as part of Spyderco’s quest for C.Q.I. (Constant Quality Improvement), Glesser decided to make it even better. And, for anyone whose male ego made it difficult for them to carry a “LadyBug,” he also made life easier.

So, apparently, although the “Ladybug” cuts many things well, what it’s most effective at cutting is precarious masculinity, and that alone was worth a creating new product line.

I generally don’t go into gender dynamics in language, as I lack the sociological chops that some of my colleagues have (and which seem required to write about social topics without hurting yourself). But reading about the “manbug” on the same day I learned about “precarious masculinity”, I just couldn’t help myself.

~ ə ~

One of the advantages to being a linguist is that I get to see some of the strange things people do when they need “other language”, but don’t expect people to understand.

One of my favorite video games from childhood was GoldenEye 007 for the Nintendo 64. In the game, which is based (very loosely!) on the 1995 James Bond film “Goldeneye”, there’s a level set in a Soviet Archive building. All throughout there are boxes, marked with big red type with “картофель”, pronounced “car-TOE-fell” ([kar’tofʲel]).

When I was a kid, playing the game, I always assumed it meant “records”, or maybe even something cool, like “nuclear weapons” or “spies who crossed the KGB”!

Nope. картофель is the Russian word for ‘potato’. Just nice.

~ ə ~

As part of my dissertation, I’m having to record a large number of subjects and do analyses on their speech. The biggest problem with doing that is that in order to do the analyses automatically, you need to time-align the words, creating files which tell your analysis software (in this case, Praat) where each sentence/word/sound starts and ends.

The fastest way to do this automatically is using what’s called “forced alignment”, and the current best forced aligner for English for phonetic use is the Penn Phonetics Lab Forced Aligner. In this post, I’ll describe how I got it working on my Mac running Mavericks (10.9), in a step-by-step sort of way.

There are four basic steps involved: 1. Install HTK (the hard part!) 2. Install the Penn Phonetics Lab Forced Aligner (henceforth P2FA) 3. Install Sox (which is required by P2FA) 4. Set it up for your data and run it to get aligned textgrids

Disclaimer

This post is up as a public service. I’ve done my absolute best to be comprehensive and clear, but your system/install/issue may vary, and they might update any of these tools at any time, and this post may not change when they do. I’m also mid-dissertation, so I’m unable to offer personal assistance setting up P2FA to commenters or by email.

Feel free to leave a comment if you have a question or issue, and maybe somebody can help, but nothing’s guaranteed. In short, the Linguistic Mystic is not responsible for any troubles, your mileage may vary, good luck and godspeed.

Step 0.5: Xcode Command Line Tools

If you’re doing anything code-y on a Mac, you need Xcode for the compilers and other useful tools it has.

  1. Download Xcode from the Mac App Store (it’s free).
  2. Follow these instructions to install the XCode command line tools.

Step 1: Installing HTK

This is the hardest and most terrifying part if you’re not used to compiling and installing command-line tools. We’ll take it step by step, though.

The P2FA readme is very specific that you need version 3.4 of HTK, so let’s install that. The manual isn’t terribly helpful for a Mac install, so we’ll have to go this alone.

  1. Go over to http://htk.eng.cam.ac.uk and register. It’s free and only takes a minute.
  2. Download HTK 3.4 from this page. Since you’re on a Mac, grab HTK-3.4.tar.gz.
  3. On your Mac, go to wherever the file downloaded to, and double-click the .tar.gz file to expand it. This will create a folder called “htk”, and for the rest of this tutorial, I’m going to pretend it’s on your desktop.
  4. Open up Terminal.app (/Applications/Utilities/Terminal.app).
    • Any time you see a command inside a code block, that means “type the command into a terminal exactly”
  5. Enter the command cd ~/Desktop/htk
  6. Run ./configure -build=i686-apple-macos LDFLAGS=-L/opt/X11/lib CFLAGS='-I/opt/X11/include -I/usr/include/malloc'to configure the software for OS X. A major hat-tip to this post for helping me with that command.

    At this point, the HTK manual says you should be able to make all && make install. But it’s not that easy. If you run that command, you’ll get a couple of errors which look like:

    esignal.c:1184:25: error: use of undeclared identifier 'ARCH' architecture = ARCH;

    Translation: “I’m trying to prep the file HTKLib/esignal.c, but nobody told me what system architecture this code is gonna be run on. Unless I know that, I can’t build!” This is actually a problem with the way HTK is written, but luckily, we can fix it by manually specifying that the Architecture is “darwin” (which it always is, for OS X). A major hat-tip to this post for helping me figure out some of these issues.

  7. Open the HTKLib/esignal.c file in a code-friendly text editor. You can use Xcode, or my personal favorite TextMate 2.
  8. Find and change the below lines:

    Change Line 974: if (strcmp(architecture, ARCH) == 0) /* native architecture */

    To: if (strcmp(architecture, "darwin") == 0) /* native architecture */

    Change Line 1184: ` architecture = ARCH;`

    To: ` architecture = “darwin”;`

  9. Now, let’s build! Run make all in the terminal window. Some warnings will pop up, but we don’t care.

  10. Now we’ll install it. Run make install

  11. Just to test, run LMerge. It’ll pop up a message about USAGE, and that’s fine. That just tells us it installed OK.

Whew. HTK is installed. That was the tough part. Now let’s install P2FA.

Step 2: Installing Penn Phonetics Lab Forced Aligner

This part’s easier!

  1. Download P2FA.
  2. Double-click the .tgz file to open it up, giving a “p2fa” folder.
  3. Move that folder someplace easy to find.

Done!

Step 3: Installing Sox

P2FA does depend on Sox to work. The easiest way to get Sox, by far, is using Homebrew, so we’ll do that. Homebrew is a great little program for easily and quickly installing all sorts of fun commandline tools. I love it.

  1. Open your terminal back up.
  2. Run ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"(This command straight from the Homebrew Homepage)
  3. Once that’s done, install sox using brew install sox

Done!

Step 4: Setting P2FA up for your data and running it

Unfortunately, P2FA needs a particular format for your data to work. In my case, I had a bunch of files of people saying the exact same things, as prompted by a script. So, my sound files started with:

The word is men

The word is mint

… and so forth for the other 318 words which they read in the script.

To force-align data like this:

  1. Make sure that any extraneous talk is trimmed out, such that the speech actually matches the script.
  2. Create a text file which it will be aligned against. To capture the above, this file would look like:

    {SL} {NS} sp THE sp WORD sp IS sp MEN {SL} {NS} sp THE sp WORD sp IS sp MINT {SL} {NS}

    … and then goes on to do the same thing for all the other ‘the word is (word)’ sentences. The {SL} stands for “silence”, and covers the silence after they finish the sentence. The {NS} means “noise”, which is there to pick up the click of the keyboard as they advance the slide. Then, each sp (small pause) is in case the person pauses again between words. In P2FA, these “small pauses” can be present or not, and they should be sprinkled liberally throughout your data. All words need to be capitalized.

    Save the file you’ve created. I’ll call it “alignscript.txt” in other examples.

  3. Make sure that all words are included in the dictionary. It’ll yell at you at runtime if you’ve asked it to align a word which isn’t in the dictionary, so, if you’re aligning non-words (or even odd, new words), you’ll need to add them. Let’s say you want to add “neighed”:

    1. To add a new word to dictionary, open the “model” folder, and then open “dict” in your text editor.
    2. Find the line for a word which rhymes with your new word, like “made”:

      MADE M EY1 D

    3. Modify the sounds for the new word:

      NEIGHED N EY1 D

  4. Downsample the file you’re looking to align using Praat. I’ve had great luck using the suggested 11,025 Hz sampling rate. Save this as a .wav file.
    • Remember, you can always use the Textgrid with the full-quality file later, the downsampled file is just temporary for alignment.
  5. Run the aligner, modifying the paths in the command to fit where you’ve got P2FA and your data. The command is: python /path/to/align.py sound_file.wav alignscript.txt output_name.TextGrid

    So, for my actual work, if I wanted to align the recording session file for a subject named “sarah”: ~/data/p2fa/align.py ~/data/sarah_session.wav ~/data/alignscript.txt ~/data/sarah_session.TextGrid

  6. Go have coffee. For a 15 minute recording, it takes around 10 minutes for the forced aligner to run on my (fairly recent) Mac.

  7. Open up the newly-generated .TextGrid file in Praat alongside the sound file and see how it did.

P2FA in Practice

So far, I’ve been really impressed with the results. It’s pretty good, with only one major error (missed word or complete mis-identification) in every two files. Individual sounds are missed more regularly (where it’ll cut off the /z/ in “meds” or the /n/ in “plan”). Vowel boundaries are off by 10 ms or so in around 1/3 of tokens.

I’ve been hand-correcting the data because I care a lot about those boundaries, but if I just wanted a measure at the center of the vowel, I wouldn’t even bother, as the vowel’s center is quite reliably in the center of the vowel span. Regardless of these issues, using P2FA with hand-correction, I’m able to beautifully annotate data in around 1/4 of the time it takes to do it by hand. It’s an absolutely excellent tool, and would recommend it to anybody.

So, I hope this was helpful, good luck, and good alignment!

~ ə ~