From 8db51c5240c6d6b3b32a03724cce379b9feed719 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 11 Sep 2024 15:08:56 +0800 Subject: [PATCH] bugfix --- rtcllm/a2a.py | 15 ++++++++++----- rtcllm/aav.py | 1 + rtcllm/rtc.py | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/rtcllm/a2a.py b/rtcllm/a2a.py index edd9616..fcfebce 100644 --- a/rtcllm/a2a.py +++ b/rtcllm/a2a.py @@ -12,11 +12,16 @@ class LLMAudioStreamTrack(AudioStreamTrack): async def recv(self): print(f'LLMAudioStreamTrack():recv() called ....') - b = self.get_audio_bytes() - if b is None: - return b - frame = AudioFrame.from_ndarray(io.BytesIO(b), format='s16', layout='mono') - return frame + try: + b = self.get_audio_bytes() + if b is None: + return b + frame = AudioFrame.from_ndarray(io.BytesIO(b), format='s16', layout='mono') + return frame + except Exception as e: + print_exc() + print(f'{self.__class__.__name__} recv() exception happened') + raise e def set_cur_audio_iter(self): if len(self.audio_iters) == 0: diff --git a/rtcllm/aav.py b/rtcllm/aav.py index 6942a60..38f8b3b 100644 --- a/rtcllm/aav.py +++ b/rtcllm/aav.py @@ -57,6 +57,7 @@ class MyAudioStreamTrack(AudioStreamTrack): async def _recv(self): if self.source is None: + print('self._recv() return None') return None f = await self.track.recv() return f diff --git a/rtcllm/rtc.py b/rtcllm/rtc.py index 095673d..4e1035a 100644 --- a/rtcllm/rtc.py +++ b/rtcllm/rtc.py @@ -126,7 +126,8 @@ class RTCLLM: 'player':player, 'pc':pc }) - pc.addTrack(MyAudioStreamTrack(player)) + pc.addTrack(llmtrack) + # pc.addTrack(MyAudioStreamTrack(player)) pc.addTrack(MyVideoStreamTrack(player)) # pc.addTrack(LoopingVideoTrack('./1.mp4')) # pc.addTrack(player.video)