diff --git a/volia/masseffect.py b/volia/masseffect.py index 3cbb813..7d21669 100644 --- a/volia/masseffect.py +++ b/volia/masseffect.py @@ -78,6 +78,16 @@ def changelabels(source: str, labels: str, outfile: str): core.data.write_line(",".join(splited), data_dict[key], out=f) +def converter(file: str, outtype: str, outfile: str): + data = core.data.read_id_values(file) + + with open(outfile, "w") as of: + for key in data: + splited = key.replace("\n", "").split(",") + of.write(key.replace("\n", "") + " " + ",".join([splited[0], splited[1], splited[3]]) + "\n") + + + if __name__ == '__main__': # Main parser parser = argparse.ArgumentParser(description="...") @@ -108,6 +118,17 @@ if __name__ == '__main__': parser_changelabels.add_argument("--outfile", required=True, type=str, help="Output file") parser_changelabels.set_defaults(which="changelabels") + # Create converter + parser_converter = subparsers.add_parser("converter", help="Create converter file") + parser_converter.add_argument("--file", + type=str, + required=True, + help="File with ids from which create converter.") + parser_converter.add_argument("--outtype", type=str, choices=["complet", "kaldi"]) + parser_converter.add_argument("--outfile", type=str, required=True, help="") + parser_converter.set_defaults(which="converter") + + # Parse args = parser.parse_args() @@ -116,7 +137,8 @@ if __name__ == '__main__': "utt2char" : utt2char, "char2utt": char2utt, "wavscp": wavscp, - "changelabels": changelabels + "changelabels": changelabels, + "converter": converter }) runner.run(args.which, args.__dict__, remove="which")