speak simple
This commit is contained in:
parent
d70f643836
commit
19f7b8d30d
22
speak.py
22
speak.py
@ -1,11 +1,13 @@
|
||||
import argparse, json, sys, time, random
|
||||
import utterance.voice
|
||||
import utterance.utils
|
||||
|
||||
UTTERANCE_LEN = 16 #<--------------- these should be in config
|
||||
|
||||
def main() -> int:
|
||||
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument("-c", "--config", type=str, default="config.json", help="configuratin file")
|
||||
p.add_argument("-c", "--config", type=str, default="voice.config.json", help="configuratin file")
|
||||
p.add_argument("-i", "--iterations", type=int, default=10, help="number of iterations")
|
||||
args = p.parse_args()
|
||||
|
||||
@ -16,25 +18,23 @@ def main() -> int:
|
||||
|
||||
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)
|
||||
model = v['model']
|
||||
voice = utterance.voice.Voice(name=v["name"].upper(), model=model['model_dir'], tokenizer=model['tokeniser_file'], temp=float(model["temperature"]), lenght=UTTERANCE_LEN)
|
||||
voices.append(voice)
|
||||
|
||||
nbr_voices = len(voices)
|
||||
current_voice = ""
|
||||
current_voice_name = ""
|
||||
for i in range(args.iterations):
|
||||
rindex = random.randint(0, nbr_voices - 1)
|
||||
v = voices[rindex]
|
||||
if v.name != current_voice:
|
||||
v = random.sample(voices, 1)[0]
|
||||
if v.name != current_voice_name:
|
||||
current_voice_name = v.name
|
||||
print("==========")
|
||||
print(v.name + ":")
|
||||
current_voice = v.name
|
||||
t = v.utter_one()
|
||||
if t != None:
|
||||
t = v.utter_one()
|
||||
t = utterance.utils.clean(t)
|
||||
t = utterance.utils.format(t)
|
||||
print(t)
|
||||
|
||||
time.sleep(4)
|
||||
# time.sleep(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user