{"record":{"id":"d8f5c17ca90a2487","repo":"microsoft/VibeVoice","slug":"multiple-voice-presets-match-the-speaker-name-sp","errorCode":null,"errorMessage":"Multiple voice presets match the speaker name '{speaker_name}', please make the speaker_name more specific.","messagePattern":"Multiple voice presets match the speaker name '(.+?)', please make the speaker_name more specific\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"demo/realtime_model_inference_from_file.py","lineNumber":77,"sourceCode":"            if os.path.exists(path)\n        }\n        \n        print(f\"Found {len(self.available_voices)} voice files in {voices_dir}\")\n        print(f\"Available voices: {', '.join(self.available_voices.keys())}\")\n\n    def get_voice_path(self, speaker_name: str) -> str:\n        \"\"\"Get voice file path for a given speaker name\"\"\"\n        # First try exact match\n        speaker_name = speaker_name.lower()\n        if speaker_name in self.voice_presets:\n            return self.voice_presets[speaker_name]\n        \n        # Try partial matching (case insensitive)\n        matched_path = None\n        for preset_name, path in self.voice_presets.items():\n            if preset_name.lower() in speaker_name or speaker_name in preset_name.lower():\n                if matched_path is not None:\n                    raise ValueError(f\"Multiple voice presets match the speaker name '{speaker_name}', please make the speaker_name more specific.\")\n                matched_path = path\n        if matched_path is not None:\n            return matched_path\n        \n        # Default to first voice if no match found\n        default_voice = list(self.voice_presets.values())[0]\n        print(f\"Warning: No voice preset found for '{speaker_name}', using default voice: {default_voice}\")\n        return default_voice\n\n\ndef parse_args():\n    parser = argparse.ArgumentParser(description=\"VibeVoiceStreaming Processor TXT Input Test\")\n    parser.add_argument(\n        \"--model_path\",\n        type=str,\n        default=\"microsoft/VibeVoice-Realtime-0.5B\",\n        help=\"Path to the HuggingFace model directory\",\n    )","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/microsoft/VibeVoice/blob/94da20d98b2fa7688e9cbfaf7692ddb4954f7600/demo/realtime_model_inference_from_file.py#L59-L95","documentation":"Raised by VoicePresetManager.get_voice_path in the demo script when the requested speaker name does not exactly match a preset key but partially matches two or more preset names. The partial matcher loops over self.voice_presets and requires exactly one bidirectional substring match; two or more matches is ambiguous and aborts with ValueError. For example 'man' matches 'en-Carter_man', 'en-Davis_man', 'en-Mike_man', etc.","triggerScenarios":"Calling get_voice_path('man'), get_voice_path('e'), or any substring contained in multiple preset names (preset names like en-Carter_man, en-Davis_man, en-Emma_woman). Exact matches (e.g. 'en-Carter_man') never trigger it; only ambiguous partial matches do.","commonSituations":"User passes a loose speaker name like 'en' or 'woman' to the demo CLI; voices directory contains many similarly named presets (de-Spk0_man, fr-Spk0_man ...); case differences do not help because matching is already case-insensitive.","solutions":["Pass the full preset name exactly, e.g. 'en-Carter_man' (keys are the .pt file stems in demo/voices/streaming_model).","Add enough of the name to be unique, e.g. 'carter' or 'en-Carter' instead of 'man'.","List available presets (print the voice_presets dict) and pick a unique key before calling.","If programmatic use is required, wrap the call in try/except ValueError and fall back to an explicit default key."],"exampleFix":"// before\npath = manager.get_voice_path(\"man\")  # ambiguous: matches Carter/Davis/Mike\n\n// after\npath = manager.get_voice_path(\"en-Carter_man\")  # exact, unique key","handlingStrategy":"validation","validationCode":"def safe_get_voice_path(manager, speaker_name: str) -> str:\n    name = speaker_name.lower()\n    if name in manager.voice_presets:\n        return manager.voice_presets[name]\n    matches = [p for p in manager.voice_presets if p.lower() in name or name in p.lower()]\n    if len(matches) == 1:\n        return manager.voice_presets[matches[0]]\n    raise KeyError(f\"Ambiguous/non-unique speaker {speaker_name!r}; candidates: {matches}\")","typeGuard":null,"tryCatchPattern":"try:\n    path = manager.get_voice_path(speaker)\nexcept ValueError as e:\n    # e lists the ambiguity; pick explicitly from manager.voice_presets\n    print(sorted(manager.voice_presets))\n    path = manager.voice_presets[\"en-Carter_man\"]","preventionTips":["Always pass the full preset stem (filename without .pt)","Print manager.voice_presets once to learn valid keys","Never derive speaker names from free-form user input without mapping to known keys"],"tags":["demo","voice-preset","ambiguous-match","valueerror"],"backgroundTag":null,"analyzedSha":"94da20d98b2fa7688e9cbfaf7692ddb4954f7600","analyzedAt":"2026-08-15T04:12:07.418Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}