import argparse, json, sys, time, random import spacy from aitextgen import aitextgen def main() -> int: p = argparse.ArgumentParser() p.add_argument("-c", "--config", type=str, default="config.json", help="configuratin file") p.add_argument("-i", "--iterations", type=int, default=10, help="number of iterations") args = p.parse_args() print(args) with open(args.config) as f: conf = json.load(f) voices = [] for v in conf['voices']: a = aitextgen(model_folder=v['model_dir'], tokenizer_file=v['tokeniser_file']) voices.append({"name": v["name"].upper(), "a": a}) nbr_voices = len(voices) current_voice = "" for i in range(args.iterations): rindex = random.randint(0, nbr_voices - 1) v = voices[rindex] if v['name'] != current_voice: print("==========") print(v['name'] + ":") current_voice = v['name'] t = v['a'].generate_one().strip() print(t) time.sleep(1) if __name__ == '__main__': sys.exit(main())