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

pre.py (SV2TTS preprocessing) uses webrtcvad for lead-in/out trimming. Unless --no_trim is passed, it imports webrtcvad and converts ImportError into ModuleNotFoundError with instructions.

Source

Thrown at pre.py:63

        "this value on GPUs with low memory. Set it to 1 if CUDA is unhappy")
    parser.add_argument("-ee","--emotion_extract", action="store_true", help=\
        "Preprocess audio to extract emotional numpy (for emotional vits).")
    args = parser.parse_args()

    # Process the arguments
    if not hasattr(args, "out_dir"):
        args.out_dir = args.datasets_root.joinpath("SV2TTS", "synthesizer")
    assert args.dataset in recognized_datasets, 'is not supported, please vote for it in https://github.com/babysor/MockingBird/issues/10'
    # Create directories
    assert args.datasets_root.exists()
    args.out_dir.mkdir(exist_ok=True, parents=True)

    # 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.")
    encoder_model_fpath = args.encoder_model_fpath
    del args.no_trim
   
    args.hparams = hparams.parse(args.hparams)
    n_processes_embed = args.n_processes_embed
    del args.n_processes_embed
    preprocess_dataset(**vars(args))
    
    create_embeddings(synthesizer_root=args.out_dir, n_processes=n_processes_embed, encoder_model_fpath=encoder_model_fpath, skip_existing=args.skip_existing)
    
    if args.emotion_extract:
        create_emo(synthesizer_root=args.out_dir, n_processes=n_processes_embed, skip_existing=args.skip_existing, hparams=args.hparams)

View on GitHub (pinned to 28dc5e14f1)

Solutions

  1. pip install webrtcvad (install a C compiler if the build fails: VS Build Tools on Windows, build-essential on Linux)
  2. Or run preprocessing with --no_trim to skip VAD trimming
  3. On modern Pythons try webrtcvad-wheels as a prebuilt alternative

Example fix

# before
$ python pre.py <args>          # ModuleNotFoundError: webrtcvad

# after
$ pip install webrtcvad
$ python pre.py <args>
# or
$ python pre.py --no_trim <args>
Defensive patterns

Strategy: fallback

Validate before calling

try:
    import webrtcvad  # noqa
    HAVE_VAD = True
except ImportError:
    HAVE_VAD = False
# pass no_trim=not HAVE_VAD downstream

Prevention

When it happens

Trigger: Running encoder_preprocess/pre without --no_trim on an environment where webrtcvad (which compiles C code) is not installed or failed to build.

Common situations: Windows without Build Tools / missing gcc; Python version without a webrtcvad wheel; fresh env after requirements prune.

Related errors


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