2023 the huggingface team licensed under the apache license version 2 0 the license you may not use this file except in compliance with the license you may obtain a copy of the license at http www apache orglicenseslicense2 0 unless required by applicable law or agreed to in writing software distributed under the license is distributed on an as is basis without warranties or conditions of any kind either express or implied see the license for the specific language governing permissions and limitations under the license univnetmodel model configuration from configurationutils import pretrainedconfig from utils import logging logger logging getloggername univnetpretrainedconfigarchivemap dg845univnetdev https huggingface codg845univnetdevresolvemainconfig json class univnetconfigpretrainedconfig r this is the configuration class to store the configuration of a univnetmodel it is used to instantiate a univnet vocoder model according to the specified arguments defining the model architecture instantiating a configuration with the defaults will yield a similar configuration to that of the univnet dg845univnetdevhttps huggingface codg845univnetdev architecture which corresponds to the c32 architecture in maumaiunivnethttps github commaumaiunivnetblobmasterconfigdefaultc32 yaml configuration objects inherit from pretrainedconfig and can be used to control the model outputs read the documentation from pretrainedconfig for more information args modelinchannels int optional defaults to 64 the number of input channels for the univnet residual network this should correspond to noisesequence shape1 and the value used in the univnetfeatureextractor class modelhiddenchannels int optional defaults to 32 the number of hidden channels of each residual block in the univnet residual network nummelbins int optional defaults to 100 the number of frequency bins in the conditioning logmel spectrogram this should correspond to the value used in the univnetfeatureextractor class resblockkernelsizes tupleint or listint optional defaults to 3 3 3 a tuple of integers defining the kernel sizes of the 1d convolutional layers in the univnet residual network the length of resblockkernelsizes defines the number of resnet blocks and should match that of resblockstridesizes and resblockdilationsizes resblockstridesizes tupleint or listint optional defaults to 8 8 4 a tuple of integers defining the stride sizes of the 1d convolutional layers in the univnet residual network the length of resblockstridesizes should match that of resblockkernelsizes and resblockdilationsizes resblockdilationsizes tupletupleint or listlistint optional defaults to 1 3 9 27 1 3 9 27 1 3 9 27 a nested tuple of integers defining the dilation rates of the dilated 1d convolutional layers in the univnet residual network the length of resblockdilationsizes should match that of resblockkernelsizes and resblockstridesizes the length of each nested list in resblockdilationsizes defines the number of convolutional layers per resnet block kernelpredictornumblocks int optional defaults to 3 the number of residual blocks in the kernel predictor network which calculates the kernel and bias for each location variable convolution layer in the univnet residual network kernelpredictorhiddenchannels int optional defaults to 64 the number of hidden channels for each residual block in the kernel predictor network kernelpredictorconvsize int optional defaults to 3 the kernel size of each 1d convolutional layer in the kernel predictor network kernelpredictordropout float optional defaults to 0 0 the dropout probability for each residual block in the kernel predictor network initializerrange float optional defaults to 0 01 the standard deviation of the truncatednormalinitializer for initializing all weight matrices leakyreluslope float optional defaults to 0 2 the angle of the negative slope used by the leaky relu activation example python from transformers import univnetmodel univnetconfig initializing a tortoise tts style configuration configuration univnetconfig initializing a model with random weights from the tortoise tts style configuration model univnetmodelconfiguration accessing the model configuration configuration model config 2023 the huggingface team licensed under the apache license version 2 0 the license you may not use this file except in compliance with the license you may obtain a copy of the license at http www apache org licenses license 2 0 unless required by applicable law or agreed to in writing software distributed under the license is distributed on an as is basis without warranties or conditions of any kind either express or implied see the license for the specific language governing permissions and limitations under the license univnetmodel model configuration this is the configuration class to store the configuration of a univnetmodel it is used to instantiate a univnet vocoder model according to the specified arguments defining the model architecture instantiating a configuration with the defaults will yield a similar configuration to that of the univnet dg845 univnet dev https huggingface co dg845 univnet dev architecture which corresponds to the c32 architecture in maum ai univnet https github com maum ai univnet blob master config default_c32 yaml configuration objects inherit from pretrainedconfig and can be used to control the model outputs read the documentation from pretrainedconfig for more information args model_in_channels int optional defaults to 64 the number of input channels for the univnet residual network this should correspond to noise_sequence shape 1 and the value used in the univnetfeatureextractor class model_hidden_channels int optional defaults to 32 the number of hidden channels of each residual block in the univnet residual network num_mel_bins int optional defaults to 100 the number of frequency bins in the conditioning log mel spectrogram this should correspond to the value used in the univnetfeatureextractor class resblock_kernel_sizes tuple int or list int optional defaults to 3 3 3 a tuple of integers defining the kernel sizes of the 1d convolutional layers in the univnet residual network the length of resblock_kernel_sizes defines the number of resnet blocks and should match that of resblock_stride_sizes and resblock_dilation_sizes resblock_stride_sizes tuple int or list int optional defaults to 8 8 4 a tuple of integers defining the stride sizes of the 1d convolutional layers in the univnet residual network the length of resblock_stride_sizes should match that of resblock_kernel_sizes and resblock_dilation_sizes resblock_dilation_sizes tuple tuple int or list list int optional defaults to 1 3 9 27 1 3 9 27 1 3 9 27 a nested tuple of integers defining the dilation rates of the dilated 1d convolutional layers in the univnet residual network the length of resblock_dilation_sizes should match that of resblock_kernel_sizes and resblock_stride_sizes the length of each nested list in resblock_dilation_sizes defines the number of convolutional layers per resnet block kernel_predictor_num_blocks int optional defaults to 3 the number of residual blocks in the kernel predictor network which calculates the kernel and bias for each location variable convolution layer in the univnet residual network kernel_predictor_hidden_channels int optional defaults to 64 the number of hidden channels for each residual block in the kernel predictor network kernel_predictor_conv_size int optional defaults to 3 the kernel size of each 1d convolutional layer in the kernel predictor network kernel_predictor_dropout float optional defaults to 0 0 the dropout probability for each residual block in the kernel predictor network initializer_range float optional defaults to 0 01 the standard deviation of the truncated_normal_initializer for initializing all weight matrices leaky_relu_slope float optional defaults to 0 2 the angle of the negative slope used by the leaky relu activation example python from transformers import univnetmodel univnetconfig initializing a tortoise tts style configuration configuration univnetconfig initializing a model with random weights from the tortoise tts style configuration model univnetmodel configuration accessing the model configuration configuration model config
from ...configuration_utils import PretrainedConfig
from ...utils import logging


logger = logging.get_logger(__name__)


UNIVNET_PRETRAINED_CONFIG_ARCHIVE_MAP = {
    "dg845/univnet-dev": "https://huggingface.co/dg845/univnet-dev/resolve/main/config.json",
}


class UnivNetConfig(PretrainedConfig):
    r

    model_type = "univnet"

    def __init__(
        self,
        model_in_channels=64,
        model_hidden_channels=32,
        num_mel_bins=100,
        resblock_kernel_sizes=[3, 3, 3],
        resblock_stride_sizes=[8, 8, 4],
        resblock_dilation_sizes=[[1, 3, 9, 27], [1, 3, 9, 27], [1, 3, 9, 27]],
        kernel_predictor_num_blocks=3,
        kernel_predictor_hidden_channels=64,
        kernel_predictor_conv_size=3,
        kernel_predictor_dropout=0.0,
        initializer_range=0.01,
        leaky_relu_slope=0.2,
        **kwargs,
    ):
        if not (len(resblock_kernel_sizes) == len(resblock_stride_sizes) == len(resblock_dilation_sizes)):
            raise ValueError(
                "`resblock_kernel_sizes`, `resblock_stride_sizes`, and `resblock_dilation_sizes` must all have the"
                " same length (which will be the number of resnet blocks in the model)."
            )

        self.model_in_channels = model_in_channels
        self.model_hidden_channels = model_hidden_channels
        self.num_mel_bins = num_mel_bins
        self.resblock_kernel_sizes = resblock_kernel_sizes
        self.resblock_stride_sizes = resblock_stride_sizes
        self.resblock_dilation_sizes = resblock_dilation_sizes
        self.kernel_predictor_num_blocks = kernel_predictor_num_blocks
        self.kernel_predictor_hidden_channels = kernel_predictor_hidden_channels
        self.kernel_predictor_conv_size = kernel_predictor_conv_size
        self.kernel_predictor_dropout = kernel_predictor_dropout
        self.initializer_range = initializer_range
        self.leaky_relu_slope = leaky_relu_slope
        super().__init__(**kwargs)