import eventlet import socketio import sys, math, base64 from datetime import datetime import struct import torch, torchaudio import numpy as np from scipy.io.wavfile import write, read sys.path.append("/hubert") from hubert import hubert_discrete, hubert_soft, kmeans100 sys.path.append("/acoustic-model") from acoustic import hubert_discrete, hubert_soft sys.path.append("/hifigan") from hifigan import hifigan hubert_model = torch.load("/models/bshall_hubert_main.pt").cuda() acoustic_model = torch.load("/models/bshall_acoustic-model_main.pt").cuda() hifigan_model = torch.load("/models/bshall_hifigan_main.pt").cuda() def applyVol(i, chunk, vols): curVol = vols[i] / 2 if curVol < 0.0001: line = torch.zeros(chunk.size()) else: line = torch.ones(chunk.size()) volApplied = torch.mul(line, chunk) volApplied = volApplied.unsqueeze(0) return volApplied class MyCustomNamespace(socketio.Namespace): def __init__(self, namespace): super().__init__(namespace) def on_connect(self, sid, environ): print('[{}] connet sid : {}'.format(datetime.now().strftime('%Y-%m-%d %H:%M:%S') , sid)) def on_request_message(self, sid, msg): print("Processing Request...") gpu = int(msg[0]) srcId = int(msg[1]) dstId = int(msg[2]) timestamp = int(msg[3]) data = msg[4] # print(srcId, dstId, timestamp) unpackedData = np.array(struct.unpack('<%sh'%(len(data) // struct.calcsize('