diff --git a/polyglotdb/io/inspect/textgrid.py b/polyglotdb/io/inspect/textgrid.py index 7fff208..132c01b 100755 --- a/polyglotdb/io/inspect/textgrid.py +++ b/polyglotdb/io/inspect/textgrid.py @@ -82,9 +82,9 @@ def uniqueLabels(tier): label from the tier """ if isinstance(tier, textgrid.IntervalTier): - return set(x for _, _, x in tier.entryList) + return set(x for _, _, x in tier.entries) else: - return set(x for _, x in tier.entryList) + return set(x for _, x in tier.entries) def average_duration(tier): @@ -103,9 +103,9 @@ def average_duration(tier): """ if isinstance(tier, textgrid.IntervalTier): - return sum(float(end) - float(begin) for (begin, end, _) in tier.entryList) / len(tier.entryList) + return sum(float(end) - float(begin) for (begin, end, _) in tier.entries) / len(tier.entries) else: - return float(tier.maxTime) / len(tier.entryList) + return float(tier.maxTime) / len(tier.entries) def averageLabelLen(tier): @@ -168,9 +168,9 @@ def guess_tiers(tg): """ tier_properties = {} tier_guesses = {} - for i, tier_name in enumerate(tg.tierNameList): - ti = tg.tierDict[tier_name] - if len(ti.entryList) == 0: + for i, tier_name in enumerate(tg.tierNames): + ti = tg.getTier(tier_name) + if len(ti.entries) == 0: continue ti.maxTime = tg.maxTimestamp tier_properties[ti.name] = (i, average_duration(ti)) @@ -228,8 +228,8 @@ def inspect_textgrid(path): tg = textgrid.openTextgrid(t, includeEmptyIntervals=True) if len(anno_types) == 0: tier_guesses, hierarchy = guess_tiers(tg) - for i, tier_name in enumerate(tg.tierNameList): - ti = tg.tierDict[tier_name] + for i, tier_name in enumerate(tg.tierNames): + ti = tg.getTier(tier_name) if tier_name not in tier_guesses: a = OrthographyTier('word', 'word') a.ignored = True @@ -261,19 +261,19 @@ def inspect_textgrid(path): raise (NotImplementedError) if not a.ignored: if isinstance(ti, textgrid.IntervalTier): - a.add(( (text.strip(), begin, end) for (begin, end, text) in ti.entryList), save=False) + a.add(( (text.strip(), begin, end) for (begin, end, text) in ti.entries), save=False) else: - a.add(((text.strip(), time) for time, text in ti.entryList), save=False) + a.add(((text.strip(), time) for time, text in ti.entries), save=False) anno_types.append(a) else: - for i, tier_name in enumerate(tg.tierNameList): - ti = tg.tierDict[tier_name] + for i, tier_name in enumerate(tg.tierNames): + ti = tg.getTier(tier_name) if anno_types[i].ignored: continue if isinstance(ti, textgrid.IntervalTier): - anno_types[i].add(( (text.strip(), begin, end) for (begin, end, text) in ti.entryList), save=False) + anno_types[i].add(( (text.strip(), begin, end) for (begin, end, text) in ti.entries), save=False) else: - anno_types[i].add(((text.strip(), time) for time, text in ti.entryList), save=False) + anno_types[i].add(((text.strip(), time) for time, text in ti.entries), save=False) parser = TextgridParser(anno_types, hierarchy) return parser diff --git a/polyglotdb/io/parsers/aligner.py b/polyglotdb/io/parsers/aligner.py index d762073..273065e 100644 --- a/polyglotdb/io/parsers/aligner.py +++ b/polyglotdb/io/parsers/aligner.py @@ -58,20 +58,20 @@ def _is_valid(self, tg): found_phone = False invalid = True multiple_speakers = False - for i, tier_name in enumerate(tg.tierNameList): + for i, tier_name in enumerate(tg.tierNames): if ' - ' in tier_name: multiple_speakers = True break if multiple_speakers: if self.speaker_first: - speakers = {tier_name.split(' - ')[0].strip().replace('/', '_').replace('\\', '_') for tier_name in tg.tierNameList if + speakers = {tier_name.split(' - ')[0].strip().replace('/', '_').replace('\\', '_') for tier_name in tg.tierNames if ' - ' in tier_name} else: - speakers = {tier_name.split(' - ')[1].strip().replace('/', '_').replace('\\', '_') for tier_name in tg.tierNameList if + speakers = {tier_name.split(' - ')[1].strip().replace('/', '_').replace('\\', '_') for tier_name in tg.tierNames if ' - ' in tier_name} found_words = {x: False for x in speakers} found_phones = {x: False for x in speakers} - for i, tier_name in enumerate(tg.tierNameList): + for i, tier_name in enumerate(tg.tierNames): if ' - ' not in tier_name: continue if self.speaker_first: @@ -87,7 +87,7 @@ def _is_valid(self, tg): found_word = all(found_words.values()) found_phone = all(found_words.values()) else: - for i, tier_name in enumerate(tg.tierNameList): + for i, tier_name in enumerate(tg.tierNames): if tier_name.lower().startswith(self.word_label): found_word = True elif tier_name.lower().startswith(self.phone_label): @@ -130,12 +130,12 @@ def parse_discourse(self, path, types_only=False): a.speaker = speaker # Parse the tiers - for i, tier_name in enumerate(tg.tierNameList): - ti = tg.tierDict[tier_name] + for i, tier_name in enumerate(tg.tierNames): + ti = tg.getTier(tier_name) if tier_name.lower().startswith(self.word_label): - self.annotation_tiers[0].add(( (text.strip(), begin, end) for (begin, end, text) in ti.entryList)) + self.annotation_tiers[0].add(( (text.strip(), begin, end) for (begin, end, text) in ti.entries)) elif tier_name.lower().startswith(self.phone_label): - self.annotation_tiers[1].add(( (text.strip(), begin, end) for (begin, end, text) in ti.entryList)) + self.annotation_tiers[1].add(( (text.strip(), begin, end) for (begin, end, text) in ti.entries)) pg_annotations = self._parse_annotations(types_only) data = DiscourseData(name, pg_annotations, self.hierarchy) @@ -153,7 +153,7 @@ def parse_discourse(self, path, types_only=False): if n_channels > 1: # Figure speaker-channel mapping n_tiers = 0 - for i, tier_name in enumerate(tg.tierNameList): + for i, tier_name in enumerate(tg.tierNames): try: speaker, type = tier_name.split(' - ') except ValueError: @@ -161,7 +161,7 @@ def parse_discourse(self, path, types_only=False): n_tiers += 1 ind = 0 cutoffs = [x / n_channels for x in range(1, n_channels)] - for i, tier_name in enumerate(tg.tierNameList): + for i, tier_name in enumerate(tg.tierNames): try: if self.speaker_first: speaker, type = tier_name.split(' - ') @@ -181,8 +181,8 @@ def parse_discourse(self, path, types_only=False): ind += 1 # Parse the tiers - for i, tier_name in enumerate(tg.tierNameList): - ti = tg.tierDict[tier_name] + for i, tier_name in enumerate(tg.tierNames): + ti = tg.getTier(tier_name) try: if self.speaker_first: speaker, type = tier_name.split(' - ') @@ -195,11 +195,11 @@ def parse_discourse(self, path, types_only=False): type = 'word' elif type.lower().startswith(self.phone_label): type = 'phone' - if len(ti.entryList) == 1 and ti.entryList[0][2].strip() == '': + if len(ti.entries) == 1 and ti.entries[0][2].strip() == '': continue at = OrthographyTier(type, type) at.speaker = speaker - at.add(( (text.strip(), begin, end) for (begin, end, text) in ti.entryList)) + at.add(( (text.strip(), begin, end) for (begin, end, text) in ti.entries)) self.annotation_tiers.append(at) pg_annotations = self._parse_annotations(types_only) data = DiscourseData(name, pg_annotations, self.hierarchy) diff --git a/polyglotdb/io/parsers/labbcat.py b/polyglotdb/io/parsers/labbcat.py index ed2eee4..c6074ff 100755 --- a/polyglotdb/io/parsers/labbcat.py +++ b/polyglotdb/io/parsers/labbcat.py @@ -51,15 +51,15 @@ def load_textgrid(self, path): try: tg = textgrid.openTextgrid(path, includeEmptyIntervals=True) new_tiers = [] - dup_tiers_maxes = {k:0 for k,v in Counter([t for t in tg.tierNameList]).items() if v > 1} + dup_tiers_maxes = {k:0 for k,v in Counter([t for t in tg.tierNames]).items() if v > 1} dup_tiers_inds = {k:0 for k in dup_tiers_maxes.keys()} - for i, t in enumerate(tg.tierNameList): + for i, t in enumerate(tg.tierNames): if t in dup_tiers_maxes: if len(t) > dup_tiers_maxes[t]: dup_tiers_maxes[t] = len(t) dup_tiers_inds[t] = i - for i, t in enumerate(tg.tierNameList): + for i, t in enumerate(tg.tierNames): if t in dup_tiers_maxes: if i != dup_tiers_inds[t]: continue diff --git a/polyglotdb/io/parsers/textgrid.py b/polyglotdb/io/parsers/textgrid.py index 0b83c06..25d0008 100755 --- a/polyglotdb/io/parsers/textgrid.py +++ b/polyglotdb/io/parsers/textgrid.py @@ -76,7 +76,7 @@ def parse_discourse(self, path, types_only=False): """ tg = self.load_textgrid(path) - if len(tg.tierNameList) != len(self.annotation_tiers): + if len(tg.tierNames) != len(self.annotation_tiers): raise (TextGridError( "The TextGrid ({}) does not have the same number of interval tiers as the number of annotation types specified.".format( path))) @@ -92,12 +92,12 @@ def parse_discourse(self, path, types_only=False): a.speaker = speaker # Parse the tiers - for i, tier_name in enumerate(tg.tierNameList): - ti = tg.tierDict[tier_name] + for i, tier_name in enumerate(tg.tierNames): + ti = tg.getTier(tier_name) if isinstance(ti, textgrid.IntervalTier): - self.annotation_tiers[i].add(( (text.strip(), begin, end) for (begin, end, text) in ti.entryList)) + self.annotation_tiers[i].add(( (text.strip(), begin, end) for (begin, end, text) in ti.entries)) else: - self.annotation_tiers[i].add(((text.strip(), time) for time, text in ti.entryList)) + self.annotation_tiers[i].add(((text.strip(), time) for time, text in ti.entries)) is_empty_textgrid = True diff --git a/requirements.txt b/requirements.txt index 329622a..bc31ad7 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ neo4j librosa -scipy ~= 1.12.0 -praatio ~= 5.0 +scipy +praatio textgrid influxdb tqdm diff --git a/setup.cfg b/setup.cfg index 9db30a4..e43d2b7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,14 +25,14 @@ license_file = LICENSE packages = find: install_requires = neo4j - praatio<=5.0 + praatio textgrid conch_sounds librosa influxdb tqdm requests - scipy<=1.12.0 + scipy pywin32; os_name == 'nt' include_package_data = True