From 88a307ed6a591d4d29454a35d8967f5b4ae2d2c2 Mon Sep 17 00:00:00 2001 From: brige Date: Thu, 14 Nov 2024 19:14:22 +0800 Subject: [PATCH] modify tts logs --- tts/tts_base.py | 4 ++-- tts/tts_edge_http.py | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tts/tts_base.py b/tts/tts_base.py index 80c2711..d628a08 100644 --- a/tts/tts_base.py +++ b/tts/tts_base.py @@ -38,21 +38,21 @@ class TTSBase(NLPCallback): self._handle = value async def _request(self, txt: str, index): - # print('_request:', txt) if not self._is_running: logger.info('TTSBase::_request is not running') return t = time.time() stream = await self._on_request(txt) + logger.info(f'-------tts request time:{time.time() - t:.4f}s, txt:{txt}') if stream is None or self._is_running is False: logger.warning(f'-------stream is None or is_running {self._is_running}') return - logger.info(f'-------tts time:{time.time() - t:.4f}s, txt:{txt}') if self._handle is not None and self._is_running: await self._on_handle((stream, txt), index) else: logger.info(f'handle is None, running:{self._is_running}') + logger.info(f'-------tts finish time:{time.time() - t:.4f}s, txt:{txt}') async def _on_request(self, text: str): pass diff --git a/tts/tts_edge_http.py b/tts/tts_edge_http.py index aa7eb20..3767bc8 100644 --- a/tts/tts_edge_http.py +++ b/tts/tts_edge_http.py @@ -1,5 +1,6 @@ #encoding = utf8 import logging +import time from io import BytesIO import aiohttp @@ -57,22 +58,23 @@ class TTSEdgeHttp(TTSBase): return self._on_sync_request(data) async def _on_handle(self, stream, index): - print('-------tts _on_handle') st, txt = stream try: st.seek(0) + t = time.time() byte_stream = self.__create_bytes_stream(st) - print('-------tts start push chunk', index) + logger.info(f'-------tts resample time:{time.time() - t:.4f}s, txt:{txt}') + t = time.time() self._handle.on_handle((byte_stream, txt), index) + logger.info(f'-------tts handle time:{time.time() - t:.4f}s') st.seek(0) st.truncate() - print('-------tts finish push chunk') except Exception as e: self._handle.on_handle(None, index) st.seek(0) st.truncate() - print('-------tts finish error:', e) + logger.error(f'-------tts finish error:{e}') st.close() def __create_bytes_stream(self, byte_stream):