41 lines
1.1 KiB
Python
Raw Normal View History

2022-03-06 14:20:53 +01:00
import argparse, json, sys, time, random
import utterance.voice
import utterance.utils
2022-04-10 15:21:22 +02:00
2022-04-11 13:09:01 +02:00
UTTERANCE_LEN = 64 #<--------------- these should be in config
2022-03-06 14:20:53 +01:00
def main() -> int:
p = argparse.ArgumentParser()
2022-04-10 15:21:22 +02:00
p.add_argument("-c", "--config", type=str, default="voice.config.json", help="configuratin file")
2022-03-06 14:20:53 +01:00
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']:
2022-04-10 15:21:22 +02:00
model = v['model']
2022-04-11 13:09:01 +02:00
voice = utterance.voice.Voice(name=v["name"].upper(), model=model['model_dir'], tokenizer=model['tokeniser_file'], temp=float(model["temperature"]), length=UTTERANCE_LEN)
2022-03-06 14:20:53 +01:00
voices.append(voice)
2022-04-10 15:21:22 +02:00
current_voice_name = ""
2022-03-06 14:20:53 +01:00
for i in range(args.iterations):
2022-04-10 15:21:22 +02:00
v = random.sample(voices, 1)[0]
if v.name != current_voice_name:
current_voice_name = v.name
2022-03-06 14:20:53 +01:00
print("==========")
print(v.name + ":")
2022-04-10 15:21:22 +02:00
t = v.utter_one()
2022-03-06 14:20:53 +01:00
t = utterance.utils.clean(t)
t = utterance.utils.format(t)
print(t)
2022-04-10 15:21:22 +02:00
# time.sleep(1)
2022-03-06 14:20:53 +01:00
if __name__ == '__main__':
sys.exit(main())