Skip to content

Commit

Permalink
textgrid.py was corrected to handle PointTiers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Keshet committed Aug 27, 2014
1 parent f80e8b0 commit 27ad661
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 0 additions & 2 deletions autovot/bin/auto_vot_extract_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ def textgrid2front_end(textgrid_list, wav_list, input_filename, features_filenam
continue
num_samples = wav_file.getnframes()
wav_duration = num_samples/float(wav_file.getframerate())
print "wav_duration=", wav_duration
textgrid = TextGrid()

# read TextGrid
Expand All @@ -173,7 +172,6 @@ def textgrid2front_end(textgrid_list, wav_list, input_filename, features_filenam
or (interval.mark() == definitions.vot_mark):
window_min = max(interval.xmin() + definitions.window_min, 0)
window_max = min(min(interval.xmax() + definitions.window_max, textgrid.xmax()), wav_duration)
print window_max
new_instance = Instance()
new_instance.set(wav_filename, window_min, window_max, interval.xmin(), interval.xmax())
instances.append(new_instance)
Expand Down
15 changes: 13 additions & 2 deletions autovot/bin/helpers/textgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,17 @@ def xmax(self):
def append(self, tier):
self.__tiers.append(tier)
## JosephKeshet
if self.__xmin == None:
if self.__xmin is None:
self.__xmin = tier.xmin()
else:
self.__xmin = min(tier.xmin(), self.__xmin)
## JosephKeshet
self.__xmax = max(tier.xmax(), self.__xmax)
## JosephKeshet / MS
if self.__xmax is None:
self.__xmax = tier.xmax()
else:
self.__xmax = max(tier.xmax(), self.__xmax)
self.__n += 1

def read(self, file):
Expand Down Expand Up @@ -322,7 +327,13 @@ def xmax(self):

def append(self, point):
self.__points.append(point)
self.__xmax = point.xmax()
## MS: points don't have xmax, right?
# self.__xmax = point.xmax()
if self.__xmax is None:
self.__xmax = point.time()
else:
self.__max = max(point.time(), self.__xmax)
## MS: do we then need to do this for xmin as well?
self.__n += 1

def read(self, file):
Expand Down

0 comments on commit 27ad661

Please sign in to comment.