Skip to content

Manipulate Praat textgrid with NodeJS.

Notifications You must be signed in to change notification settings

WangNianyi2001/textgrid-js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

textgrid-js

This is a NodeJS package for manipulating Praat textgrid files. It is written in the ES Module style.

Installation

$ npm i @nianyi-wang/textgrid

Usage

The following code snippet shows how to iterate through certain tier in a Textgrid file and change their labels.

import { TextGrid, IntervalTier } from '@nianyi-wang/textgrid';
import * as Fs from 'fs';

// Input
const src = './input.Textgrid';
const tg = TextGrid.FromString(fs.readFileSync(src).toString());

// TextGrid manipulations
const tier = tg.tiers.get('phonemes');
function ProcessLabel(label) {
	// TODO
	return label;
}
for(const range of tier)
	tier.label = ProcessLabel(tier.label);

// Output
fs.writeFileSync(src, tg.Serialize());

Languages

  • JavaScript 77.8%
  • TypeScript 22.2%