This commit is contained in:
yumoqing 2024-09-04 11:00:07 +08:00
parent 201687718d
commit 6e151f9399

View File

@ -21,6 +21,17 @@ from aav import MyAudioTrack, MyVideoTrack
videos = ['./1.mp4', './2.mp4']
async def pc_get_local_candidates(pc, peer):
await pc.__gather()
if not peer.l_candidates:
peer.l_candidates = []
for c in pc.__iceTransports.local_candidates():
if c not in peer.l_candidates:
peer.l_candidates.append(c)
pc.emit('icecandidate', c)
RTCPeerConnection.get_local_candidates = pc_get_local_candidates
class RTCLLM:
def __init__(self, ws_url, iceServers):
self.stt_model = WhisperModel('large-v3', device="cuda", compute_type="float16")
@ -152,6 +163,7 @@ class RTCLLM:
async def response_offer(self, data):
pc = self.get_pc(data)
peer = self.peers[data['from'].id]
if pc is None:
print(f'{self.peers=}, {data=}')
return
@ -169,7 +181,7 @@ class RTCLLM:
'answer':{'type':pc.localDescription.type, 'sdp':pc.localDescription.sdp},
'to':data['from']
}))
cands = await pc.gather_candidates()
cands = await pc.get_local_candidates(peer)
for c in cands:
await self.send_candidate(data['from'], c)