GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - FieldDB/PraatTextGridJS: A small library which can parse TextGrid into json and json into TextGrid

BranchesTags
Open more actions menu

Latest commit

 

History

31 Commits
31 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
data
data
 
 
dist
dist
 
 
lib
lib
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.jshintrc
.jshintrc
 
 
Gruntfile.js
Gruntfile.js
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
bower.json
bower.json
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

Repository files navigation

Build Status

textgrid

A small library which can parse TextGrid into json and json into TextGrid

Getting Started

On the server

Install the module with: npm install textgrid --save

var textgrid = require('textgrid');
const fs = require('fs')

var sampleUtterancesTextGrid = fs.readFileSync('./test.TextGrid', {
  encoding: "UTF-8"
});
var json = textgrid.TextGrid.textgridToJSON(sampleUtterancesTextGrid)
console.log(json)

In the browser

Install the module with: bower install textgrid --save or,

Download the production version or the development version.

In your web app:

<script src="bower_components/textgrid/dist/textgrid.min.js"></script>
<script>
  var textgridAsJson = TextGrid.textgridToIGT(originalTextGridAsText);
</script>

In your code, you can attach textgrid's methods to any object.

<script>
var exports = Bocoup.utils;
</script>
<script src="bower_components/textgrid/dist/textgrid.min.js"></script>
<script>
var textgridAsJson = Bocoup.utils.textgridToIGT(originalTextGridAsText); // "init"
</script>

An example of what you can do with the result.

var textgrid = TextGrid.textgridToIGT(text);
if (textgrid.isIGTNestedOrAlignedOrBySpeaker.probablyAligned) {
	for (itemIndex in textgrid.intervalsByXmin) {
		if (!textgrid.intervalsByXmin.hasOwnProperty(itemIndex)) {
			continue;
		}
		if (textgrid.intervalsByXmin[itemIndex]) {
			row = {};
			for (intervalIndex = 0; intervalIndex < textgrid.intervalsByXmin[itemIndex].length; intervalIndex++) {
				interval = textgrid.intervalsByXmin[itemIndex][intervalIndex];
				row.startTime = row.startTime ? row.startTime : interval.xmin;
				row.endTime = row.endTime ? row.endTime : interval.xmax;
				row.utterance = row.utterance ? row.utterance : interval.text.trim();
				row.modality = "spoken";
				row.tier = interval.tierName;
				row.speakers = interval.speaker;
				row.audioFileName = interval.fileName || audioFileName;
				row.CheckedWithConsultant = interval.speaker;
				consultants.push(row.speakers);
				row[interval.tierName] = interval.text;
				header.push(interval.tierName);
			}
			matrix.push(row);
		}
	}
} else {
	for (itemIndex in textgrid.intervalsByXmin) {
		if (!textgrid.intervalsByXmin.hasOwnProperty(itemIndex)) {
			continue;
		}
		if (textgrid.intervalsByXmin[itemIndex]) {
			for (intervalIndex = 0; intervalIndex < textgrid.intervalsByXmin[itemIndex].length; intervalIndex++) {
				row = {};
				interval = textgrid.intervalsByXmin[itemIndex][intervalIndex];
				row.startTime = row.startTime ? row.startTime : interval.xmin;
				row.endTime = row.endTime ? row.endTime : interval.xmax;
				row.utterance = row.utterance ? row.utterance : interval.text.trim();
				row.modality = "spoken";
				row.tier = interval.tierName;
				row.speakers = interval.speaker;
				row.audioFileName = interval.fileName || audioFileName;
				row.CheckedWithConsultant = interval.speaker;
				consultants.push(row.speakers);
				row[interval.tierName] = interval.text;
				header.push(interval.tierName);
				matrix.push(row);
			}
		}
	}
}

Documentation

http://opensourcefieldlinguistics.github.io/FieldDB/

Examples

See tests directory for more ways to use the library

Contributing

In 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.

The "dist" subdirectory files are generated via Grunt. You'll find source code in the "lib" subdirectory!

Release History

  • v1.102.3 April 22 2014 Long audio import support
  • v2.2.0 April 22 2014 Support for multiple small files each corresponding to an utterance

License

Copyright (c) 2014 OpenSourceFieldLinguistics Contribs
Licensed under the Apache 2.0 license.

About

A small library which can parse TextGrid into json and json into TextGrid

Resources

Readme
Apache-2.0 license
Activity
Custom properties

Stars

15 stars

Watchers

2 watching

Forks

6 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.