41 lines
1.0 KiB
Python
41 lines
1.0 KiB
Python
|
|
import argparse, json, sys, time, random
|
||
|
|
import utterance.voice
|
||
|
|
import utterance.utils
|
||
|
|
|
||
|
|
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']:
|
||
|
|
voice = utterance.voice.Voice(name=v["name"].upper(), model=v['model_dir'], tokenizer=v['tokeniser_file'], temp=float(v["temperature"]), lenght=32)
|
||
|
|
voices.append(voice)
|
||
|
|
|
||
|
|
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.utter_one()
|
||
|
|
if t != None:
|
||
|
|
t = utterance.utils.clean(t)
|
||
|
|
t = utterance.utils.format(t)
|
||
|
|
print(t)
|
||
|
|
|
||
|
|
time.sleep(4)
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == '__main__':
|
||
|
|
sys.exit(main())
|