This commit is contained in:
yumoqing 2024-09-11 15:08:56 +08:00
parent 1382ecdba5
commit 8db51c5240
3 changed files with 13 additions and 6 deletions

View File

@ -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:

View File

@ -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

View File

@ -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)