diff --git a/rtcllm/vad.py b/rtcllm/vad.py index 232efca..415a654 100644 --- a/rtcllm/vad.py +++ b/rtcllm/vad.py @@ -136,6 +136,7 @@ class AudioTrackVad(MediaStreamTrack): Takes path, PCM audio data, and sample rate. """ + """ audio_data = self.to_mono16000_data() path = temp_file(suffix='.wav') # print(f'temp_file={path}') @@ -150,4 +151,17 @@ class AudioTrackVad(MediaStreamTrack): if self.onvoiceend: await self.onvoiceend(path) # print('************over*******') + return + """ + + path = temp_file(suffix='.wav') + output_container = av.open(path, 'w') + out_stream = output_container.add_stream('pcm_s16le', rate=16000, layout='mono') + resampler = AudioResampler(format=out_stream.format, layout=out_stream.layout, rate=out_stream.rate) + for frame in self.voiced_frames: + for f in resampler.resample(frame): + output_container.mux(out_stream.encode(frame)) + output_container.mux(out_stream.encode()) + output_container.close() + return path