Move stop frame task creation into TTSService.start
This commit is contained in:
@@ -238,13 +238,20 @@ class TTSService(AIService):
|
|||||||
else:
|
else:
|
||||||
await self.push_frame(frame, direction)
|
await self.push_frame(frame, direction)
|
||||||
|
|
||||||
|
async def start(self, frame: StartFrame):
|
||||||
|
await super().start(frame)
|
||||||
|
if self._push_stop_frames:
|
||||||
|
self._stop_frame_task = self.get_event_loop().create_task(self._stop_frame_handler())
|
||||||
|
|
||||||
async def stop(self, frame: EndFrame):
|
async def stop(self, frame: EndFrame):
|
||||||
|
await super().stop(frame)
|
||||||
if self._stop_frame_task:
|
if self._stop_frame_task:
|
||||||
self._stop_frame_task.cancel()
|
self._stop_frame_task.cancel()
|
||||||
await self._stop_frame_task
|
await self._stop_frame_task
|
||||||
self._stop_frame_task = None
|
self._stop_frame_task = None
|
||||||
|
|
||||||
async def cancel(self, frame: CancelFrame):
|
async def cancel(self, frame: CancelFrame):
|
||||||
|
await super().cancel(frame)
|
||||||
if self._stop_frame_task:
|
if self._stop_frame_task:
|
||||||
self._stop_frame_task.cancel()
|
self._stop_frame_task.cancel()
|
||||||
await self._stop_frame_task
|
await self._stop_frame_task
|
||||||
@@ -258,9 +265,6 @@ class TTSService(AIService):
|
|||||||
isinstance(frame, TTSStartedFrame) or
|
isinstance(frame, TTSStartedFrame) or
|
||||||
isinstance(frame, AudioRawFrame) or
|
isinstance(frame, AudioRawFrame) or
|
||||||
isinstance(frame, TTSStoppedFrame)):
|
isinstance(frame, TTSStoppedFrame)):
|
||||||
if self._stop_frame_task is None:
|
|
||||||
event_loop = self.get_event_loop()
|
|
||||||
self._stop_frame_task = event_loop.create_task(self._stop_frame_handler())
|
|
||||||
await self._stop_frame_queue.put(frame)
|
await self._stop_frame_queue.put(frame)
|
||||||
|
|
||||||
async def _stop_frame_handler(self):
|
async def _stop_frame_handler(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user