mlml / autovot

Trainable algorithm for automatic measurement of voice onset time
GNU Lesser General Public License v3.0
62 stars 20 forks source link

Universal newlines in open() commands #62

Closed msonderegger closed 10 years ago

msonderegger commented 10 years ago

A student of mine is using autovot, and got this error when she tried to use wav and textgrid files for training:

wpa168012:~ hyeyoungbang$ cd /Users/hyeyoungbang/Desktop/autovot_Kr/experiments
wpa168012:experiments hyeyoungbang$ export PATH=$PATH:/Users/hyeyoungbang/Desktop/autovot_Kr/autovot/bin
wpa168012:experiments hyeyoungbang$ auto_vot_extract_features.py --log=INFO --vot_tier sib --vot_mark H \
> config/laxTrainTgList.txt config/laxTrainWavList.txt \
> config/laxFeInput.txt config/laxFeFeatures.txt \
> config/laxFeLabels.txt tmp_dir
13:19:42.746 [auto_vot_extract_features.py] ERROR: /hyeyoungbang/Desktop/autovot/hyeyoungbang/Desktop/autovot_Kr/experiments/data/tutorialExample/train/lax/kf2./hyeyoungbang/Desktop/autovot_Kr/experiments/data/tutorialExample/train/lax/kf3./hyeyoungbang/Desktop/autovot_Kr/experiments/data/tutorialExample/train/lax/kf4./hyeyoungbang/Desktop/autovot_Kr/experiments/data/tutorialExample/train/lax/kf6./hyeyoungbang/Desktop/autovot_Kr/experiments/data/tutorialExample/train/lax/kf7./hyeyoungbang/Desktop/autovot_Kr/experiments/data/tutorialExample/train/lax/kf8./hyeyoungbang/Desktop/autovot_Kr/experiments/data/tutorialExample/train/lax/kf9./hyeyoungbang/Desktop/autovot_Kr/experiments/data/tutorialExample/train/lax/kf10/hyeyoungbang/Desktop/autovot_Kr/experiments/data/tutorialExample/train/lax/kf11/hye
...

as you can see, the issue is that the newlines in the file laxTrainWavList.txt aren't being detected. It turns out this because she saved it in an editor which used the Macintosh '\r' convention for newlines, and these open commands in auto_vot_extract_features.py only work if the textgrid_list and wav_list have '\n' newlines:

    textgrid_list = open(textgrid_list)
    wav_list = open(wav_list)

you can get around this kind of issue by using open( x.txt, 'rU') instead of open(x.txt) -- see here in the "in addition to the standard.." paragraph.

Since it will probably be common that users save their text file on a Mac or Windows text editor, should we change these lines (and any others in the .py scripts) to end in ,'rU'?

msonderegger commented 10 years ago

Done (open(x) changed to open(x, 'rU') in all .py files).