{ "info": { "author": "Legisign.org", "author_email": "software@legisign.org", "bugtrack_url": null, "classifiers": [], "description": "# praat-textgrids -- Praat TextGrid manipulation in Python\n\n## Description\n\n`textgrids` is a module for handling Praat TextGrid files in any format (short text, long text, or binary). The module implements five classes, from largest to smallest:\n\n* `TextGrid` -- a `dict` with tier names as keys and `Tier`s as values\n* `Tier` -- a `list` of either `Interval` or `Point` objects\n* `Interval` -- an `object` representing Praat intervals\n* `Point` -- a `namedtuple` representing Praat points\n* `Transcript` -- a `str` with special methods for transcription handling\n\nAll Praat text objects are represented as `Transcript` objects.\n\nThe module also exports the following variables:\n\n* `diacritics` -- a `dict` of all diacritics with their Unicode counterparts\n* `inline_diacritics` -- a `dict` of inline (symbol-like) diacritics\n* `index_diacritics` -- a `dict` of over/understrike diacritics\n* `symbols` -- a `dict` of special Praat symbols with their Unicode counterparts\n* `version` -- module version as string\n* `vowels` -- a `list` of all vowels in either Praat or Unicode notation\n\n## Version\n\nThis file documents `praat-textgrids` version 1.2.0.\n\n## Copyright\n\nCopyright \u00a9 2019 Legisign.org, Tommi Nieminen \n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with this program. If not, see .\n\n## Module contents\n\n### 0. Module properties\n\nBesides `textgrids.version`, which contains the module version number as string, the module exports the following properties:\n\n#### 0.1. symbols\n\n`symbols` is a `dict` that contains all the Praat special notation symbols (as keys) and their Unicode counterparts (as values).\n\n#### 0.2. vowels\n\n`vowels` is a `list` of all vowel symbols in either Praat notation (e.g., `\"\\as\"`) or in Unicode. It is used by `Interval` methods `containsvowel()` and `startswithvowel()`, so changing it, for example, adding new symbols to it or removing symbols used for other purposes in a specific case, will change how those methods function.\n\n#### 0.3. diacritics, inline_diacritics, and index_diacritics\n\n`diacritics` is a `dict` of all diacritics in Praat notation (as keys) and their Unicode counterparts (as values).\n\n`inline_diacritics` and `index_diacritics` are subsets of `diacritics`. The former are semantically diacritics but appear as inline symbols, the latter are the \u201ctrue\u201d diacritics (i.e., under- or overstrikes) that need special handling when transcoding.\n\n### 1. TextGrid\n\n`TextGrid` is a `dict` whose keys are tier names (strings) and values are `Tier` objects. The constructor takes an optional filename argument for easy loading and parsing textgrid files.\n\n#### 1.1. Properties\n\nAll the properties of `dict`s plus:\n\n* `filename` holds the textgrid filename, if any. `read()` and `write()` methods both set or update it.\n\n#### 1.2. Methods\n\nAll the methods of `dict`s plus:\n\n* `parse()` -- parse string `data` into a TextGrid\n* `read()` -- read a TextGrid file `name`\n* `write()` -- write a TextGrid file `name`\n* `tier_from_csv()` -- read a textgrid tier from a CSV file\n* `tier_to_csv()` -- write a textgrid tier into a CSV file\n\n`parse()` takes an obligatory string argument (Praat-format textgrid data) and an optional argument `binary=BOOLEAN`. If passed binary data, the argument has to be given.\n\n`read()` and `write()` each take an obligatory filename argument. `read()` can take an optional argument `binary=BOOLEAN`. Opening a binary file the argument has to be given.\n\n`tier_from_csv()` and `tier_to_csv()` both take two obligatory arguments, the tier name and the filename, in that order.\n\n### 2. Tier\n\n`Tier` is a list of either `Interval` or `Point` objects.\n\n**NOTE:** `Tier` only allows adding `Interval` or `Point` objects. Adding anything else or mixing `Interval`s and `Point`s will trigger an exception.\n\n#### 2.2. Properties\n\nAll the properties of `list`s plus:\n\n* `is_point_tier` -- Boolean value: `True` for point tier, `False` for interval tier.\n\n#### 2.3. Methods\n\nAll the methods of `list`s plus:\n\n* `concat()` -- concatenate intervals\n* `to_csv()` -- convert tier data into a CSV-like list\n\n`concat()` returns a `TypeError` if used with a point tier. It takes two optional arguments, `first=` and `last=`, both of which are integer indexes with the usual Python semantics: 0 stands for the first element, -1 for the last element, these being also the defaults.\n\n`to_csv()` returns a CSV-like list. It\u2019s mainly intended to be used from the `TextGrid` level method `tier_to_csv()` but can be called directly if writing to a file is not desired.\n\n### 3. Interval\n\n`Interval` is an `object` class.\n\n#### 3.1. Properties\n\n* `dur` -- interval duration (`float`)\n* `mid` -- interval midpoint (`float`)\n* `text` -- text label (`Transcript`)\n* `xmax` -- interval end time (`float`)\n* `xmin` -- interval start time (`float`)\n\n#### 3.3. Methods\n\n* `containsvowel()` -- Boolean: does the interval contain a vowel?\n* `startswithvowel()` -- Boolean: does the interval start with a vowel?\n* `timegrid()` -- create a grid of even time slices\n\n`containsvowel()` and `startswithvowel()` check for possible vowels in both Praat notation and Unicode but can of course make an error if symbols are used in an unexpected way. They don\u2019t take arguments.\n\n**NOTE:** At the moment there is no `endswithvowel()` as might perhaps be expected. This is a result of an early implementation bug and might get corrected in the future.\n\n`timegrid()` returns a list of timepoints (in `float`) evenly distributed from `xmin` to `xmax`. It takes an optional integer argument specifying the number of timepoints desired; the default is 3. It raises a `ValueError` if the argument is not an integer or is less than 1.\n\n### 4. Point\n\n`Point` is a `namedtuple` with two properties: `text` and `xpos`.\n\n#### 4.1. Properties\n\n* `text` -- text label (`Transcript`)\n* `xpos` -- temporal position (`float`)\n\n### 5. Transcript\n\n`Transcript` is a `str`-derived class with one special method: `transcode()`.\n\n### 5.1. Properties\n\nAll the properties of `str`s.\n\n#### 5.2. Methods\n\nAll the methods of `str`s plus:\n\n* `transcode()` -- convert Praat notation to Unicode or vice versa.\n\nWithout arguments, `transcode()` assumes its input to be in Praat notation and converts it to Unicode; no check is made as to whether the input really is in Praat notation but nothing **should** happen if it isn\u2019t. User should take care and handle any exceptions.\n\nOptional `to_unicode=False` argument inverts the direction of the transcoding from Unicode to Praat. Again, it is not checked whether input is in Unicode.\n\nWith optional `retain_diacritics=True` argument the transcoding does not remove over- and understrike diacritics from the result.\n\n## Example code\n\n import sys\n import textgrids\n\n for arg in sys.argv[1:]:\n # Try to open the file as textgrid\n try:\n grid = textgrids.TextGrid(arg)\n # Discard and try the next one\n except:\n continue\n\n # Assume \"syllables\" is the name of the tier\n # containing syllable information\n for syll in grid['syllables']:\n # Convert Praat to Unicode in the label\n label = syll.text.transcode()\n # Print label and syllable duration, CSV-like\n print('\"{}\";{}'.format(label, syll.dur))\n\n## Plans for the future\n\n* `TextGrid.read()` and `TextGrid.parse()` should analyze the file or data and automatically select either text or binary handling as needed. (After all, when parsing text files, short or long format **is** automatically recognized.)\n\n* `TextGrid.__str()__` will continue to produce long text format in the future too, but `TextGrid.write()` should be able to produce any of the three formats.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/Legisign/Praat-textgrids", "keywords": "", "license": "GPLv3", "maintainer": "", "maintainer_email": "", "name": "praat-textgrids", "package_url": "https://pypi.org/project/praat-textgrids/", "platform": "", "project_url": "https://pypi.org/project/praat-textgrids/", "project_urls": { "Homepage": "http://github.com/Legisign/Praat-textgrids" }, "release_url": "https://pypi.org/project/praat-textgrids/1.2.0/", "requires_dist": null, "requires_python": "", "summary": "Manipulation of Praat text-format TextGrids", "version": "1.2.0" }, "last_serial": 5531813, "releases": { "1.0.2": [ { "comment_text": "", "digests": { "md5": "f022fa4b6aff8e3e5a4acf6fde7aa4f2", "sha256": "1d6cb1afd37bfb1aee7b7b5427db9ba99cbd428645204bbf18671b95321862be" }, "downloads": -1, "filename": "praat_textgrids-1.0.2-py3.6.egg", "has_sig": false, "md5_digest": "f022fa4b6aff8e3e5a4acf6fde7aa4f2", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 15448, "upload_time": "2019-06-30T16:15:03", "url": "https://files.pythonhosted.org/packages/d5/ff/a524f67148ad2ac20bfc46b32abfde37126bd29345dff06e36c9228d71e0/praat_textgrids-1.0.2-py3.6.egg" }, { "comment_text": "", "digests": { "md5": "0a2998186ea123814bcdd088a5c77ac7", "sha256": "31e74681a07afcc9533b3a457e16f3ed6864c7c2fe8ef4b94b4e95463c75aaea" }, "downloads": -1, "filename": "praat-textgrids-1.0.2.tar.gz", "has_sig": false, "md5_digest": "0a2998186ea123814bcdd088a5c77ac7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8616, "upload_time": "2019-06-30T16:15:05", "url": "https://files.pythonhosted.org/packages/45/1f/982c453f32f8e5f5fa78fce62f20e852065290edb00282fd712fb26fab69/praat-textgrids-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "8b56028427add396ce8430fb5152f649", "sha256": "e3a908ad43a3164cf108158984de56117afed1214476aa1244c879d51bccb9c5" }, "downloads": -1, "filename": "praat_textgrids-1.0.3-py3.6.egg", "has_sig": false, "md5_digest": "8b56028427add396ce8430fb5152f649", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 17026, "upload_time": "2019-07-10T12:04:58", "url": "https://files.pythonhosted.org/packages/52/e6/0201d2ebcd7887013c37dff4534120ee6b0ec9be439faf6f46ef9232c0e8/praat_textgrids-1.0.3-py3.6.egg" }, { "comment_text": "", "digests": { "md5": "b952f31057cb4147c405ab47ede3e4ad", "sha256": "5201ad2c44adb07cb3a7fae3936fa44283974e2e601fd2a5624a045bef57c3b4" }, "downloads": -1, "filename": "praat-textgrids-1.0.3.tar.gz", "has_sig": false, "md5_digest": "b952f31057cb4147c405ab47ede3e4ad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9697, "upload_time": "2019-07-10T12:05:00", "url": "https://files.pythonhosted.org/packages/63/ae/0b608da96d5ae928549daffa4ef5e8db0e7ad05b1e9bef05bec7ebd1b79d/praat-textgrids-1.0.3.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "17f9e9d56f1688921d08b4714e3aa8eb", "sha256": "5af554f304712ad274387e5a556999e5797a3c6c772cc63f95790b91f6676f7f" }, "downloads": -1, "filename": "praat_textgrids-1.2.0-py3.7.egg", "has_sig": false, "md5_digest": "17f9e9d56f1688921d08b4714e3aa8eb", "packagetype": "bdist_egg", "python_version": "3.7", "requires_python": null, "size": 20012, "upload_time": "2019-07-14T19:03:58", "url": "https://files.pythonhosted.org/packages/7b/dc/7b6b02b43abb85e81aff5c08bfa250f310af0da12c0587f862c6a9a3b05f/praat_textgrids-1.2.0-py3.7.egg" }, { "comment_text": "", "digests": { "md5": "4ac5eef6dea4ccb755f4daee199ba933", "sha256": "876329cfb8a037b7222c0d77a28e625fb2bc311e815edee21212e03e7a5fa613" }, "downloads": -1, "filename": "praat-textgrids-1.2.0.tar.gz", "has_sig": false, "md5_digest": "4ac5eef6dea4ccb755f4daee199ba933", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11003, "upload_time": "2019-07-14T19:04:00", "url": "https://files.pythonhosted.org/packages/fc/15/ce5f224603105c93f43ec3d9c41a3e4b13dabfd7835bee57266466d0d6db/praat-textgrids-1.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "17f9e9d56f1688921d08b4714e3aa8eb", "sha256": "5af554f304712ad274387e5a556999e5797a3c6c772cc63f95790b91f6676f7f" }, "downloads": -1, "filename": "praat_textgrids-1.2.0-py3.7.egg", "has_sig": false, "md5_digest": "17f9e9d56f1688921d08b4714e3aa8eb", "packagetype": "bdist_egg", "python_version": "3.7", "requires_python": null, "size": 20012, "upload_time": "2019-07-14T19:03:58", "url": "https://files.pythonhosted.org/packages/7b/dc/7b6b02b43abb85e81aff5c08bfa250f310af0da12c0587f862c6a9a3b05f/praat_textgrids-1.2.0-py3.7.egg" }, { "comment_text": "", "digests": { "md5": "4ac5eef6dea4ccb755f4daee199ba933", "sha256": "876329cfb8a037b7222c0d77a28e625fb2bc311e815edee21212e03e7a5fa613" }, "downloads": -1, "filename": "praat-textgrids-1.2.0.tar.gz", "has_sig": false, "md5_digest": "4ac5eef6dea4ccb755f4daee199ba933", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11003, "upload_time": "2019-07-14T19:04:00", "url": "https://files.pythonhosted.org/packages/fc/15/ce5f224603105c93f43ec3d9c41a3e4b13dabfd7835bee57266466d0d6db/praat-textgrids-1.2.0.tar.gz" } ] }