modify tts logs
This commit is contained in:
parent
742340971b
commit
88a307ed6a
@ -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
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user