babysor/MockingBird · error · ModuleNotFoundError

Package 'webrtcvad' not found. This package enables noise re

Error message

Package 'webrtcvad' not found. This package enables noise removal and is recommended. Please install and try again. If installation fails, use --no_trim to disable this error message.

What it means

Raised by the encoder preprocessing CLI when the webrtcvad package cannot be imported. webrtcvad performs voice activity detection (VAD) used to trim silence/noise from utterances before feature extraction. The check runs unless --no_trim was passed, and the bare except catches any import failure (missing package or broken native build).

Source

Thrown at control/cli/encoder_preprocess.py:41

        "defaults to <datasets_root>/SV2TTS/encoder/")
    parser.add_argument("-d", "--datasets", type=str, 
                        default="librispeech_other,voxceleb1,aidatatang_200zh", help=\
        "Comma-separated list of the name of the datasets you want to preprocess. Only the train "
        "set of these datasets will be used. Possible names: librispeech_other, voxceleb1, "
        "voxceleb2.")
    parser.add_argument("-s", "--skip_existing", action="store_true", help=\
        "Whether to skip existing output files with the same name. Useful if this script was "
        "interrupted.")
    parser.add_argument("--no_trim", action="store_true", help=\
        "Preprocess audio without trimming silences (not recommended).")
    args = parser.parse_args()

    # Verify webrtcvad is available
    if not args.no_trim:
        try:
            import webrtcvad
        except:
            raise ModuleNotFoundError("Package 'webrtcvad' not found. This package enables "
                "noise removal and is recommended. Please install and try again. If installation fails, "
                "use --no_trim to disable this error message.")
    del args.no_trim

    # Process the arguments
    args.datasets = args.datasets.split(",")
    if not hasattr(args, "out_dir"):
        args.out_dir = args.datasets_root.joinpath("SV2TTS", "encoder")
    assert args.datasets_root.exists()
    args.out_dir.mkdir(exist_ok=True, parents=True)

    # Preprocess the datasets
    print_args(args, parser)
    preprocess_func = {
        "librispeech_other": preprocess_librispeech,
        "voxceleb1": preprocess_voxceleb1,
        "voxceleb2": preprocess_voxceleb2,
        "aidatatang_200zh": preprocess_aidatatang_200zh,

View on GitHub (pinned to 28dc5e14f1)

Solutions

  1. pip install webrtcvad (or pip install webrtcvad-wheels for newer Python)
  2. Re-run with --no_trim to skip VAD trimming if you can't install it
  3. Install build tools (gcc, python-dev) and retry if compiling from source fails

Example fix

# before
python encoder_preprocess.py datasets/SV2TTS/synthesizer
# after (skip VAD)
python encoder_preprocess.py datasets/SV2TTS/synthesizer --no_trim
Defensive patterns

Strategy: validation

Validate before calling

def webrtcvad_available() -> bool:
    try:
        import webrtcvad  # noqa: F401
        return True
    except ImportError:
        return False

if not webrtcvad_available():
    args.no_trim = True  # or abort with instructions

Try / catch

try:
    import webrtcvad
except ImportError as e:
    raise RuntimeError('Install webrtcvad or pass --no_trim') from e

Prevention

When it happens

Trigger: Running encoder_preprocess.py without --no_trim on an environment where webrtcvad is not installed or its C extension failed to build/import.

Common situations: Fresh environment where requirements.txt wasn't fully installed; webrtcvad wheels unavailable for the Python version/platform (e.g. Python 3.11+ where old webrtcvad has no wheel and gcc is missing); Docker images trimmed of build tools.

Related errors


AI-assisted analysis of babysor/MockingBird@28dc5e14f1 (2026-08-27). Data as JSON: /api/errors/6e1e9daa45da4a4a. Report an issue: GitHub.