Difference between revisions of "Get dur"

From Phonlab
Jump to navigationJump to search
(Created page with "<code>get_dur</code> script =================== This script illustrates basic usage of the [https://github.com/rsprouse/audiolabel <code>audiolabel</code> library]. It reads a P…")
 
Line 1: Line 1:
 
<code>get_dur</code> script
 
<code>get_dur</code> script
 
The <code>get_dur</code> script illustrates basic usage of the [https://github.com/rsprouse/audiolabel <code>audiolabel</code> library]. It reads a Praat textgrid and reports time values for labels that match a set of target labels.
===================
 
   
  +
<nowiki>
This script illustrates basic usage of the [https://github.com/rsprouse/audiolabel <code>audiolabel</code> library]. It reads a Praat textgrid and reports time values for labels that match a set of target labels.
 
 
<code>
 
 
#!/usr/bin/env python
 
#!/usr/bin/env python
   
Line 30: Line 28:
 
label.text, label.t1, label.t2, label.duration
 
label.text, label.t1, label.t2, label.duration
 
)
 
)
</code>
+
</nowiki>

Revision as of 11:21, 19 October 2015

get_dur script 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.

#!/usr/bin/env python # Simple script to measure phone durations. Usage = "meas_dur file1.TextGrid" import sys import audiolabel try: sys.argv[1] != None tg = sys.argv[1] except IndexError: raise Exception("\nUsage: " + Usage) # List of labels for which we want duration measurements. phones = ["P", "T", "K", "B", "D", "G"] print "phone\tt1\tt2\tduration" lm = audiolabel.LabelManager(from_file=tg, from_type="praat") for label in lm.tier('phone'): if label.text in phones: print "{:s}\t{:1.4f}\t{:1.4f}\t{:1.4f}".format( label.text, label.t1, label.t2, label.duration )