From Praat's documentation, a TextGrid object consists of a number of tiers. There are two kinds of tiers: an interval tier is a connected sequence of labelled intervals, with boundaries in between. A point tier is a sequence of labelled points.
- Read and write TextGrid files
- Supports both Long & Short TextGrid formats
- Manipulate TextGrid objects
To use [flutter_textgrid], install [flutter_textgrid] by adding it to your pubspec.yaml
file:"
For a Flutter project:
flutter pub add flutter_textgrid
For a Dart project:
dart pub add flutter_textgrid
final textGrid = TextGrid(
startTime: Time.zero,
endTime: Time(5), // 5 seconds
);
final intervalTier = IntervalTier(name: 'test');
final ia = IntervalAnnotation(
startTime: Time.zero,
endTime: const Time(0.5),
text: 'worda',
);
intervalTier.addAnnotation(ia);
textGrid.addTier(intervalTier);
First of all create a TextGridSerializer. It can read both Long and Short format, without any configurations.
final tgs = TextGridSerializer();
final tgContent = "...TextGrid...";
final textGrid = tgs.fromString(tgContent);
final tgs = TextGridSerializer();
final textGrid = tgs.fromFile(File('../path/to/file'));
// Just use your TextGrid file
or you can read directly from a path:
final tgs = TextGridSerializer();
final textGrid = tgs.fromPath('../path/to/file');
// Just use your TextGrid file
or you can use the [fromString] method.
final tgs = TextGridSerializer();
final fileContent = File('../path/to/file').readAsStringSync();
final textGrid = tgs.fromString(fileContent);
// Just use your TextGrid file