#!/usr/bin/perl
# extract text from Praat TextGrids, ignoring the "noise" tier and following "notes" tier
# written by Pavel Vondricka <Pavel.Vondricka@ff.cuni.cz> for Sound2Sense project

$proc=1;

while (<>) {
	# Start processing again at the beginning of each new TextGrid
	$proc = 1 if /^File type =/;
	next unless $proc;
	# Skip noise and (the following) notes tier
	$proc = 0 if /name = "noise"/;
	# extract only lines with the text
	next unless /text =/;
	# cut out only the text (contents)
	s/text = "//g;
	s/"//g;
	s/\s*//;
	print if /./;
}
