2noise/ChatTTS · error · ValueError

`penalty` has to be a strictly positive float, but is {penal

Error message

`penalty` has to be a strictly positive float, but is {penalty}

What it means

Error "`penalty` has to be a strictly positive float, but is {penalty}" thrown in 2noise/ChatTTS.

Source

Thrown at ChatTTS/model/processors.py:10

import torch
import torch.nn.functional as F
from transformers.generation import TopKLogitsWarper, TopPLogitsWarper


class CustomRepetitionPenaltyLogitsProcessorRepeat:

    def __init__(self, penalty: float, max_input_ids: int, past_window: int):
        if not isinstance(penalty, float) or not (penalty > 0):
            raise ValueError(
                f"`penalty` has to be a strictly positive float, but is {penalty}"
            )

        self.penalty = penalty
        self.max_input_ids = max_input_ids
        self.past_window = past_window

    def __call__(
        self, input_ids: torch.LongTensor, scores: torch.FloatTensor
    ) -> torch.FloatTensor:
        if input_ids.size(1) > self.past_window:
            input_ids = input_ids.narrow(1, -self.past_window, self.past_window)
        freq = F.one_hot(input_ids, scores.size(1)).sum(1)
        if freq.size(0) > self.max_input_ids:
            freq.narrow(
                0, self.max_input_ids, freq.size(0) - self.max_input_ids
            ).zero_()
        alpha = torch.pow(self.penalty, freq)

View on GitHub (pinned to 77b89ee281)

When it happens

Trigger: Thrown at ChatTTS/model/processors.py:10 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of 2noise/ChatTTS@77b89ee281 (2026-08-26). Data as JSON: /api/errors/82d6b66ee99d1f1c. Report an issue: GitHub.