Upload model
Browse files- config.json +6 -2
- configuration_vits.py +258 -0
config.json
CHANGED
@@ -1,10 +1,14 @@
|
|
1 |
{
|
2 |
-
"_name_or_path": "ljspeech_vits_mb_istft",
|
3 |
"activation_dropout": 0.1,
|
4 |
"architectures": [
|
5 |
"VitsModel"
|
6 |
],
|
7 |
"attention_dropout": 0.1,
|
|
|
|
|
|
|
|
|
8 |
"depth_separable_channels": 2,
|
9 |
"depth_separable_num_layers": 3,
|
10 |
"duration_predictor_dropout": 0.5,
|
@@ -63,7 +67,7 @@
|
|
63 |
"spectrogram_bins": 513,
|
64 |
"subbands": 4,
|
65 |
"torch_dtype": "float32",
|
66 |
-
"transformers_version": "4.47.
|
67 |
"upsample_initial_channel": 512,
|
68 |
"upsample_kernel_sizes": [
|
69 |
16,
|
|
|
1 |
{
|
2 |
+
"_name_or_path": "/home/anhnct8/transformers/ljspeech_vits_mb_istft",
|
3 |
"activation_dropout": 0.1,
|
4 |
"architectures": [
|
5 |
"VitsModel"
|
6 |
],
|
7 |
"attention_dropout": 0.1,
|
8 |
+
"auto_map": {
|
9 |
+
"AutoConfig": "configuration_vits.VitsConfig",
|
10 |
+
"AutoModel": "modeling_vits.VitsModel"
|
11 |
+
},
|
12 |
"depth_separable_channels": 2,
|
13 |
"depth_separable_num_layers": 3,
|
14 |
"duration_predictor_dropout": 0.5,
|
|
|
67 |
"spectrogram_bins": 513,
|
68 |
"subbands": 4,
|
69 |
"torch_dtype": "float32",
|
70 |
+
"transformers_version": "4.47.1",
|
71 |
"upsample_initial_channel": 512,
|
72 |
"upsample_kernel_sizes": [
|
73 |
16,
|
configuration_vits.py
ADDED
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2023 The Kakao Enterprise Authors and the HuggingFace Inc. team. All rights reserved.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
"""VITS model configuration"""
|
16 |
+
|
17 |
+
from transformers.configuration_utils import PretrainedConfig
|
18 |
+
from transformers.utils import logging
|
19 |
+
|
20 |
+
|
21 |
+
logger = logging.get_logger(__name__)
|
22 |
+
|
23 |
+
|
24 |
+
class VitsConfig(PretrainedConfig):
|
25 |
+
r"""
|
26 |
+
This is the configuration class to store the configuration of a [`VitsModel`]. It is used to instantiate a VITS
|
27 |
+
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
|
28 |
+
defaults will yield a similar configuration to that of the VITS
|
29 |
+
[facebook/mms-tts-eng](https://huggingface.co/facebook/mms-tts-eng) architecture.
|
30 |
+
|
31 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
32 |
+
documentation from [`PretrainedConfig`] for more information.
|
33 |
+
|
34 |
+
Args:
|
35 |
+
vocab_size (`int`, *optional*, defaults to 38):
|
36 |
+
Vocabulary size of the VITS model. Defines the number of different tokens that can be represented by the
|
37 |
+
`inputs_ids` passed to the forward method of [`VitsModel`].
|
38 |
+
hidden_size (`int`, *optional*, defaults to 192):
|
39 |
+
Dimensionality of the text encoder layers.
|
40 |
+
num_hidden_layers (`int`, *optional*, defaults to 6):
|
41 |
+
Number of hidden layers in the Transformer encoder.
|
42 |
+
num_attention_heads (`int`, *optional*, defaults to 2):
|
43 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
44 |
+
window_size (`int`, *optional*, defaults to 4):
|
45 |
+
Window size for the relative positional embeddings in the attention layers of the Transformer encoder.
|
46 |
+
use_bias (`bool`, *optional*, defaults to `True`):
|
47 |
+
Whether to use bias in the key, query, value projection layers in the Transformer encoder.
|
48 |
+
ffn_dim (`int`, *optional*, defaults to 768):
|
49 |
+
Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
|
50 |
+
layerdrop (`float`, *optional*, defaults to 0.1):
|
51 |
+
The LayerDrop probability for the encoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556)
|
52 |
+
for more details.
|
53 |
+
ffn_kernel_size (`int`, *optional*, defaults to 3):
|
54 |
+
Kernel size of the 1D convolution layers used by the feed-forward network in the Transformer encoder.
|
55 |
+
flow_size (`int`, *optional*, defaults to 192):
|
56 |
+
Dimensionality of the flow layers.
|
57 |
+
spectrogram_bins (`int`, *optional*, defaults to 513):
|
58 |
+
Number of frequency bins in the target spectrogram.
|
59 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"relu"`):
|
60 |
+
The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
|
61 |
+
`"relu"`, `"selu"` and `"gelu_new"` are supported.
|
62 |
+
hidden_dropout (`float`, *optional*, defaults to 0.1):
|
63 |
+
The dropout probability for all fully connected layers in the embeddings and encoder.
|
64 |
+
attention_dropout (`float`, *optional*, defaults to 0.1):
|
65 |
+
The dropout ratio for the attention probabilities.
|
66 |
+
activation_dropout (`float`, *optional*, defaults to 0.1):
|
67 |
+
The dropout ratio for activations inside the fully connected layer.
|
68 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
69 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
70 |
+
layer_norm_eps (`float`, *optional*, defaults to 1e-05):
|
71 |
+
The epsilon used by the layer normalization layers.
|
72 |
+
use_stochastic_duration_prediction (`bool`, *optional*, defaults to `True`):
|
73 |
+
Whether to use the stochastic duration prediction module or the regular duration predictor.
|
74 |
+
num_speakers (`int`, *optional*, defaults to 1):
|
75 |
+
Number of speakers if this is a multi-speaker model.
|
76 |
+
speaker_embedding_size (`int`, *optional*, defaults to 0):
|
77 |
+
Number of channels used by the speaker embeddings. Is zero for single-speaker models.
|
78 |
+
upsample_initial_channel (`int`, *optional*, defaults to 512):
|
79 |
+
The number of input channels into the HiFi-GAN upsampling network.
|
80 |
+
upsample_rates (`Tuple[int]` or `List[int]`, *optional*, defaults to `[8, 8, 2, 2]`):
|
81 |
+
A tuple of integers defining the stride of each 1D convolutional layer in the HiFi-GAN upsampling network.
|
82 |
+
The length of `upsample_rates` defines the number of convolutional layers and has to match the length of
|
83 |
+
`upsample_kernel_sizes`.
|
84 |
+
upsample_kernel_sizes (`Tuple[int]` or `List[int]`, *optional*, defaults to `[16, 16, 4, 4]`):
|
85 |
+
A tuple of integers defining the kernel size of each 1D convolutional layer in the HiFi-GAN upsampling
|
86 |
+
network. The length of `upsample_kernel_sizes` defines the number of convolutional layers and has to match
|
87 |
+
the length of `upsample_rates`.
|
88 |
+
resblock_kernel_sizes (`Tuple[int]` or `List[int]`, *optional*, defaults to `[3, 7, 11]`):
|
89 |
+
A tuple of integers defining the kernel sizes of the 1D convolutional layers in the HiFi-GAN
|
90 |
+
multi-receptive field fusion (MRF) module.
|
91 |
+
resblock_dilation_sizes (`Tuple[Tuple[int]]` or `List[List[int]]`, *optional*, defaults to `[[1, 3, 5], [1, 3, 5], [1, 3, 5]]`):
|
92 |
+
A nested tuple of integers defining the dilation rates of the dilated 1D convolutional layers in the
|
93 |
+
HiFi-GAN multi-receptive field fusion (MRF) module.
|
94 |
+
leaky_relu_slope (`float`, *optional*, defaults to 0.1):
|
95 |
+
The angle of the negative slope used by the leaky ReLU activation.
|
96 |
+
depth_separable_channels (`int`, *optional*, defaults to 2):
|
97 |
+
Number of channels to use in each depth-separable block.
|
98 |
+
depth_separable_num_layers (`int`, *optional*, defaults to 3):
|
99 |
+
Number of convolutional layers to use in each depth-separable block.
|
100 |
+
duration_predictor_flow_bins (`int`, *optional*, defaults to 10):
|
101 |
+
Number of channels to map using the unonstrained rational spline in the duration predictor model.
|
102 |
+
duration_predictor_tail_bound (`float`, *optional*, defaults to 5.0):
|
103 |
+
Value of the tail bin boundary when computing the unconstrained rational spline in the duration predictor
|
104 |
+
model.
|
105 |
+
duration_predictor_kernel_size (`int`, *optional*, defaults to 3):
|
106 |
+
Kernel size of the 1D convolution layers used in the duration predictor model.
|
107 |
+
duration_predictor_dropout (`float`, *optional*, defaults to 0.5):
|
108 |
+
The dropout ratio for the duration predictor model.
|
109 |
+
duration_predictor_num_flows (`int`, *optional*, defaults to 4):
|
110 |
+
Number of flow stages used by the duration predictor model.
|
111 |
+
duration_predictor_filter_channels (`int`, *optional*, defaults to 256):
|
112 |
+
Number of channels for the convolution layers used in the duration predictor model.
|
113 |
+
prior_encoder_num_flows (`int`, *optional*, defaults to 4):
|
114 |
+
Number of flow stages used by the prior encoder flow model.
|
115 |
+
prior_encoder_num_wavenet_layers (`int`, *optional*, defaults to 4):
|
116 |
+
Number of WaveNet layers used by the prior encoder flow model.
|
117 |
+
posterior_encoder_num_wavenet_layers (`int`, *optional*, defaults to 16):
|
118 |
+
Number of WaveNet layers used by the posterior encoder model.
|
119 |
+
wavenet_kernel_size (`int`, *optional*, defaults to 5):
|
120 |
+
Kernel size of the 1D convolution layers used in the WaveNet model.
|
121 |
+
wavenet_dilation_rate (`int`, *optional*, defaults to 1):
|
122 |
+
Dilation rates of the dilated 1D convolutional layers used in the WaveNet model.
|
123 |
+
wavenet_dropout (`float`, *optional*, defaults to 0.0):
|
124 |
+
The dropout ratio for the WaveNet layers.
|
125 |
+
speaking_rate (`float`, *optional*, defaults to 1.0):
|
126 |
+
Speaking rate. Larger values give faster synthesised speech.
|
127 |
+
noise_scale (`float`, *optional*, defaults to 0.667):
|
128 |
+
How random the speech prediction is. Larger values create more variation in the predicted speech.
|
129 |
+
noise_scale_duration (`float`, *optional*, defaults to 0.8):
|
130 |
+
How random the duration prediction is. Larger values create more variation in the predicted durations.
|
131 |
+
sampling_rate (`int`, *optional*, defaults to 16000):
|
132 |
+
The sampling rate at which the output audio waveform is digitalized expressed in hertz (Hz).
|
133 |
+
|
134 |
+
Example:
|
135 |
+
|
136 |
+
```python
|
137 |
+
>>> from transformers import VitsModel, VitsConfig
|
138 |
+
|
139 |
+
>>> # Initializing a "facebook/mms-tts-eng" style configuration
|
140 |
+
>>> configuration = VitsConfig()
|
141 |
+
|
142 |
+
>>> # Initializing a model (with random weights) from the "facebook/mms-tts-eng" style configuration
|
143 |
+
>>> model = VitsModel(configuration)
|
144 |
+
|
145 |
+
>>> # Accessing the model configuration
|
146 |
+
>>> configuration = model.config
|
147 |
+
```"""
|
148 |
+
|
149 |
+
model_type = "vits"
|
150 |
+
|
151 |
+
def __init__(
|
152 |
+
self,
|
153 |
+
vocab_size=38,
|
154 |
+
hidden_size=192,
|
155 |
+
num_hidden_layers=6,
|
156 |
+
num_attention_heads=2,
|
157 |
+
window_size=4,
|
158 |
+
use_bias=True,
|
159 |
+
ffn_dim=768,
|
160 |
+
layerdrop=0.1,
|
161 |
+
ffn_kernel_size=3,
|
162 |
+
flow_size=192,
|
163 |
+
spectrogram_bins=513,
|
164 |
+
hidden_act="relu",
|
165 |
+
hidden_dropout=0.1,
|
166 |
+
attention_dropout=0.1,
|
167 |
+
activation_dropout=0.1,
|
168 |
+
initializer_range=0.02,
|
169 |
+
layer_norm_eps=1e-5,
|
170 |
+
use_stochastic_duration_prediction=True,
|
171 |
+
num_speakers=1,
|
172 |
+
speaker_embedding_size=0,
|
173 |
+
upsample_initial_channel=512,
|
174 |
+
upsample_rates=[8, 8, 2, 2],
|
175 |
+
upsample_kernel_sizes=[16, 16, 4, 4],
|
176 |
+
resblock_kernel_sizes=[3, 7, 11],
|
177 |
+
resblock_dilation_sizes=[[1, 3, 5], [1, 3, 5], [1, 3, 5]],
|
178 |
+
leaky_relu_slope=0.1,
|
179 |
+
depth_separable_channels=2,
|
180 |
+
depth_separable_num_layers=3,
|
181 |
+
duration_predictor_flow_bins=10,
|
182 |
+
duration_predictor_tail_bound=5.0,
|
183 |
+
duration_predictor_kernel_size=3,
|
184 |
+
duration_predictor_dropout=0.5,
|
185 |
+
duration_predictor_num_flows=4,
|
186 |
+
duration_predictor_filter_channels=256,
|
187 |
+
prior_encoder_num_flows=4,
|
188 |
+
prior_encoder_num_wavenet_layers=4,
|
189 |
+
posterior_encoder_num_wavenet_layers=16,
|
190 |
+
wavenet_kernel_size=5,
|
191 |
+
wavenet_dilation_rate=1,
|
192 |
+
wavenet_dropout=0.0,
|
193 |
+
speaking_rate=1.0,
|
194 |
+
noise_scale=0.667,
|
195 |
+
noise_scale_duration=0.8,
|
196 |
+
sampling_rate=16_000,
|
197 |
+
istft_decoder=None,
|
198 |
+
subbands=None,
|
199 |
+
gen_istft_n_fft=None,
|
200 |
+
gen_istft_hop_size=None,
|
201 |
+
**kwargs,
|
202 |
+
):
|
203 |
+
self.vocab_size = vocab_size
|
204 |
+
self.hidden_size = hidden_size
|
205 |
+
self.num_hidden_layers = num_hidden_layers
|
206 |
+
self.num_attention_heads = num_attention_heads
|
207 |
+
self.window_size = window_size
|
208 |
+
self.use_bias = use_bias
|
209 |
+
self.ffn_dim = ffn_dim
|
210 |
+
self.layerdrop = layerdrop
|
211 |
+
self.ffn_kernel_size = ffn_kernel_size
|
212 |
+
self.flow_size = flow_size
|
213 |
+
self.spectrogram_bins = spectrogram_bins
|
214 |
+
self.hidden_act = hidden_act
|
215 |
+
self.hidden_dropout = hidden_dropout
|
216 |
+
self.attention_dropout = attention_dropout
|
217 |
+
self.activation_dropout = activation_dropout
|
218 |
+
self.initializer_range = initializer_range
|
219 |
+
self.layer_norm_eps = layer_norm_eps
|
220 |
+
self.use_stochastic_duration_prediction = use_stochastic_duration_prediction
|
221 |
+
self.num_speakers = num_speakers
|
222 |
+
self.speaker_embedding_size = speaker_embedding_size
|
223 |
+
self.upsample_initial_channel = upsample_initial_channel
|
224 |
+
self.upsample_rates = upsample_rates
|
225 |
+
self.upsample_kernel_sizes = upsample_kernel_sizes
|
226 |
+
self.resblock_kernel_sizes = resblock_kernel_sizes
|
227 |
+
self.resblock_dilation_sizes = resblock_dilation_sizes
|
228 |
+
self.leaky_relu_slope = leaky_relu_slope
|
229 |
+
self.depth_separable_channels = depth_separable_channels
|
230 |
+
self.depth_separable_num_layers = depth_separable_num_layers
|
231 |
+
self.duration_predictor_flow_bins = duration_predictor_flow_bins
|
232 |
+
self.duration_predictor_tail_bound = duration_predictor_tail_bound
|
233 |
+
self.duration_predictor_kernel_size = duration_predictor_kernel_size
|
234 |
+
self.duration_predictor_dropout = duration_predictor_dropout
|
235 |
+
self.duration_predictor_num_flows = duration_predictor_num_flows
|
236 |
+
self.duration_predictor_filter_channels = duration_predictor_filter_channels
|
237 |
+
self.prior_encoder_num_flows = prior_encoder_num_flows
|
238 |
+
self.prior_encoder_num_wavenet_layers = prior_encoder_num_wavenet_layers
|
239 |
+
self.posterior_encoder_num_wavenet_layers = posterior_encoder_num_wavenet_layers
|
240 |
+
self.wavenet_kernel_size = wavenet_kernel_size
|
241 |
+
self.wavenet_dilation_rate = wavenet_dilation_rate
|
242 |
+
self.wavenet_dropout = wavenet_dropout
|
243 |
+
self.speaking_rate = speaking_rate
|
244 |
+
self.noise_scale = noise_scale
|
245 |
+
self.noise_scale_duration = noise_scale_duration
|
246 |
+
self.sampling_rate = sampling_rate
|
247 |
+
self.istft_decoder = istft_decoder
|
248 |
+
self.subbands = subbands
|
249 |
+
self.gen_istft_n_fft = gen_istft_n_fft
|
250 |
+
self.gen_istft_hop_size = gen_istft_hop_size
|
251 |
+
|
252 |
+
if len(upsample_kernel_sizes) != len(upsample_rates):
|
253 |
+
raise ValueError(
|
254 |
+
f"The length of `upsample_kernel_sizes` ({len(upsample_kernel_sizes)}) must match the length of "
|
255 |
+
f"`upsample_rates` ({len(upsample_rates)})"
|
256 |
+
)
|
257 |
+
|
258 |
+
super().__init__(**kwargs)
|