Extracting the stress pattern from a text

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

DrZiro
Posts: 132
Joined: Mon Feb 09, 2009 3:51 pm UTC

Extracting the stress pattern from a text

Postby DrZiro » Wed Jun 04, 2014 7:41 pm UTC

I'm planning a little research project where I make a program that takes a text and writes music for it. As a first step of this, I would need to know the syllable count and stress pattern of the text. I assume there are programs that do that, since it's also needed for decent text-to-speech, so I'd like to find something I can use. Does anyone know of such a program?

Ideally I'd like a Perl module or standalone Mac/Unix program that takes a text file and outputs a simple list of syllables with stress level, but I can make do with anything in the right direction. A start would be some kind of pronunciation lexicon in a machine-readable format, so I can at least figure out the word-level stress, and worry about the sentence-level later.

Derek
Posts: 2176
Joined: Wed Aug 18, 2010 4:15 am UTC

Re: Extracting the stress pattern from a text

Postby Derek » Wed Jun 04, 2014 9:27 pm UTC

I would imagine that the standard solution is to take the text and look it up in a prepared dictionary of pronunciations. Of course homograph disambiguation will be necessary for some words.

But I don't think you're going to be able to accurately predict the stress pattern of English words based on the spelling alone.

DrZiro
Posts: 132
Joined: Mon Feb 09, 2009 3:51 pm UTC

Re: Extracting the stress pattern from a text

Postby DrZiro » Thu Jun 05, 2014 11:02 am UTC

Yes, that's what I think too - that's presumably what a text-to-speech engine does. After that, it probably has some algorithm for determining which words are stressed, and that would be helpful here too, so we don't end up with the stress on some "the" or "and". But as long as I can find that pronunciation dictionary, it's a start.

DrZiro
Posts: 132
Joined: Mon Feb 09, 2009 3:51 pm UTC

Re: Extracting the stress pattern from a text

Postby DrZiro » Fri Jun 06, 2014 12:10 pm UTC

Progress has been made: I just stumbled upon such a pronunciation dictionary: http://www.speech.cs.cmu.edu/cgi-bin/cmudict

Now the question is just if there's something available that would let me find the sentence stress.

billy joule
Posts: 54
Joined: Tue Jun 11, 2013 7:14 am UTC

Re: Extracting the stress pattern from a text

Postby billy joule » Sun Jun 08, 2014 9:06 am UTC

How do you plan on generating the melody?

Derek
Posts: 2176
Joined: Wed Aug 18, 2010 4:15 am UTC

Re: Extracting the stress pattern from a text

Postby Derek » Sun Jun 08, 2014 9:12 am UTC

That's unlikely, sentence stress can be on almost any word. Two native speakers reading the same text may apply completely different sentence stress patterns. If you know the intended meaning of the sentence then that can narrow the range of possibilities, or if the sentence is from a poem or song you could possibly derive it from the music. But for the most part, I think it will be too ambiguous.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 14 guests