首页 > 解决方案 > 在 webrtcvac 上处理帧时出错

问题描述

我正在尝试在此函数中使用 webrtcvac.vac 检查帧是否包含语音,但出现此错误。我知道帧变量返回一个实际字节,所以我知道这部分有效,但我仍然得到错误。我对音频操作非常陌生,所以我的错误可能是由于我不明白的东西。

    def check_audio(self, framex):
        sample_rate = 16000
        frame_duration = 10  
        frame = int(framex * sample_rate * frame_duration / 1000).to_bytes(2, "big")
        print(frame)
        return self.vad.is_speech(frame, sample_rate)

    if (detector.check_audio(frame) is True):
  File "C:\Users\bruhm\source\repos\speechrecognition\speechrecognition\voice_detector.py", line 17, in check_audio
    return self.vad.is_speech(frame, sample_rate)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\webrtcvad.py", line 27, in is_speech
    return _webrtcvad.process(self._vad, sample_rate, buf, length)
webrtcvad.Error: Error while processing frame
The thread 'MainThread' (0x1) has exited with code 0 (0x0).
The program 'python.exe' has exited with code 0 (0x0).

这可能是一个非常明显的错误,或者是我需要完全改变它的错误,但不幸的是,这似乎已经超出了我的掌握,因为我在理解文档/堆栈溢出内容中的任何内容时遇到了很多麻烦

谢谢

标签: pythonaudiovoice-recognitionrecording

解决方案


推荐阅读