File size: 999 Bytes
79cf5f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pathlib

import click
import tqdm


@click.command('Check if all TextGrids are generated')
@click.option('--wavs', required=True, help='Path to the segments directory')
@click.option('--tg', required=True, help='Path to the TextGrids directory')
def check_tg(wavs, tg):
    wavs = pathlib.Path(wavs)
    tg = pathlib.Path(tg)
    missing = []
    filelist = list(wavs.glob('*.wav'))
    for wavfile in tqdm.tqdm(filelist):
        tgfile = tg / wavfile.with_suffix('.TextGrid').name
        if not tgfile.exists():
            missing.append(tgfile)
    if len(missing) > 0:
        print(
            'These TextGrids are missing! There are possible severe errors in labels of those corresponding segments. '
            'If you do believe there are no errors, consider increase the \'--beam\' argument for MFA.')
        for fn in missing:
            print(f' - {fn}')
    else:
        print('All alignments have been successfully generated.')


if __name__ == '__main__':
    check_tg()