-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.py
More file actions
78 lines (69 loc) · 1.96 KB
/
stack.py
File metadata and controls
78 lines (69 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from videoEngine.inference_final import main as vd
from vocalEngine.vox import generate
from inputEngine.stt import stt
import AVController as av
from threading import Thread
import socket
import warnings
import time
import torch
import json
# Load Config File
cfg = json.load(open("config.json"))
## system vars.
avLock = False
HOST = "127.0.0.1"
PORT = 25077
# Init.
warnings.filterwarnings("ignore", category=DeprecationWarning)
warnings.filterwarnings("ignore", category=FutureWarning)
# Function Definitions
def inputEngine():
print('Listening...')
response = stt()
if response:
return response
else:
raise RuntimeError('The input engine has encountered an error.')
def processEngine(data_in):
print('processing data in core...')
sock = socket.socket()
sock.connect((HOST, PORT))
outbound_message = 'STACK://' + data_in
sock.sendall(outbound_message.encode('utf-8'))
data = sock.recv(16384)
ai_response = data.decode()
sock.close()
return ai_response
def vocalEngine(data_in):
print('Vocalizing data...')
generate(cfg['vocal_reference'], data_in, cfg['vocal_output'])
def videoEngine(data_in):
global avLock
avLock = True
print('Visualizing data...')
av.playFile(vd(cfg['video_checkpoint'], cfg['video_reference'], data_in))
avLock = False
def idle():
global avLock
while True:
if not avLock:
avLock - True
av.playFile(cfg['video_reference'], False)
avLock = False
# Main Thread
if __name__ == '__main__':
if cfg['audio_only'] == 0:
Thread(target=idle).start()
while True:
input = inputEngine()
input = processEngine(input)
vocalEngine(input)
torch.cuda.empty_cache()
time.sleep(1)
if cfg['audio_only'] == 0:
videoEngine(cfg['vocal_output'])
torch.cuda.empty_cache()
else:
av.audioHeadless(cfg['vocal_output'])
time.sleep(3)