This commit is contained in:
yumoqing 2024-09-11 10:34:18 +08:00
parent a156763d20
commit 70362f4643

View File

@ -47,6 +47,9 @@ async def pc_get_local_candidates(pc, peer):
RTCPeerConnection.get_local_candidates = pc_get_local_candidates
clas MyMediaPlayer(MediaPlayer):
pass
class RTCLLM:
def __init__(self, ws_url, iceServers):
# self.stt_model = WhisperModel('large-v3', device="cuda", compute_type="float16")
@ -116,14 +119,16 @@ class RTCLLM:
async def auto_accept_call(self, data):
opts = DictObject(iceServers=self.iceServers)
pc = RTCPeerConnection(opts)
player = MyMediaPlayer('./1.mp4')
llmtrack = LLMAudioStreamTrack(self.omni_infer)
self.peers[data['from'].id] = DictObject(**{
'info':data['from'],
'llmtrack':llmtrack,
'player':player,
'pc':pc
})
llmtrack.start()
pc.addTrack(llmtrack)
pc.addTrack(MediaStreamTrack(player.audio))
pc.addTrack(MediaStreamTrack(player.video))
await self.ws_send(json.dumps({'type':'callAccepted', 'to':data['from']}))
async def pc_track(self, peerid, track):