wiseman / py-webrtcvad

Python interface to the WebRTC Voice Activity Detector
Other
2.07k stars 409 forks source link

webrtcvad.Error: Error while processing frame #83

Closed ben-8878 closed 2 years ago

ben-8878 commented 2 years ago

I run follow codes to use webrtc:

vad: webrtcvad.Vad = webrtcvad.Vad(mode=0)
with open(sys.argv[1], "rb") as file:
    n = int(16000 * (30 / 1000.0) * 2)
    while True:
        buf = file.read(n)
        if len(buf) == 0:
           break
        if vad.is_speech(buf=buf, sample_rate=16000):
            print("the frame is  speech")
        else:
            print("the frame is not speech")

get follows error:

Traceback (most recent call last):
  File "test_vad.py", line 88, in <module>
    if vad.is_speech(buf=buf, sample_rate=16000):
  File "/home/ybZhang/miniconda3/lib/python3.8/site-packages/webrtcvad.py", line 27, in is_speech
    return _webrtcvad.process(self._vad, sample_rate, buf, length)
webrtcvad.Error: Error while processing frame