jamiepine/voicebox · error · ValueError

Preset voice '{preset_voice_id}' is not valid for engine '{p

Error message

Preset voice '{preset_voice_id}' is not valid for engine '{preset_engine}'

What it means

Returned by _validate_profile_fields when voice_type=='preset' and preset_voice_id is not in the known voice set for preset_engine. Only engines 'kokoro' (KOKORO_VOICES) and 'qwen_custom_voice' (QWEN_CUSTOM_VOICES) publish voice lists; for any other preset_engine the set is empty and this check is skipped, so this error only fires for those two engines.

Source

Thrown at backend/services/profiles.py:173

    existing_profile = db.query(DBVoiceProfile).filter_by(name=data.name).first()
    if existing_profile:
        raise ValueError(f"A profile with the name '{data.name}' already exists. Please choose a different name.")

    # Auto-set default_engine for preset profiles
    default_engine = data.default_engine
    voice_type = data.voice_type or "cloned"
    if voice_type == "preset" and data.preset_engine and not default_engine:
        default_engine = data.preset_engine

    validation_error = _validate_profile_fields(
        voice_type=voice_type,
        preset_engine=data.preset_engine,
        preset_voice_id=data.preset_voice_id,
        design_prompt=data.design_prompt,
        default_engine=default_engine,
    )
    if validation_error:
        raise ValueError(validation_error)

    db_profile = DBVoiceProfile(
        id=str(uuid.uuid4()),
        name=data.name,
        description=data.description,
        language=data.language,
        voice_type=voice_type,
        preset_engine=data.preset_engine,
        preset_voice_id=data.preset_voice_id,
        design_prompt=data.design_prompt,
        default_engine=default_engine,
        personality=data.personality,
        created_at=datetime.utcnow(),
        updated_at=datetime.utcnow(),
    )

    db.add(db_profile)
    db.commit()

View on GitHub (pinned to 51f49dea19)

Solutions

  1. Fetch the live voice list for the engine (KOKORO_VOICES / QWEN_CUSTOM_VOICES) and select a valid preset_voice_id from it.
  2. Upgrade the backend so the voice catalogue matches what the client expects, then re-send.
  3. Regenerate the client's voice picker from the current backend response, not a cached snapshot.

Example fix

// before
{"voice_type":"preset","preset_engine":"kokoro","preset_voice_id":"af_heart_x"}
// after - use a real kokoro voice id
{"voice_type":"preset","preset_engine":"kokoro","preset_voice_id":"af_heart"}
Defensive patterns

Strategy: validation

Validate before calling

from ..backends.kokoro_backend import KOKORO_VOICES
from ..backends.qwen_custom_voice_backend import QWEN_CUSTOM_VOICES

def known_voice_ids(engine: str) -> set[str]:
    if engine == "kokoro":
        return {v for v, *_ in KOKORO_VOICES}
    if engine == "qwen_custom_voice":
        return {v for v, *_ in QWEN_CUSTOM_VOICES}
    return set()  # other engines: catalogue not enforced

def preset_voice_ok(engine: str, voice_id: str) -> bool:
    ids = known_voice_ids(engine)
    return (not ids) or (voice_id in ids)

Type guard

def is_known_preset_voice(engine: str, voice_id: str) -> bool:
    ids = known_voice_ids(engine)
    return not ids or voice_id in ids

Prevention

When it happens

Trigger: POSTing preset_engine:'kokoro' with a voice id not in KOKORO_VOICES, or preset_engine:'qwen_custom_voice' with an id not in QWEN_CUSTOM_VOICES. A typo, a stale id from an older backend version, or an id belonging to a different engine.

Common situations: Hardcoding a voice id that was renamed/removed in a backend update; mixing up ids across engines (e.g. sending a kokoro id under qwen_custom_voice); frontend dropdown populated from a cached/stale list.

Related errors


AI-assisted analysis of jamiepine/voicebox@51f49dea19 (2026-08-12). Data as JSON: /api/errors/2ae032af1c915c88. Report an issue: GitHub.