-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
As I'm going through to make MFA compatible with v6.0, one thing that sticks out to me is that several aspects of PraatIO could be more pythonic and make it easier for integrating with other packages.
- Use PEP8 snake case rather than camel case (e.g.
Textgrid.tier_namesinstead ofTextGrid.tierNames). This might cause a bit of desync with the underlying TextGrid parameters, but it would also be nice to unifyTextGrid.minTimestamp, TextGrid.maxTimestampwithIntervalTier.minT, IntervalTier.maxT. (I'll stick to using camel case for consistency in my other thoughts) - Add magic functions to TextGrid classes
__len__solen(textgrid_object)returnslen(textgrid_object._tierDict),len(interval_tier)returnslen(interval_tier.entries)__getitem__sotextgrid_object[tier_name]returnstextgrid_object._tierDict[tier_name]andinterval_tier[0]returnsinterval_tier.entries[0]__setitem__could callTextGrid.addTierfor TextGrid andIntervalTier.insertEntryfor IntervalTier with the defaults (and if there's an error, then prompt the user to use the more fully featured function (or have a separate IntervalTier.append and IntervalTier.insert that mirrors python list functionality, though an interval doesn't necessarily have to be added at the end, but that's usually how I think about TextGrid creation)- It might be good to split
IntervalTier.insertEntryinto three functions rather than have a string switch on its behavior, so something likeIntervalTier.insertEntry, IntervalTier.mergeEntry, IntervalTier.replaceEntry, so it's easier for IDE autocompletes, easier debugging
__iter__sofor tier in textgrid_objectyields each tier intextgrid_object.tiersandfor interval in interval_tierreturns each interval ininterval_tier.entries- Use dataclasses for Intervals/Points rather than namedtuples so that they're mutable. I realize that changes to intervals have to be evaluated in the context of the tier and so that's likely why they're immutable, but I wonder if when adding intervals to a tier, you could store a reference to the tier in the interval, and then when changing any parameters of it, call the tier's validation logic? Or have a signal/slot style where every time an interval gets added, the tier connects a validation function to the interval's
dataChangedsignal.
It also might be helpful to have includeBlankSpaces default to true for exporting to textgrids (and it might also be worth breaking up the TextGrid.save method into different methods for the output format), since it's a bit of a gotcha if you try to open up TextGrids in Praat later on. Not having blank intervals was the root cause of some issues for MFA in https://twitter.com/betsysneller/status/1621607813632892929, though I don't think they were using PraatIO to generate the textgrids.
timmahrt, NickleDave and William-N-Havard
Metadata
Metadata
Assignees
Labels
No labels