-
Notifications
You must be signed in to change notification settings - Fork 3
/
preprocess.py
27 lines (16 loc) · 976 Bytes
/
preprocess.py
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
import argparse
from text2phonemesequence import Text2PhonemeSequence
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("--input_file", default="filelists/train.list")
parser.add_argument("--output_file", default="filelists/train.list.phonemized")
parser.add_argument("--language", default="vie-n")
parser.add_argument("--cuda", default=False, action='store_true')
parser.add_argument("--pretrained_g2p_model", default="charsiu/g2p_multilingual_byT5_small_100")
parser.add_argument("--tokenizer", default="google/byt5-small")
parser.add_argument("--batch_size", default=64)
args = parser.parse_args()
# Load Text2PhonemeSequence
model = Text2PhonemeSequence(pretrained_g2p_model=args.pretrained_g2p_model, tokenizer=args.tokenizer, language=args.language, is_cuda=args.cuda)
# Processing data
model.infer_dataset(input_file = args.input_file, output_file=args.output_file, batch_size=args.batch_size)