From cb9ea0ac177b9f0263c5f0a29f148216d4526609 Mon Sep 17 00:00:00 2001 From: brige Date: Wed, 18 Sep 2024 23:48:18 +0800 Subject: [PATCH] modify human --- Human.py | 9 +++++---- tts/Chunk2Mal.py | 10 ++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Human.py b/Human.py index 4c1e41c..d79dc99 100644 --- a/Human.py +++ b/Human.py @@ -81,7 +81,7 @@ def inference(render_event, batch_size, face_images_path, audio_feat_queue, audi logging.info('start inference') print(f'start inference: {render_event.is_set()}') while render_event.is_set(): - print('start inference') + mel_batch = [] try: mel_batch = audio_feat_queue.get(block=True, timeout=1) except queue.Empty: @@ -139,6 +139,7 @@ def inference(render_event, batch_size, face_images_path, audio_feat_queue, audi class Human: def __init__(self): + self._text = None self._tts = None self._fps = 50 # 20 ms per frame self._batch_size = 16 @@ -201,18 +202,18 @@ class Human: self._chunk_2_mal.push_chunk(chunk) def push_feat_queue(self, mel_chunks): - print("21") + print("push_feat_queue") self._feat_queue.put(mel_chunks) - print("22") def push_audio_frames(self, chunk, type_): + print("push_audio_frames") self._output_queue.put((chunk, type_)) def render(self): try: img, aud = self._res_frame_queue.get(block=True, timeout=.3) except queue.Empty: - print('queue.Empty:') + # print('render queue.Empty:') return None return img diff --git a/tts/Chunk2Mal.py b/tts/Chunk2Mal.py index 3c3bda1..f0d32af 100644 --- a/tts/Chunk2Mal.py +++ b/tts/Chunk2Mal.py @@ -23,14 +23,16 @@ class Chunk2Mal: try: chunk, type_ = self.pull_chunk() self._chunks.append(chunk) - self._human.push_audio_frames((chunk, type_)) - print("1") + self._human.push_audio_frames(chunk, type_) except queue.Empty: + # print('Chunk2Mal queue.Empty') continue if len(self._chunks) <= self._human.get_stride_left_size() + self._human.get_stride_right_size(): + # print('Chunk2Mal queue.Empty') continue + logging.info('np.concatenate') inputs = np.concatenate(self._chunks) # [N * chunk] mel = audio.melspectrogram(inputs) left = max(0, self._human.get_stride_left_size() * 80 / 50) @@ -41,7 +43,6 @@ class Chunk2Mal: mel_chunks = [] while i < (len(self._chunks) - self._human.get_stride_left_size() - self._human.get_stride_right_size()) / 2: - print("14") start_idx = int(left + i * mel_idx_multiplier) # print(start_idx) if start_idx + mel_step_size > len(mel[0]): @@ -49,13 +50,10 @@ class Chunk2Mal: else: mel_chunks.append(mel[:, start_idx: start_idx + mel_step_size]) i += 1 - print("13") self._human.push_feat_queue(mel_chunks) - print("15") # discard the old part to save memory self._chunks = self._chunks[-(self._human.get_stride_left_size() + self._human.get_stride_right_size()):] - print("12") logging.info('chunk2mal exit')