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