Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Forced Alignment

49 views
Skip to first unread message

Claudia Narang

unread,
Jul 26, 2024, 10:36:10 AM7/26/24
to Parselmouth
Hi Yannick

I wanted to ask if there's a way to perform forced alignment in Praat using Parselmouth.

In Praat it can be done using the following script:
path$ = "~/Projects/something”
basename$ = “filename”
Read from file: path$ + basename$ + ".wav"
Read from file: path$ + basename$ + ".TextGrid"
selectObject: "Sound " + basename$
plusObject: "TextGrid " + basename$
View & Edit
editor: "TextGrid " + basename$
       Alignment settings: "German", "yes", "yes", "yes"
       Align interval
endeditor
Save as text file: path$ + basename$ + "_aligned.TextGrid"

Unfortunately, this approach doesn’t work when I try to run it in Python with run_file() (even after removing the View & Edit line).

I also tried various versions of the call() methods without success, e.g.:
result = call([sound,tg], "Align interval..", "German", "yes", "yes", "yes")

Is there a way to achieve forced alignment via Parselmouth?
Thank you so much for your time and effort.

Kind regards, Claudia

yannick...@gmail.com

unread,
Jul 31, 2024, 6:18:22 PM7/31/24
to Parselmouth
Hi Claudia

Sorry, that took me a while to look into, as I've never bumped into this functionality before.

So, as far as I can tell, the original command is in the editor, and has been there for a while (i.e., has not just been added recently to Praat) ? The problem is that to open/access this editor, "View & Edit" needs to be run, as the editor needs to be opened the use the "editor:" block. And as Parselmouth doesn't initialize the graphical user interface, it's not possible to open this editor. And as I haven't really bumped into such and issue before (normally, all editor window commands also exist in the main object window), I haven't thought of/implemented a workaround for this in Parselmouth.

Note that it's the same issue if I try to run the pure Praat scrip from the command line:
$ praat test.praat
Error: Cannot edit a TextGrid from batch.
Script line 7 not performed or completed:
« View & Edit »
Script “/home/yannick/test.praat” not completed.
Praat: script command <<test.praat>> not completed.
or
$ praat test.praat
Error: Editor "TextGrid the_north_wind_and_the_sun" does not exist.
Formula not run.
Script line 8 not performed or completed:
« editor: "TextGrid " + basename$ »
Script “/home/yannick/test.praat” not completed.
Praat: script command <<test.praat>> not completed.



Now, it seems Praat actually added the command to the object window, but only in a very recent version (https://www.fon.hum.uva.nl/praat/manual/What_s_new_.html says 6.4.09), and unfortunately I haven't included that version yet in Parselmouth.
What I could do, is spend a bit of time this weekend to update Parselmouth's internal Praat version this weekend. You could then download and install a pre-release version of Parselmouth 0.5.0.
Would this help you, and are you happy to then use a development version?

Kind regards
Yannick
Reply all
Reply to author
Forward
0 new messages