|
|
|
#!/usr/bin/env python3
|
|
|
|
import json, random, os
|
|
|
|
from pprint import pprint
|
|
|
|
from time import sleep
|
|
|
|
|
|
|
|
# open json files
|
|
|
|
oracle_f = open("guru.json", "r").read()
|
|
|
|
oracle = json.loads(oracle_f)
|
|
|
|
rebel_f = open("rebel.json", "r").read()
|
|
|
|
rebel = json.loads(rebel_f)
|
|
|
|
|
|
|
|
# GURU PART
|
|
|
|
keys = list( oracle.keys())
|
|
|
|
part = random.choice(keys) # choose: Repeat OR Ask Yourself
|
|
|
|
print(part)
|
|
|
|
sound_dir = "Audio_recordings/" + oracle[part]['title'] + "/"
|
|
|
|
intro = random.choice(oracle[part]['introductions'])
|
|
|
|
intro_txt = intro[0]
|
|
|
|
intro_sound = sound_dir + intro[1]
|
|
|
|
print('Intro:', intro_txt, intro_sound)
|
|
|
|
os.system('play -q "{}" gain 10 chorus 0.7 0.9 100 0.5 5 2 -t'.format(intro_sound) )
|
|
|
|
|
|
|
|
# REBEL reply
|
|
|
|
rebel_run = random.choice([True, False]) # shall the rebel enter??
|
|
|
|
if rebel_run is True:
|
|
|
|
rebel_reply_snippet = intro[2] # comes from guru/oracle dictionary
|
|
|
|
rebel_reply = random.choice( rebel[part] )
|
|
|
|
rebel_sentence = rebel_reply.format(rebel_reply_snippet)
|
|
|
|
|
|
|
|
|
|
|
|
# play msg
|
|
|
|
for i in range( random.randint(1,4) ):
|
|
|
|
sleep( random.randint(2,5) )
|
|
|
|
msg = random.choice(oracle[part]['messages'])
|
|
|
|
msg_txt = msg[0]
|
|
|
|
msg_sound = sound_dir + msg[1]
|
|
|
|
print('MSG:', msg_txt, msg_sound)
|
|
|
|
os.system('play -q "{}" gain 10 chorus 0.7 0.9 100 0.5 5 2 -t '.format(msg_sound) )
|
|
|
|
|
|
|
|
|
|
|
|
# rebel text to speech
|
|
|
|
if rebel_run is True:
|
|
|
|
print('rebel sentence:', rebel_sentence)
|
|
|
|
os.system('echo "{}" | espeak -ven+whisper -s 110'.format(rebel_sentence) )
|
|
|
|
|
|
|
|
|