{"record":{"id":"6455b3fcf1f6181d","repo":"CorentinJ/Real-Time-Voice-Cloning","slug":"package-webrtcvad-not-found-this-package-enable","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"exception","errorClass":"ModuleNotFoundError","httpStatus":null,"severity":"error","filePath":"encoder_preprocess.py","lineNumber":49,"sourceCode":"        \"defaults to <datasets_root>/SV2TTS/encoder/\")\n    parser.add_argument(\"-d\", \"--datasets\", type=str,\n                        default=\"librispeech_other,voxceleb1,voxceleb2\", help=\\\n        \"Comma-separated list of the name of the datasets you want to preprocess. Only the train \"\n        \"set of these datasets will be used. Possible names: librispeech_other, voxceleb1, \"\n        \"voxceleb2.\")\n    parser.add_argument(\"-s\", \"--skip_existing\", action=\"store_true\", help=\\\n        \"Whether to skip existing output files with the same name. Useful if this script was \"\n        \"interrupted.\")\n    parser.add_argument(\"--no_trim\", action=\"store_true\", help=\\\n        \"Preprocess audio without trimming silences (not recommended).\")\n    args = parser.parse_args()\n\n    # Verify webrtcvad is available\n    if not args.no_trim:\n        try:\n            import webrtcvad\n        except:\n            raise ModuleNotFoundError(\"Package 'webrtcvad' not found. This package enables \"\n                \"noise removal and is recommended. Please install and try again. If installation fails, \"\n                \"use --no_trim to disable this error message.\")\n    del args.no_trim\n\n    # Process the arguments\n    args.datasets = args.datasets.split(\",\")\n    if not hasattr(args, \"out_dir\"):\n        args.out_dir = args.datasets_root.joinpath(\"SV2TTS\", \"encoder\")\n    assert args.datasets_root.exists()\n    args.out_dir.mkdir(exist_ok=True, parents=True)\n\n    # Preprocess the datasets\n    print_args(args, parser)\n    preprocess_func = {\n        \"librispeech_other\": preprocess_librispeech,\n        \"voxceleb1\": preprocess_voxceleb1,\n        \"voxceleb2\": preprocess_voxceleb2,\n    }","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/CorentinJ/Real-Time-Voice-Cloning/blob/890f3a03187195b9829db2079b75c2ba2ab0405c/encoder_preprocess.py#L31-L67","documentation":"Raised by encoder_preprocess.py when the webrtcvad import fails and --no_trim was not passed. webrtcvad powers trim_long_silences() (VAD-based silence removal) during encoder preprocessing; it is a recommended-but-optional C-extension package, and the script treats a missing install as a hard error unless trimming is explicitly disabled. Note the bare `except:` also swallows real import-time errors, not just absence of the package.","triggerScenarios":"Running `python encoder_preprocess.py` without --no_trim on an environment where `import webrtcvad` fails: package not installed, not in the active venv/uv environment, or its C extension fails to build/import on the current platform or Python version.","commonSituations":"New clone without requirements installed; using the wrong interpreter (system python vs the project venv); Python or OS upgrades breaking webrtcvad's wheel availability (e.g. new Python minor with no wheel); Windows/msvc or Alpine/musl environments where the C extension does not build.","solutions":["Install it in the environment you actually run the script with: `pip install webrtcvad` (or `pip install webrtcvad-wheels` for prebuilt wheels on newer Pythons), then re-run.","Verify with `python -c \"import webrtcvad\"` using the same interpreter; if that fails with a build error, install a compiler toolchain or use webrtcvad-wheels.","If you accept keeping silences, re-run with --no_trim to skip VAD trimming entirely (model quality may drop slightly)."],"exampleFix":"# before\npython encoder_preprocess.py -d librispeech -i ~/datasets  # ModuleNotFoundError: webrtcvad\n\n# after\npip install webrtcvad  # or: pip install webrtcvad-wheels\npython encoder_preprocess.py -d librispeech -i ~/datasets\n# fallback:\npython encoder_preprocess.py -d librispeech -i ~/datasets --no_trim","handlingStrategy":"validation","validationCode":"def webrtcvad_available() -> bool:\n    try:\n        import webrtcvad  # noqa: F401\n        return True\n    except Exception:\n        return False\n\n# before subprocess: assert webrtcvad_available() or pass \"--no_trim\"","typeGuard":null,"tryCatchPattern":"try:\n    subprocess.run([sys.executable, \"encoder_preprocess.py\", ...], check=True)\nexcept subprocess.CalledProcessError:\n    if not webrtcvad_available():\n        subprocess.run([sys.executable, \"encoder_preprocess.py\", ..., \"--no_trim\"], check=True)\n    else:\n        raise","preventionTips":["Pin webrtcvad (or webrtcvad-wheels) in the project environment and verify `import webrtcvad` in CI.","Run all repo scripts with the same interpreter/venv you installed packages into.","When C-extension builds are impossible (musl, new Python), fall back to --no_trim knowingly, not accidentally."],"tags":["dependencies","preprocessing","webrtcvad","environment"],"backgroundTag":null,"analyzedSha":"890f3a03187195b9829db2079b75c2ba2ab0405c","analyzedAt":"2026-08-15T02:15:13.202Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}