You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.5 KiB
Python

6 years ago
#!/usr/bin/env python3
import json, random, os
from pprint import pprint
from time import sleep
6 years ago
6 years ago
# open json files
6 years ago
pwd = os.path.dirname( os.path.realpath(__file__) ) + "/"
oracle_f = open(pwd + "guru.json", "r").read()
6 years ago
oracle = json.loads(oracle_f)
6 years ago
rebel_f = open(pwd + "rebel.json", "r").read()
6 years ago
rebel = json.loads(rebel_f)
6 years ago
# GURU PART
6 years ago
keys = list( oracle.keys())
part = random.choice(keys) # choose: Repeat OR Ask Yourself
6 years ago
print(part)
6 years ago
sound_dir = pwd + "Audio_recordings/" + oracle[part]['title'] + "/"
6 years ago
intro = random.choice(oracle[part]['introductions'])
intro_txt = intro[0]
intro_sound = sound_dir + intro[1]
6 years ago
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) )
6 years ago
# 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)
6 years ago
6 years ago
# play msg
for i in range( random.randint(1,4) ):
sleep( random.randint(1,3) )
6 years ago
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) )
6 years ago
6 years ago
# 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) )
6 years ago