fix: use undeclared variable _preinitialized. fix: double send of start frame
This commit is contained in:
@@ -48,7 +48,7 @@ class SimliVideoService(FrameProcessor):
|
||||
use_turn_server: bool = False,
|
||||
latency_interval: int = 0,
|
||||
simli_url: str = "https://api.simli.ai",
|
||||
isTrinityAvatar: bool = False,
|
||||
is_trinity_avatar: bool = False,
|
||||
):
|
||||
"""Initialize the Simli video service.
|
||||
|
||||
@@ -57,6 +57,7 @@ class SimliVideoService(FrameProcessor):
|
||||
use_turn_server: Whether to use TURN server for connection. Defaults to False.
|
||||
latency_interval: Latency interval setting for sending health checks to check the latency to Simli Servers. Defaults to 0.
|
||||
simli_url: URL of the simli servers. Can be changed for custom deployments of enterprise users.
|
||||
is_trinity_avatar: boolean to tell simli client that this is a Trinity avatar which reduces latency when using Trinity.
|
||||
|
||||
"""
|
||||
super().__init__()
|
||||
@@ -77,7 +78,7 @@ class SimliVideoService(FrameProcessor):
|
||||
self._audio_task: asyncio.Task = None
|
||||
self._video_task: asyncio.Task = None
|
||||
self._started = False
|
||||
self._is_gs_avatar = isTrinityAvatar
|
||||
self._is_trinity_avatar = is_trinity_avatar
|
||||
self._previously_interrupted = True
|
||||
self._audio_buffer = bytearray()
|
||||
|
||||
@@ -134,7 +135,6 @@ class SimliVideoService(FrameProcessor):
|
||||
await super().process_frame(frame, direction)
|
||||
if isinstance(frame, StartFrame):
|
||||
await self._start_connection()
|
||||
await self.push_frame(frame, direction)
|
||||
elif isinstance(frame, TTSAudioRawFrame):
|
||||
# Send audio frame to Simli
|
||||
try:
|
||||
@@ -153,7 +153,7 @@ class SimliVideoService(FrameProcessor):
|
||||
resampled_frames = self._simli_resampler.resample(old_frame)
|
||||
for resampled_frame in resampled_frames:
|
||||
audioBytes = resampled_frame.to_ndarray().astype(np.int16).tobytes()
|
||||
if self._previously_interrupted and self._is_gs_avatar:
|
||||
if self._previously_interrupted and self._is_trinity_avatar:
|
||||
self._audio_buffer.extend(audioBytes)
|
||||
if len(self._audio_buffer) >= 128000:
|
||||
try:
|
||||
@@ -180,9 +180,6 @@ class SimliVideoService(FrameProcessor):
|
||||
except Exception as e:
|
||||
logger.exception(f"{self} exception: {e}")
|
||||
return
|
||||
if isinstance(frame, StartFrame):
|
||||
if not self._preinitialize:
|
||||
await self._start_connection()
|
||||
self._started = True
|
||||
await self._simli_client.send((0).to_bytes(1, "big") * 6000)
|
||||
elif isinstance(frame, (EndFrame, CancelFrame)):
|
||||
@@ -190,7 +187,7 @@ class SimliVideoService(FrameProcessor):
|
||||
elif isinstance(frame, (StartInterruptionFrame, UserStartedSpeakingFrame)):
|
||||
if not self._previously_interrupted:
|
||||
await self._simli_client.clearBuffer()
|
||||
self._previously_interrupted = True and self._is_gs_avatar
|
||||
self._previously_interrupted = self._is_trinity_avatar
|
||||
|
||||
await self.push_frame(frame, direction)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user