From 7eccc99c2a14c720f2bd17ad63d2d28c597d9305 Mon Sep 17 00:00:00 2001 From: jiegeaiai Date: Fri, 15 Nov 2024 01:09:47 +0800 Subject: [PATCH] modify handler --- asr/sherpa_ncnn_asr.py | 2 +- human/audio_mal_handler.py | 4 ++-- nlp/nlp_doubao.py | 8 ++++---- tts/tts_audio_handle.py | 4 +++- tts/tts_base.py | 1 + 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/asr/sherpa_ncnn_asr.py b/asr/sherpa_ncnn_asr.py index cefe451..2e5c257 100644 --- a/asr/sherpa_ncnn_asr.py +++ b/asr/sherpa_ncnn_asr.py @@ -68,7 +68,7 @@ class SherpaNcnnAsr(AsrBase): self._notify_complete('介绍中国5000年历史文学') logger.info(f'_recognize_loop111') segment_id += 1 - time.sleep(20) + time.sleep(50) logger.info(f'_recognize_loop222') logger.info(f'_recognize_loop exit') ''' diff --git a/human/audio_mal_handler.py b/human/audio_mal_handler.py index 76f471c..53fc14b 100644 --- a/human/audio_mal_handler.py +++ b/human/audio_mal_handler.py @@ -48,7 +48,7 @@ class AudioMalHandler(AudioHandler): super().on_message(message) def on_handle(self, stream, index): - # print('AudioMalHandler on_handle', index) + # logging.info(f'AudioMalHandler on_handle {index}') self._queue.put(stream) def _on_run(self): @@ -107,7 +107,7 @@ class AudioMalHandler(AudioHandler): chunk = np.zeros(self.chunk, dtype=np.float32) frame = (chunk, '') type_ = 1 - # print('AudioMalHandler get_audio_frame type:', type_) + # logging.info(f'AudioMalHandler get_audio_frame type:{type_}') return frame, type_ def stop(self): diff --git a/nlp/nlp_doubao.py b/nlp/nlp_doubao.py index 8b5e2f1..8c72535 100644 --- a/nlp/nlp_doubao.py +++ b/nlp/nlp_doubao.py @@ -37,15 +37,15 @@ class DouBaoSDK: sec = sec + completion.choices[0].delta.content sec, message = handle.handle(sec) if len(message) > 0: - logger.info(f'-------dou_bao nlp time:{time.time() - t:.4f}s') + # logger.info(f'-------dou_bao nlp time:{time.time() - t:.4f}s') callback(message) callback(sec) - logger.info(f'-------dou_bao nlp time:{time.time() - t:.4f}s') + # logger.info(f'-------dou_bao nlp time:{time.time() - t:.4f}s') await self._stream.close() self._stream = None except Exception as e: - print(e) - logger.info(f'-------dou_bao nlp time:{time.time() - t:.4f}s') + logger.error(f'-------dou_bao error:{e}') + # logger.info(f'-------dou_bao nlp time:{time.time() - t:.4f}s') async def close(self): if self._stream is not None: diff --git a/tts/tts_audio_handle.py b/tts/tts_audio_handle.py index bd7643c..728f49a 100644 --- a/tts/tts_audio_handle.py +++ b/tts/tts_audio_handle.py @@ -93,7 +93,7 @@ class TTSAudioSplitHandle(TTSAudioHandle): return heapq.heappush(self._priority_queue, (index, (chunks, txt))) - print('TTSAudioSplitHandle::on_handle', index, current, self._current, len(self._priority_queue)) + logger.info(f'TTSAudioSplitHandle::on_handle {index}, {current}, {self._current}, {len(self._priority_queue)}') if current == self._current: self._current = self._current + 1 chunks = heapq.heappop(self._priority_queue)[1] @@ -101,7 +101,9 @@ class TTSAudioSplitHandle(TTSAudioHandle): if chunks is not None: for chunk in chunks: + logger.info(f'TTSAudioSplitHandle::on_handle push') self.on_next_handle((chunk, txt), 0) + logger.info(f'TTSAudioSplitHandle::on_handle push finish') def stop(self): self._is_running = False diff --git a/tts/tts_base.py b/tts/tts_base.py index d628a08..edb3428 100644 --- a/tts/tts_base.py +++ b/tts/tts_base.py @@ -79,6 +79,7 @@ class TTSBase(NLPCallback): if self._handle is not None: index = self._handle.get_index() # print(f'message txt-index:{txt}, index {index}') + logger.info(f'TTSBase::message request:{txt}, index:{index}') self._message_queue.add_task(self._request, txt, index) def stop(self):