Skip to content

vllm_omni.diffusion.models.soulx_singer.utils

SoulXKind module-attribute

SoulXKind = Literal['svs', 'svc']

logger module-attribute

logger = init_logger(__name__)

MetadataProcessor

Data processor for SoulX-Singer

device instance-attribute

device = device

hop_size instance-attribute

hop_size = hop_size

sample_rate instance-attribute

sample_rate = sample_rate

load_phoneme_id_map

load_phoneme_id_map(phoneset_path: str)

merge_phoneme

merge_phoneme(meta)

preprocess

preprocess(
    note_duration: list[float],
    phonemes: list[str],
    note_pitch: list[int],
    note_type: list[int],
)

Insert and for each note. Get aligned indices for each frame.

Parameters:

Name Type Description Default
note_duration list[float]

Duration of each note in seconds

required
phonemes list[str]

Phoneme sequence for each note

required
note_pitch list[int]

Pitch value for each note

required
note_type list[int]

Type value for each note

required

process

process(
    meta: dict, wav_path: str | None = None
) -> dict[str, Tensor | None]

build_vocal_segments

build_vocal_segments(
    f0,
    *,
    f0_rate: int = 50,
    ignore_silent_frames_thresh: int = 5,
    min_duration_sec_per_segment: float = 5.0,
    max_duration_sec_per_segment: float = 30.0,
    num_overlaps: int = 1,
    ignore_silent_frames: bool = True,
) -> tuple[
    list[tuple[float, float]], list[tuple[float, float]]
]

Build vocal segments from an F0 contour for chunked SVC inference.

f0_to_coarse

f0_to_coarse(
    f0, f0_bin=361, f0_min=32.7031956625, f0_shift=0
)

Convert continuous F0 values to discrete F0 bins (SIL and C1 - B6, 361 bins). args: f0: continuous F0 values f0_bin: number of F0 bins f0_min: minimum F0 value f0_shift: shift value for F0 bins returns: f0_coarse: discrete F0 bins

load_config

load_config(config_path: str | Path) -> DictConfig

Load a configuration file and optionally merges it with a base configuration.

Args: config_path (Path): Path to the configuration file.

load_model_config_json

load_model_config_json(
    model_dir: str | Path,
) -> dict[str, Any]

Load config.json from a SoulX-Singer model view directory.

load_wav

load_wav(wav_path: str, sample_rate: int) -> Tensor

Load wav file and resample to target sample rate.

Parameters:

Name Type Description Default
wav_path str

Path to wav file.

required
sample_rate int

Target sample rate.

required

Returns:

Type Description
Tensor

torch.Tensor: Waveform tensor with shape (1, T).

preprocess_weight_paths

preprocess_weight_paths(
    weights_root: Path,
) -> dict[str, str]

Map upstream relative paths to absolute paths under weights_root.

resolve_phoneset_path

resolve_phoneset_path(model_dir: str) -> str

Resolve phoneme vocabulary; must be present in model directory.

resolve_pitch_shift

resolve_pitch_shift(
    *,
    auto_shift: bool,
    manual_shift: int,
    prompt_f0: Tensor | None = None,
    target_f0: Tensor | None = None,
    prompt_note_pitch: Tensor | None = None,
    target_note_pitch: Tensor | None = None,
) -> int

Resolve semitone shift for auto_shift; f0_to_coarse(..., f0_shift=shift * 5) consumes it.

resolve_preprocess_weights_root

resolve_preprocess_weights_root(
    od_config: OmniDiffusionConfig,
) -> Path

Locate preprocess weights on disk or download from Hugging Face.

resolve_soulx_kind

resolve_soulx_kind(model_dir: str | Path) -> SoulXKind

Resolve SVS vs SVC from config.json architectures[0].

validate_soulx_extra_args

validate_soulx_extra_args(
    kind: SoulXKind, extra_args: dict[str, Any] | None
) -> dict[str, Any]

Validate request extra_args against the model mode from config.json.