modify human
This commit is contained in:
parent
aa32bd2a82
commit
cb9ea0ac17
9
Human.py
9
Human.py
@ -81,7 +81,7 @@ def inference(render_event, batch_size, face_images_path, audio_feat_queue, audi
|
|||||||
logging.info('start inference')
|
logging.info('start inference')
|
||||||
print(f'start inference: {render_event.is_set()}')
|
print(f'start inference: {render_event.is_set()}')
|
||||||
while render_event.is_set():
|
while render_event.is_set():
|
||||||
print('start inference')
|
mel_batch = []
|
||||||
try:
|
try:
|
||||||
mel_batch = audio_feat_queue.get(block=True, timeout=1)
|
mel_batch = audio_feat_queue.get(block=True, timeout=1)
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
@ -139,6 +139,7 @@ def inference(render_event, batch_size, face_images_path, audio_feat_queue, audi
|
|||||||
|
|
||||||
class Human:
|
class Human:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self._text = None
|
||||||
self._tts = None
|
self._tts = None
|
||||||
self._fps = 50 # 20 ms per frame
|
self._fps = 50 # 20 ms per frame
|
||||||
self._batch_size = 16
|
self._batch_size = 16
|
||||||
@ -201,18 +202,18 @@ class Human:
|
|||||||
self._chunk_2_mal.push_chunk(chunk)
|
self._chunk_2_mal.push_chunk(chunk)
|
||||||
|
|
||||||
def push_feat_queue(self, mel_chunks):
|
def push_feat_queue(self, mel_chunks):
|
||||||
print("21")
|
print("push_feat_queue")
|
||||||
self._feat_queue.put(mel_chunks)
|
self._feat_queue.put(mel_chunks)
|
||||||
print("22")
|
|
||||||
|
|
||||||
def push_audio_frames(self, chunk, type_):
|
def push_audio_frames(self, chunk, type_):
|
||||||
|
print("push_audio_frames")
|
||||||
self._output_queue.put((chunk, type_))
|
self._output_queue.put((chunk, type_))
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
try:
|
try:
|
||||||
img, aud = self._res_frame_queue.get(block=True, timeout=.3)
|
img, aud = self._res_frame_queue.get(block=True, timeout=.3)
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
print('queue.Empty:')
|
# print('render queue.Empty:')
|
||||||
return None
|
return None
|
||||||
return img
|
return img
|
||||||
|
|
||||||
|
@ -23,14 +23,16 @@ class Chunk2Mal:
|
|||||||
try:
|
try:
|
||||||
chunk, type_ = self.pull_chunk()
|
chunk, type_ = self.pull_chunk()
|
||||||
self._chunks.append(chunk)
|
self._chunks.append(chunk)
|
||||||
self._human.push_audio_frames((chunk, type_))
|
self._human.push_audio_frames(chunk, type_)
|
||||||
print("1")
|
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
|
# print('Chunk2Mal queue.Empty')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if len(self._chunks) <= self._human.get_stride_left_size() + self._human.get_stride_right_size():
|
if len(self._chunks) <= self._human.get_stride_left_size() + self._human.get_stride_right_size():
|
||||||
|
# print('Chunk2Mal queue.Empty')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
logging.info('np.concatenate')
|
||||||
inputs = np.concatenate(self._chunks) # [N * chunk]
|
inputs = np.concatenate(self._chunks) # [N * chunk]
|
||||||
mel = audio.melspectrogram(inputs)
|
mel = audio.melspectrogram(inputs)
|
||||||
left = max(0, self._human.get_stride_left_size() * 80 / 50)
|
left = max(0, self._human.get_stride_left_size() * 80 / 50)
|
||||||
@ -41,7 +43,6 @@ class Chunk2Mal:
|
|||||||
mel_chunks = []
|
mel_chunks = []
|
||||||
while i < (len(self._chunks) - self._human.get_stride_left_size()
|
while i < (len(self._chunks) - self._human.get_stride_left_size()
|
||||||
- self._human.get_stride_right_size()) / 2:
|
- self._human.get_stride_right_size()) / 2:
|
||||||
print("14")
|
|
||||||
start_idx = int(left + i * mel_idx_multiplier)
|
start_idx = int(left + i * mel_idx_multiplier)
|
||||||
# print(start_idx)
|
# print(start_idx)
|
||||||
if start_idx + mel_step_size > len(mel[0]):
|
if start_idx + mel_step_size > len(mel[0]):
|
||||||
@ -49,13 +50,10 @@ class Chunk2Mal:
|
|||||||
else:
|
else:
|
||||||
mel_chunks.append(mel[:, start_idx: start_idx + mel_step_size])
|
mel_chunks.append(mel[:, start_idx: start_idx + mel_step_size])
|
||||||
i += 1
|
i += 1
|
||||||
print("13")
|
|
||||||
self._human.push_feat_queue(mel_chunks)
|
self._human.push_feat_queue(mel_chunks)
|
||||||
print("15")
|
|
||||||
|
|
||||||
# discard the old part to save memory
|
# discard the old part to save memory
|
||||||
self._chunks = self._chunks[-(self._human.get_stride_left_size() + self._human.get_stride_right_size()):]
|
self._chunks = self._chunks[-(self._human.get_stride_left_size() + self._human.get_stride_right_size()):]
|
||||||
print("12")
|
|
||||||
|
|
||||||
logging.info('chunk2mal exit')
|
logging.info('chunk2mal exit')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user