Skip to content

Whisper Models

aana.core.models.whisper

WhisperParams

Bases: BaseModel

A model for the Whisper audio-to-text model parameters.

ATTRIBUTE DESCRIPTION
language

Optional language code such as "en" or "fr". If None, language will be automatically detected.

TYPE: str

beam_size

Size of the beam for decoding.

TYPE: int

best_of

Number of best candidate sentences to consider.

TYPE: int

temperature

Controls the sampling randomness. It can be a tuple of temperatures, which will be successively used upon failures according to either compression_ratio_threshold or log_prob_threshold.

TYPE: Union[float, List[float], Tuple[float, ...]]

word_timestamps

Whether to extract word-level timestamps.

TYPE: bool

vad_filter

Whether to enable voice activity detection to filter non-speech.

TYPE: bool

check_temperature

check_temperature(v)

Validates a temperature value.

PARAMETER DESCRIPTION
v

Value to validate.

TYPE: float

RAISES DESCRIPTION
ValueError

Temperature is out of range.

RETURNS DESCRIPTION

Temperature value.

Source code in aana/core/models/whisper.py
@field_validator("temperature")
@classmethod
def check_temperature(cls, v: float):
    """Validates a temperature value.

    Args:
        v (float): Value to validate.

    Raises:
        ValueError: Temperature is out of range.

    Returns:
        Temperature value.
    """
    if isinstance(v, float) and not 0 <= v <= 1:
        raise ValueError(  # noqa: TRY003
            "Temperature must be between 0 and 1 when a single float is provided."
        )
    if isinstance(v, list | tuple) and not all(0 <= t <= 1 for t in v):
        raise ValueError(  # noqa: TRY003
            "Each temperature in the sequence must be between 0 and 1."
        )
    return v

BatchedWhisperParams

Bases: BaseModel

A model for the Batched version of Whisper audio-to-text model parameters.

ATTRIBUTE DESCRIPTION
language

Optional language code such as "en" or "fr". If None, language will be automatically detected.

TYPE: str

beam_size

Size of the beam for decoding.

TYPE: int

best_of

Number of best candidate sentences to consider.

TYPE: int

temperature

Controls the sampling randomness. It can be a tuple of temperatures, which will be successively used upon failures according to either compression_ratio_threshold or log_prob_threshold.

TYPE: Union[float, List[float], Tuple[float, ...]]

#TODO

add other parameters

TYPE: Union[float, List[float], Tuple[float, ...]]

check_temperature

check_temperature(v)

Validates a temperature value.

PARAMETER DESCRIPTION
v

Value to validate.

TYPE: float

RAISES DESCRIPTION
ValueError

Temperature is out of range.

RETURNS DESCRIPTION

Temperature value.

Source code in aana/core/models/whisper.py
@field_validator("temperature")
@classmethod
def check_temperature(cls, v: float):
    """Validates a temperature value.

    Args:
        v (float): Value to validate.

    Raises:
        ValueError: Temperature is out of range.

    Returns:
        Temperature value.
    """
    if isinstance(v, float) and not 0 <= v <= 1:
        raise ValueError(  # noqa: TRY003
            "Temperature must be between 0 and 1 when a single float is provided."
        )
    if isinstance(v, list | tuple) and not all(0 <= t <= 1 for t in v):
        raise ValueError(  # noqa: TRY003
            "Each temperature in the sequence must be between 0 and 1."
        )
    return v