{"id":13741544,"url":"https://github.com/FieldDB/PraatTextGridJS","last_synced_at":"2025-05-08T21:34:19.120Z","repository":{"id":15991405,"uuid":"18734584","full_name":"FieldDB/PraatTextGridJS","owner":"FieldDB","description":"A small library which can parse TextGrid into json and json into TextGrid","archived":false,"fork":false,"pushed_at":"2021-12-14T14:30:29.000Z","size":183,"stargazers_count":11,"open_issues_count":3,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-12T09:29:48.092Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FieldDB.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-13T17:04:35.000Z","updated_at":"2023-02-17T22:34:11.000Z","dependencies_parsed_at":"2022-08-31T09:40:16.415Z","dependency_job_id":null,"html_url":"https://github.com/FieldDB/PraatTextGridJS","commit_stats":null,"previous_names":["opensourcefieldlinguistics/praattextgridjs"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FieldDB%2FPraatTextGridJS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FieldDB%2FPraatTextGridJS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FieldDB%2FPraatTextGridJS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FieldDB%2FPraatTextGridJS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FieldDB","download_url":"https://codeload.github.com/FieldDB/PraatTextGridJS/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224774886,"owners_count":17367816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T04:01:00.148Z","updated_at":"2024-11-15T11:31:26.277Z","avatar_url":"https://github.com/FieldDB.png","language":"JavaScript","readme":"[![Build Status](https://travis-ci.org/OpenSourceFieldlinguistics/PraatTextGridJS.png)](https://travis-ci.org/OpenSourceFieldlinguistics/PraatTextGridJS)\n# textgrid\n\nA small library which can parse TextGrid into json and json into TextGrid\n\n## Getting Started\n### On the server\nInstall the module with: `npm install textgrid --save`\n\n```javascript\nvar textgrid = require('textgrid');\nconst fs = require('fs')\n\nvar sampleUtterancesTextGrid = fs.readFileSync('./test.TextGrid', {\n  encoding: \"UTF-8\"\n});\nvar json = textgrid.TextGrid.textgridToJSON(sampleUtterancesTextGrid)\nconsole.log(json)\n```\n\n### In the browser\n\nInstall the module with: `bower install textgrid --save` or,\n \nDownload the [production version][min] or the [development version][max].\n\n[min]: https://raw.github.com/OpenSourceFieldlinguistics/PraatTextGridJS/master/dist/textgrid.min.js\n[max]: https://raw.github.com/OpenSourceFieldlinguistics/PraatTextGridJS/master/dist/textgrid.js\n\nIn your web app:\n\n```html\n\u003cscript src=\"bower_components/textgrid/dist/textgrid.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  var textgridAsJson = TextGrid.textgridToIGT(originalTextGridAsText);\n\u003c/script\u003e\n```\n\nIn your code, you can attach textgrid's methods to any object.\n\n```html\n\u003cscript\u003e\nvar exports = Bocoup.utils;\n\u003c/script\u003e\n\u003cscript src=\"bower_components/textgrid/dist/textgrid.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\nvar textgridAsJson = Bocoup.utils.textgridToIGT(originalTextGridAsText); // \"init\"\n\u003c/script\u003e\n```\n\nAn example of what you can do with the result.\n\n```js\nvar textgrid = TextGrid.textgridToIGT(text);\nif (textgrid.isIGTNestedOrAlignedOrBySpeaker.probablyAligned) {\n\tfor (itemIndex in textgrid.intervalsByXmin) {\n\t\tif (!textgrid.intervalsByXmin.hasOwnProperty(itemIndex)) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (textgrid.intervalsByXmin[itemIndex]) {\n\t\t\trow = {};\n\t\t\tfor (intervalIndex = 0; intervalIndex \u003c textgrid.intervalsByXmin[itemIndex].length; intervalIndex++) {\n\t\t\t\tinterval = textgrid.intervalsByXmin[itemIndex][intervalIndex];\n\t\t\t\trow.startTime = row.startTime ? row.startTime : interval.xmin;\n\t\t\t\trow.endTime = row.endTime ? row.endTime : interval.xmax;\n\t\t\t\trow.utterance = row.utterance ? row.utterance : interval.text.trim();\n\t\t\t\trow.modality = \"spoken\";\n\t\t\t\trow.tier = interval.tierName;\n\t\t\t\trow.speakers = interval.speaker;\n\t\t\t\trow.audioFileName = interval.fileName || audioFileName;\n\t\t\t\trow.CheckedWithConsultant = interval.speaker;\n\t\t\t\tconsultants.push(row.speakers);\n\t\t\t\trow[interval.tierName] = interval.text;\n\t\t\t\theader.push(interval.tierName);\n\t\t\t}\n\t\t\tmatrix.push(row);\n\t\t}\n\t}\n} else {\n\tfor (itemIndex in textgrid.intervalsByXmin) {\n\t\tif (!textgrid.intervalsByXmin.hasOwnProperty(itemIndex)) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (textgrid.intervalsByXmin[itemIndex]) {\n\t\t\tfor (intervalIndex = 0; intervalIndex \u003c textgrid.intervalsByXmin[itemIndex].length; intervalIndex++) {\n\t\t\t\trow = {};\n\t\t\t\tinterval = textgrid.intervalsByXmin[itemIndex][intervalIndex];\n\t\t\t\trow.startTime = row.startTime ? row.startTime : interval.xmin;\n\t\t\t\trow.endTime = row.endTime ? row.endTime : interval.xmax;\n\t\t\t\trow.utterance = row.utterance ? row.utterance : interval.text.trim();\n\t\t\t\trow.modality = \"spoken\";\n\t\t\t\trow.tier = interval.tierName;\n\t\t\t\trow.speakers = interval.speaker;\n\t\t\t\trow.audioFileName = interval.fileName || audioFileName;\n\t\t\t\trow.CheckedWithConsultant = interval.speaker;\n\t\t\t\tconsultants.push(row.speakers);\n\t\t\t\trow[interval.tierName] = interval.text;\n\t\t\t\theader.push(interval.tierName);\n\t\t\t\tmatrix.push(row);\n\t\t\t}\n\t\t}\n\t}\n}\n\n```\n\n## Documentation\nhttp://opensourcefieldlinguistics.github.io/FieldDB/\n\n## Examples\nSee tests directory for more ways to use the library\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n_The \"dist\" subdirectory files are generated via Grunt. You'll find source code in the \"lib\" subdirectory!_\n\n## Release History\n* v1.102.3 April 22 2014 Long audio import support \n* v2.2.0 April 22 2014 Support for multiple small files each corresponding to an utterance \n\n\n## License\nCopyright (c) 2014 OpenSourceFieldLinguistics Contribs  \nLicensed under the Apache 2.0 license.\n","funding_links":[],"categories":["Software"],"sub_categories":["Utilities"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFieldDB%2FPraatTextGridJS","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFieldDB%2FPraatTextGridJS","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFieldDB%2FPraatTextGridJS/lists"}