diff --git a/speach/__version__.py b/speach/__version__.py index 7206b0d..d57dec8 100644 --- a/speach/__version__.py +++ b/speach/__version__.py @@ -14,6 +14,6 @@ __issue__ = "https://github.com/neocl/speach/issues/" __maintainer__ = "Le Tuan Anh" __version_major__ = "0.1" # follow PEP-0440 -__version__ = "{}a15.post1".format(__version_major__) -__version_long__ = "{} - Alpha 15.post1".format(__version_major__) +__version__ = "{}a15.post1+geintra".format(__version_major__) +__version_long__ = "{} - Alpha 15.post1+geintra".format(__version_major__) __status__ = "3 - Alpha" diff --git a/speach/elan.py b/speach/elan.py index cb774a0..9635fe2 100644 --- a/speach/elan.py +++ b/speach/elan.py @@ -1238,6 +1238,7 @@ class Doc(DataObject): def __init__(self, **kwargs): super().__init__(**kwargs) self.properties = OrderedDict() + self.media_descriptors = [] # JMG added this self.time_order = OrderedDict() self.__tiers = [] self.__tier_map = OrderedDict() # internal - map tierIDs to tier objects @@ -1523,31 +1524,56 @@ def time_units(self, value): @property def media_url(self): + # TODO JMG: Generalize this to allow for multiple media descriptors + print(f'Use of @property media_url is deprecated as there may be more than one in a general ELAN file.') # JMG added this return self._xml_media_node.get('MEDIA_URL') @media_url.setter def media_url(self, value): # TODO: what if __xml_header_node is None? + # TODO JMG: Generalize this to allow for multiple media descriptors + print(f'Use of @media_url.setter is deprecated as there may be more than one in a general ELAN file.') # JMG added this self._xml_media_node.set('MEDIA_URL', value) @property def mime_type(self): + # TODO JMG: Generalize this to allow for multiple media descriptors + print(f'Use of @property mime_type is deprecated as there may be more than one in a general ELAN file.') # JMG added this return self._xml_media_node.get('MIME_TYPE') @mime_type.setter def mime_type(self, value): # TODO: what if __xml_header_node is None? + # TODO JMG: Generalize this to allow for multiple media descriptors + print(f'Use of @media_type.setter is deprecated as there may be more than one in a general ELAN file.') # JMG added this self._xml_media_node.set('MIME_TYPE', value) @property def relative_media_url(self): + # TODO JMG: Generalize this to allow for multiple media descriptors + print(f'Use of @property relative_media_url is deprecated as there may be more than one in a general ELAN file.') # JMG added this return self._xml_media_node.get('RELATIVE_MEDIA_URL') @relative_media_url.setter def relative_media_url(self, value): # TODO: what if __xml_header_node is None? + # TODO JMG: Generalize this to allow for multiple media descriptors + print(f'Use of @relative_media_url.setter is deprecated as there may be more than one in a general ELAN file.') # JMG added this self._xml_media_node.set('RELATIVE_MEDIA_URL', value) + @property + def time_origin(self): + # TODO JMG: Generalize this to allow for multiple media descriptors + print(f'Use of @property time_origin is deprecated as there may be more than one in a general ELAN file.') # JMG added this + return self._xml_media_node.get('TIME_ORIGIN') + + @time_origin.setter + def time_origin(self, value): + # TODO: what if __xml_header_node is None? + # TODO JMG: Generalize this to allow for multiple media descriptors + print(f'Use of @time_origin.setter is deprecated as there may be more than one in a general ELAN file.') # JMG added this + self._xml_media_node.set('TIME_ORIGIN', value) + def _update_header_xml(self, node): """ [Internal function] Read ELAN doc information from a HEADER XML node @@ -1557,6 +1583,8 @@ def _update_header_xml(self, node): # extract extra properties for prop_node in node.findall('PROPERTY'): self.properties[prop_node.get('NAME')] = prop_node.text + for media_node in node.findall('MEDIA_DESCRIPTOR'): + self.media_descriptors.append(media_node.attrib) def _add_tier_xml(self, tier_node) -> Tier: """ [Internal function] Parse a TIER XML node, create an ELANTier object and link it to this ELAN Doc @@ -1834,6 +1862,7 @@ def read_eaf(cls, eaf_path, encoding='utf-8', *args, **kwargs): def create(cls, media_file='audio.wav', media_url=None, relative_media_url=None, + time_origin=0, author="", *args, **kwargs): """ Create a new blank ELAN doc @@ -1854,6 +1883,7 @@ def create(cls, media_file='audio.wav', eaf.media_file = media_file eaf.media_url = media_url eaf.relative_media_url = relative_media_url + eaf.time_origin = time_origin eaf.date = datetime.now() if author: eaf.author = author