From e3322b9bacf7a8c836067ea6f4b545e4d9b93c4e Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 18 Sep 2024 15:48:30 +0800 Subject: [PATCH] bugfix --- rtcllm/rec.py | 2 +- rtcllm/vad.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/rtcllm/rec.py b/rtcllm/rec.py index 1ffc34d..f7f6d52 100644 --- a/rtcllm/rec.py +++ b/rtcllm/rec.py @@ -1,7 +1,7 @@ import pyaudio import av import numpy as np -from utils import frames_write_wave +from vad import frames_write_wave import sys import select from vad import MyVad, bytes2frame, to16000_160_frames diff --git a/rtcllm/vad.py b/rtcllm/vad.py index 69ad84b..eceb620 100644 --- a/rtcllm/vad.py +++ b/rtcllm/vad.py @@ -12,7 +12,18 @@ from scipy.io.wavfile import write import numpy as np import av from av import AudioLayout, AudioResampler, AudioFrame, AudioFormat -from utils import frames_write_wave + +def frames_write_wave(frames): + path = temp_file(suffix='.wav') + output_container = av.open(path, 'w') + out_stream = output_container.add_stream('pcm_s16le') + for frame in frames: + for packet in out_stream.encode(frame): + output_container.mux(packet) + for packet in out_stream.encode(None): + output_container.mux(packet) + output_container.close() + return path def to16000_160_frames(frame): remind_byts = b''