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