From a36206bdd16e5370ebf3daf9f2392855aab135d5 Mon Sep 17 00:00:00 2001 From: quillotm Date: Fri, 20 Aug 2021 12:21:33 +0200 Subject: [PATCH] Add needed functionalities to generate utt2spk and utt2char files --- volia/skyrim.py | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/volia/skyrim.py b/volia/skyrim.py index ec82b2f..cb73763 100644 --- a/volia/skyrim.py +++ b/volia/skyrim.py @@ -29,7 +29,29 @@ def lst2wav(lst: str, root: str, outfile: str): full_path = os.path.join(root, language, "wave-audio", wav) f.write(f"{id_} {full_path}\n") - pass + + +def utt2spk(lst: str, outfile: str): + lst_ = read_lst(lst) + + with open(outfile, "w") as f: + for id_ in lst: + splited = id_.split(",") + spk_id = splited[0] + "-" + splited[1] + f.write(id_ + " " + spk_id + "\n") + + +def utt2char(lst: str, outfile: str): + lst_ = read_lst(lst) + + with open(outfile, "w") as f: + for id_ in lst: + splited = id_.split(",") + char_id = splited[1] + f.write(id_ + " " + char_id + "\n") + + +def utt2char(): pass @@ -44,12 +66,24 @@ if __name__ == '__main__': parser_lst2wav.add_argument("--outfile", type=str, help="output wav.scp-like file") parser_lst2wav.set_defaults(which="lst2wav") + parser_utt2spk = subparsers.add_parser("utt2spk", help="generate utt2spk file") + parser_utt2spk.add_argument("--lst", required=True, type=str, help="list file .lst") + parser_utt2spk.add_argument("--outfile", required=True, type=str, help="utt2spk output file") + parser_utt2spk.set_defaults(which="utt2spk") + + parser_utt2char = subparsers.add_parser("utt2char", help="..") + parser_utt2char.add_argument("--lst", required=True, type=str, help="list file .lst") + parser_utt2char.add_argument("--outfile", required=True, type=str, help="utt2char output file") + parser_utt2char.set_defaults(which="utt2char") + # Parse args = parser.parse_args() # Run commands runner = SubCommandRunner({ - "lst2wav" : lst2wav + "lst2wav" : lst2wav, + "utt2spk": utt2spk, + "utt2char": utt2char }) runner.run(args.which, args.__dict__, remove="which") -- 1.8.2.3