Difference between revisions of "Get dur"
From Phonlab
Jump to navigationJump to searchm |
m |
||
Line 14: | Line 14: | ||
sys.argv[1] != None |
sys.argv[1] != None |
||
tg = sys.argv[1] |
tg = sys.argv[1] |
||
⚫ | |||
except IndexError: |
except IndexError: |
||
raise Exception("\nUsage: " + Usage) |
raise Exception("\nUsage: " + Usage) |
||
Line 21: | Line 22: | ||
print "phone\tword\tt1\tt2\tduration" |
print "phone\tword\tt1\tt2\tduration" |
||
⚫ | |||
for label in lm.tier('phone'): |
for label in lm.tier('phone'): |
||
if label.text in phones: |
if label.text in phones: |
Revision as of 11:35, 19 October 2015
The get_dur
script illustrates basic usage of the audiolabel
library. It reads a Praat textgrid and reports time values for labels that match a set of target labels.
<nowiki>
- !/usr/bin/env python
- Simple script to measure phone durations.
Usage = "meas_dur file.TextGrid"
import sys import audiolabel
try:
sys.argv[1] != None tg = sys.argv[1] lm = audiolabel.LabelManager(from_file=tg, from_type="praat")
except IndexError:
raise Exception("\nUsage: " + Usage)
- List of labels for which we want duration measurements.
phones = ["P", "T", "K", "B", "D", "G"]
print "phone\tword\tt1\tt2\tduration" for label in lm.tier('phone'):
if label.text in phones: word = lm.tier('word').label_at(label.center) print "{:s}\t{:s}\t{:1.4f}\t{:1.4f}\t{:1.4f}".format( label.text, word.text, label.t1, label.t2, label.duration )