Skip to content

supertonic.config

supertonic.config

Configuration and constants for Supertonic TTS package.

This module centralizes all configuration values, magic numbers, and default settings used throughout the package.

Functions:

Name Description
get_model_config

Get configuration for a specific model.

get_model_cache_dir

Get cache directory for a specific model.

get_model_repo

Get HuggingFace repo ID for a specific model.

is_multilingual_model

Check if a model supports multilingual synthesis.

Attributes:

Name Type Description
logger
AVAILABLE_MODELS
DEFAULT_MODEL
MODEL_CONFIGS
DEFAULT_MODEL_REPO
DEFAULT_CACHE_DIR
DEFAULT_MODEL_REVISION
ONNX_DIR
VOICE_STYLES_DIR
CFG_REL_PATH
UNICODE_INDEXER_REL_PATH
DP_ONNX_REL_PATH
TEXT_ENC_ONNX_REL_PATH
VECTOR_EST_ONNX_REL_PATH
VOCODER_ONNX_REL_PATH
AVAILABLE_LANGUAGES
DEFAULT_LANGUAGE
DEFAULT_TOTAL_STEPS
DEFAULT_SPEED
DEFAULT_MAX_CHUNK_LENGTH
DEFAULT_MAX_CHUNK_LENGTH_KO
DEFAULT_SILENCE_DURATION
MIN_SPEED
MAX_SPEED
MIN_TOTAL_STEPS
MAX_TOTAL_STEPS
DEFAULT_ONNX_PROVIDERS
DEFAULT_INTRA_OP_NUM_THREADS
DEFAULT_INTER_OP_NUM_THREADS
MAX_TEXT_LENGTH
LOG_FORMAT
LOG_LEVEL

logger module-attribute

logger = getLogger(__name__)

AVAILABLE_MODELS module-attribute

AVAILABLE_MODELS = ['supertonic', 'supertonic-2']

DEFAULT_MODEL module-attribute

DEFAULT_MODEL = 'supertonic-2'

MODEL_CONFIGS module-attribute

MODEL_CONFIGS = {
    "supertonic": {
        "repo": "Supertone/supertonic",
        "cache_dir": "supertonic",
        "multilingual": False,
    },
    "supertonic-2": {
        "repo": "Supertone/supertonic-2",
        "cache_dir": "supertonic2",
        "multilingual": True,
    },
}

DEFAULT_MODEL_REPO module-attribute

DEFAULT_MODEL_REPO = getenv(
    "SUPERTONIC_MODEL_REPO",
    MODEL_CONFIGS[DEFAULT_MODEL]["repo"],
)

DEFAULT_CACHE_DIR module-attribute

DEFAULT_CACHE_DIR = getenv(
    "SUPERTONIC_CACHE_DIR",
    str(
        home()
        / ".cache"
        / MODEL_CONFIGS[DEFAULT_MODEL]["cache_dir"]
    ),
)

DEFAULT_MODEL_REVISION module-attribute

DEFAULT_MODEL_REVISION = getenv(
    "SUPERTONIC_MODEL_REVISION", "main"
)

get_model_config

get_model_config(model_name: str) -> dict

Get configuration for a specific model.

Parameters:

Name Type Description Default
model_name str

Model name ("supertonic" or "supertonic-2")

required

Returns:

Type Description
dict

Dictionary with model configuration (repo, cache_dir, multilingual)

Raises:

Type Description
ValueError

If model_name is not valid

Source code in supertonic/config.py
def get_model_config(model_name: str) -> dict:
    """Get configuration for a specific model.

    Args:
        model_name: Model name ("supertonic" or "supertonic-2")

    Returns:
        Dictionary with model configuration (repo, cache_dir, multilingual)

    Raises:
        ValueError: If model_name is not valid
    """
    if model_name not in MODEL_CONFIGS:
        raise ValueError(
            f"Invalid model: '{model_name}'. " f"Available models: {', '.join(AVAILABLE_MODELS)}"
        )
    return MODEL_CONFIGS[model_name]

get_model_cache_dir

get_model_cache_dir(model_name: str) -> Path

Get cache directory for a specific model.

Parameters:

Name Type Description Default
model_name str

Model name ("supertonic" or "supertonic-2")

required

Returns:

Type Description
Path

Path to the model's cache directory

Source code in supertonic/config.py
def get_model_cache_dir(model_name: str) -> Path:
    """Get cache directory for a specific model.

    Args:
        model_name: Model name ("supertonic" or "supertonic-2")

    Returns:
        Path to the model's cache directory
    """
    config = get_model_config(model_name)
    return Path.home() / ".cache" / config["cache_dir"]

get_model_repo

get_model_repo(model_name: str) -> str

Get HuggingFace repo ID for a specific model.

Parameters:

Name Type Description Default
model_name str

Model name ("supertonic" or "supertonic-2")

required

Returns:

Type Description
str

HuggingFace repository ID

Source code in supertonic/config.py
def get_model_repo(model_name: str) -> str:
    """Get HuggingFace repo ID for a specific model.

    Args:
        model_name: Model name ("supertonic" or "supertonic-2")

    Returns:
        HuggingFace repository ID
    """
    config = get_model_config(model_name)
    return config["repo"]

is_multilingual_model

is_multilingual_model(model_name: str) -> bool

Check if a model supports multilingual synthesis.

Parameters:

Name Type Description Default
model_name str

Model name ("supertonic" or "supertonic-2")

required

Returns:

Type Description
bool

True if model supports multiple languages

Source code in supertonic/config.py
def is_multilingual_model(model_name: str) -> bool:
    """Check if a model supports multilingual synthesis.

    Args:
        model_name: Model name ("supertonic" or "supertonic-2")

    Returns:
        True if model supports multiple languages
    """
    config = get_model_config(model_name)
    return config["multilingual"]

ONNX_DIR module-attribute

ONNX_DIR = Path('onnx')

VOICE_STYLES_DIR module-attribute

VOICE_STYLES_DIR = Path('voice_styles')

CFG_REL_PATH module-attribute

CFG_REL_PATH = ONNX_DIR / 'tts.json'

UNICODE_INDEXER_REL_PATH module-attribute

UNICODE_INDEXER_REL_PATH = ONNX_DIR / "unicode_indexer.json"

DP_ONNX_REL_PATH module-attribute

DP_ONNX_REL_PATH = ONNX_DIR / 'duration_predictor.onnx'

TEXT_ENC_ONNX_REL_PATH module-attribute

TEXT_ENC_ONNX_REL_PATH = ONNX_DIR / 'text_encoder.onnx'

VECTOR_EST_ONNX_REL_PATH module-attribute

VECTOR_EST_ONNX_REL_PATH = (
    ONNX_DIR / "vector_estimator.onnx"
)

VOCODER_ONNX_REL_PATH module-attribute

VOCODER_ONNX_REL_PATH = ONNX_DIR / 'vocoder.onnx'

AVAILABLE_LANGUAGES module-attribute

AVAILABLE_LANGUAGES = ['en', 'ko', 'es', 'pt', 'fr']

DEFAULT_LANGUAGE module-attribute

DEFAULT_LANGUAGE = 'en'

DEFAULT_TOTAL_STEPS module-attribute

DEFAULT_TOTAL_STEPS = 5

DEFAULT_SPEED module-attribute

DEFAULT_SPEED = 1.05

DEFAULT_MAX_CHUNK_LENGTH module-attribute

DEFAULT_MAX_CHUNK_LENGTH = 300

DEFAULT_MAX_CHUNK_LENGTH_KO module-attribute

DEFAULT_MAX_CHUNK_LENGTH_KO = 120

DEFAULT_SILENCE_DURATION module-attribute

DEFAULT_SILENCE_DURATION = 0.3

MIN_SPEED module-attribute

MIN_SPEED = 0.7

MAX_SPEED module-attribute

MAX_SPEED = 2.0

MIN_TOTAL_STEPS module-attribute

MIN_TOTAL_STEPS = 1

MAX_TOTAL_STEPS module-attribute

MAX_TOTAL_STEPS = 100

DEFAULT_ONNX_PROVIDERS module-attribute

DEFAULT_ONNX_PROVIDERS = ['CPUExecutionProvider']

DEFAULT_INTRA_OP_NUM_THREADS module-attribute

DEFAULT_INTRA_OP_NUM_THREADS = _parse_env_int(
    "SUPERTONIC_INTRA_OP_THREADS"
)

DEFAULT_INTER_OP_NUM_THREADS module-attribute

DEFAULT_INTER_OP_NUM_THREADS = _parse_env_int(
    "SUPERTONIC_INTER_OP_THREADS"
)

MAX_TEXT_LENGTH module-attribute

MAX_TEXT_LENGTH = 100000

LOG_FORMAT module-attribute

LOG_FORMAT = (
    "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)

LOG_LEVEL module-attribute

LOG_LEVEL = getenv('SUPERTONIC_LOG_LEVEL', 'INFO')