Make the webrtcvad dependency optional (#2754)

This commit is contained in:
PedroDKE 2020-02-13 17:16:37 +01:00 committed by GitHub
parent a334c333de
commit 50c5e5b23a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,6 @@ import sox
import wave import wave
import tempfile import tempfile
import collections import collections
from webrtcvad import Vad
DEFAULT_RATE = 16000 DEFAULT_RATE = 16000
DEFAULT_CHANNELS = 1 DEFAULT_CHANNELS = 1
@ -90,6 +89,7 @@ def vad_split(audio_frames,
num_padding_frames=10, num_padding_frames=10,
threshold=0.5, threshold=0.5,
aggressiveness=3): aggressiveness=3):
from webrtcvad import Vad
sample_rate, channels, width = audio_format sample_rate, channels, width = audio_format
if channels != 1: if channels != 1:
raise ValueError('VAD-splitting requires mono samples') raise ValueError('VAD-splitting requires mono samples')