diff --git a/rtcllm/vad.py b/rtcllm/vad.py index eceb620..b35fd61 100644 --- a/rtcllm/vad.py +++ b/rtcllm/vad.py @@ -157,28 +157,13 @@ class AudioTrackVad(MediaStreamTrack): def stop(self): self.running = False - def to16000_160_frames(self, frame): - frames = resample(frame, sample_rate=16000) - ret_frames = [] - for f in frames: - if f.samples == 160: - return frames - for f in frames: - b1 = self.remind_byts + frame2bytes(f) - while len(b1) >= 320: - b = b1[:320] - b1 = b1[320:] - ret_frames.append(bytes2frame(b)) - self.remind_byts = b1 - - async def recv(self): frame = await self.track.recv() self.sample_rate = frame.sample_rate duration = (frame.samples * 1000) / frame.sample_rate # print(f'{self.__class__.__name__}.recv(): {duration=}, {frame.samples=}, {frame.sample_rate=}') try: - frames = self.to16000_160_frames(frame) + frames = o16000_160_frames(frame) for frame in frames: await self.vad.vad_check(frame) except Exception as e: