fix: remove unused variable; fix: remove redundant logic

This commit is contained in:
antonyesk601
2025-07-23 08:26:44 +00:00
parent 688031efd6
commit 1cbf7ae480

View File

@@ -77,9 +77,8 @@ class SimliVideoService(FrameProcessor):
self._audio_task: asyncio.Task = None self._audio_task: asyncio.Task = None
self._video_task: asyncio.Task = None self._video_task: asyncio.Task = None
self._started = False
self._is_trinity_avatar = is_trinity_avatar self._is_trinity_avatar = is_trinity_avatar
self._previously_interrupted = True self._previously_interrupted = is_trinity_avatar
self._audio_buffer = bytearray() self._audio_buffer = bytearray()
async def _start_connection(self): async def _start_connection(self):
@@ -153,7 +152,7 @@ class SimliVideoService(FrameProcessor):
resampled_frames = self._simli_resampler.resample(old_frame) resampled_frames = self._simli_resampler.resample(old_frame)
for resampled_frame in resampled_frames: for resampled_frame in resampled_frames:
audioBytes = resampled_frame.to_ndarray().astype(np.int16).tobytes() audioBytes = resampled_frame.to_ndarray().astype(np.int16).tobytes()
if self._previously_interrupted and self._is_trinity_avatar: if self._previously_interrupted:
self._audio_buffer.extend(audioBytes) self._audio_buffer.extend(audioBytes)
if len(self._audio_buffer) >= 128000: if len(self._audio_buffer) >= 128000:
try: try:
@@ -176,12 +175,9 @@ class SimliVideoService(FrameProcessor):
await self._simli_client.playImmediate(self._audio_buffer) await self._simli_client.playImmediate(self._audio_buffer)
self._previously_interrupted = False self._previously_interrupted = False
self._audio_buffer = bytearray() self._audio_buffer = bytearray()
except Exception as e: except Exception as e:
logger.exception(f"{self} exception: {e}") logger.exception(f"{self} exception: {e}")
return return
self._started = True
await self._simli_client.send((0).to_bytes(1, "big") * 6000)
elif isinstance(frame, (EndFrame, CancelFrame)): elif isinstance(frame, (EndFrame, CancelFrame)):
await self._stop() await self._stop()
elif isinstance(frame, (StartInterruptionFrame, UserStartedSpeakingFrame)): elif isinstance(frame, (StartInterruptionFrame, UserStartedSpeakingFrame)):