├── .gitignore
├── .gitmodules
├── LICENSE
├── README.md
├── attentions.py
├── audio_processing.py
├── commons.py
├── configs
├── base.json
└── base_blank.json
├── data
└── cmu_dictionary
├── data_utils.py
├── filelists
├── ljs_audio_text_test_filelist.txt
├── ljs_audio_text_train_filelist.txt
└── ljs_audio_text_val_filelist.txt
├── inference.ipynb
├── inference_hifigan.ipynb
├── init.py
├── models.py
├── modules.py
├── monotonic_align
├── __init__.py
├── core.pyx
└── setup.py
├── resources
├── fig_1a.png
└── fig_1b.png
├── stft.py
├── text
├── LICENSE
├── __init__.py
├── cleaners.py
├── cmudict.py
├── numbers.py
└── symbols.py
├── train.py
├── train_ddi.sh
└── utils.py
/.gitignore:
--------------------------------------------------------------------------------
1 | DATASETS
2 | DUMMY
3 | DUMMY2
4 | samples
5 | logs
6 | __pycache__
7 | .ipynb_checkpoints
8 | .*.swp
9 |
10 | build
11 | *.c
12 | monotonic_align/monotonic_align
13 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "waveglow"]
2 | path = waveglow
3 | url = https://github.com/NVIDIA/waveglow.git
4 | [submodule "hifigan"]
5 | path = hifigan
6 | url = https://github.com/jik876/hifi-gan.git
7 | [submodule "hifi-gan"]
8 | path = hifi-gan
9 | url = https://github.com/jik876/hifi-gan.git
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Jaehyeon Kim
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Glow-TTS: A Generative Flow for Text-to-Speech via Monotonic Alignment Search
2 |
3 | ### Jaehyeon Kim, Sungwon Kim, Jungil Kong, and Sungroh Yoon
4 |
5 | In our recent [paper](https://arxiv.org/abs/2005.11129), we propose Glow-TTS: A Generative Flow for Text-to-Speech via Monotonic Alignment Search.
6 |
7 | Recently, text-to-speech (TTS) models such as FastSpeech and ParaNet have been proposed to generate mel-spectrograms from text in parallel. Despite the advantage, the parallel TTS models cannot be trained without guidance from autoregressive TTS models as their external aligners. In this work, we propose Glow-TTS, a flow-based generative model for parallel TTS that does not require any external aligner. By combining the properties of flows and dynamic programming, the proposed model searches for the most probable monotonic alignment between text and the latent representation of speech on its own. We demonstrate that enforcing hard monotonic alignments enables robust TTS, which generalizes to long utterances, and employing generative flows enables fast, diverse, and controllable speech synthesis. Glow-TTS obtains an order-of-magnitude speed-up over the autoregressive model, Tacotron 2, at synthesis with comparable speech quality. We further show that our model can be easily extended to a multi-speaker setting.
8 |
9 | Visit our [demo](https://jaywalnut310.github.io/glow-tts-demo/index.html) for audio samples.
10 |
11 | We also provide the [pretrained model](https://drive.google.com/open?id=1JiCMBVTG4BMREK8cT3MYck1MgYvwASL0).
12 |
13 |
14 |
15 | Glow-TTS at training |
16 | Glow-TTS at inference |
17 |
18 |
19 |  |
20 |  |
21 |
22 |
23 |
24 |
25 | ## Update Notes*
26 |
27 | This result was not included in the paper. Lately, we found that two modifications help to improve the synthesis quality of Glow-TTS.; 1) moving to a vocoder, [HiFi-GAN](https://arxiv.org/abs/2010.05646) to reduce noise, 2) putting a blank token between any two input tokens to improve pronunciation. Specifically,
28 | we used a fine-tuned vocoder with Tacotron 2 which is provided as a pretrained model in the [HiFi-GAN repo](https://github.com/jik876/hifi-gan). If you're interested, please listen to the samples in our [demo](https://jaywalnut310.github.io/glow-tts-demo/index.html).
29 |
30 | For adding a blank token, we provide a [config file](./configs/base_blank.json) and a [pretrained model](https://drive.google.com/open?id=1RxR6JWg6WVBZYb-pIw58hi1XLNb5aHEi). We also provide an inference example [inference_hifigan.ipynb](./inference_hifigan.ipynb). You may need to initialize HiFi-GAN submodule: `git submodule init; git submodule update`
31 |
32 |
33 | ## 1. Environments we use
34 |
35 | * Python3.6.9
36 | * pytorch1.2.0
37 | * cython0.29.12
38 | * librosa0.7.1
39 | * numpy1.16.4
40 | * scipy1.3.0
41 |
42 | For Mixed-precision training, we use [apex](https://github.com/NVIDIA/apex); commit: 37cdaf4
43 |
44 |
45 | ## 2. Pre-requisites
46 |
47 | a) Download and extract the [LJ Speech dataset](https://keithito.com/LJ-Speech-Dataset/), then rename or create a link to the dataset folder: `ln -s /path/to/LJSpeech-1.1/wavs DUMMY`
48 |
49 | b) Initialize WaveGlow submodule: `git submodule init; git submodule update`
50 |
51 | Don't forget to download pretrained WaveGlow model and place it into the waveglow folder.
52 |
53 | c) Build Monotonic Alignment Search Code (Cython): `cd monotonic_align; python setup.py build_ext --inplace`
54 |
55 |
56 | ## 3. Training Example
57 |
58 | ```sh
59 | sh train_ddi.sh configs/base.json base
60 | ```
61 |
62 | ## 4. Inference Example
63 |
64 | See [inference.ipynb](./inference.ipynb)
65 |
66 |
67 | ## Acknowledgements
68 |
69 | Our implementation is hugely influenced by the following repos:
70 | * [WaveGlow](https://github.com/NVIDIA/waveglow)
71 | * [Tensor2Tensor](https://github.com/tensorflow/tensor2tensor)
72 | * [Mellotron](https://github.com/NVIDIA/mellotron)
73 |
--------------------------------------------------------------------------------
/attentions.py:
--------------------------------------------------------------------------------
1 | import copy
2 | import math
3 | import numpy as np
4 | import torch
5 | from torch import nn
6 | from torch.nn import functional as F
7 |
8 | import commons
9 | import modules
10 | from modules import LayerNorm
11 |
12 |
13 | class Encoder(nn.Module):
14 | def __init__(self, hidden_channels, filter_channels, n_heads, n_layers, kernel_size=1, p_dropout=0., window_size=None, block_length=None, **kwargs):
15 | super().__init__()
16 | self.hidden_channels = hidden_channels
17 | self.filter_channels = filter_channels
18 | self.n_heads = n_heads
19 | self.n_layers = n_layers
20 | self.kernel_size = kernel_size
21 | self.p_dropout = p_dropout
22 | self.window_size = window_size
23 | self.block_length = block_length
24 |
25 | self.drop = nn.Dropout(p_dropout)
26 | self.attn_layers = nn.ModuleList()
27 | self.norm_layers_1 = nn.ModuleList()
28 | self.ffn_layers = nn.ModuleList()
29 | self.norm_layers_2 = nn.ModuleList()
30 | for i in range(self.n_layers):
31 | self.attn_layers.append(MultiHeadAttention(hidden_channels, hidden_channels, n_heads, window_size=window_size, p_dropout=p_dropout, block_length=block_length))
32 | self.norm_layers_1.append(LayerNorm(hidden_channels))
33 | self.ffn_layers.append(FFN(hidden_channels, hidden_channels, filter_channels, kernel_size, p_dropout=p_dropout))
34 | self.norm_layers_2.append(LayerNorm(hidden_channels))
35 |
36 | def forward(self, x, x_mask):
37 | attn_mask = x_mask.unsqueeze(2) * x_mask.unsqueeze(-1)
38 | for i in range(self.n_layers):
39 | x = x * x_mask
40 | y = self.attn_layers[i](x, x, attn_mask)
41 | y = self.drop(y)
42 | x = self.norm_layers_1[i](x + y)
43 |
44 | y = self.ffn_layers[i](x, x_mask)
45 | y = self.drop(y)
46 | x = self.norm_layers_2[i](x + y)
47 | x = x * x_mask
48 | return x
49 |
50 |
51 | class CouplingBlock(nn.Module):
52 | def __init__(self, in_channels, hidden_channels, kernel_size, dilation_rate, n_layers, gin_channels=0, p_dropout=0, sigmoid_scale=False):
53 | super().__init__()
54 | self.in_channels = in_channels
55 | self.hidden_channels = hidden_channels
56 | self.kernel_size = kernel_size
57 | self.dilation_rate = dilation_rate
58 | self.n_layers = n_layers
59 | self.gin_channels = gin_channels
60 | self.p_dropout = p_dropout
61 | self.sigmoid_scale = sigmoid_scale
62 |
63 | start = torch.nn.Conv1d(in_channels//2, hidden_channels, 1)
64 | start = torch.nn.utils.weight_norm(start)
65 | self.start = start
66 | # Initializing last layer to 0 makes the affine coupling layers
67 | # do nothing at first. It helps to stabilze training.
68 | end = torch.nn.Conv1d(hidden_channels, in_channels, 1)
69 | end.weight.data.zero_()
70 | end.bias.data.zero_()
71 | self.end = end
72 |
73 | self.wn = modules.WN(in_channels, hidden_channels, kernel_size, dilation_rate, n_layers, gin_channels, p_dropout)
74 |
75 |
76 | def forward(self, x, x_mask=None, reverse=False, g=None, **kwargs):
77 | b, c, t = x.size()
78 | if x_mask is None:
79 | x_mask = 1
80 | x_0, x_1 = x[:,:self.in_channels//2], x[:,self.in_channels//2:]
81 |
82 | x = self.start(x_0) * x_mask
83 | x = self.wn(x, x_mask, g)
84 | out = self.end(x)
85 |
86 | z_0 = x_0
87 | m = out[:, :self.in_channels//2, :]
88 | logs = out[:, self.in_channels//2:, :]
89 | if self.sigmoid_scale:
90 | logs = torch.log(1e-6 + torch.sigmoid(logs + 2))
91 |
92 | if reverse:
93 | z_1 = (x_1 - m) * torch.exp(-logs) * x_mask
94 | logdet = None
95 | else:
96 | z_1 = (m + torch.exp(logs) * x_1) * x_mask
97 | logdet = torch.sum(logs * x_mask, [1, 2])
98 |
99 | z = torch.cat([z_0, z_1], 1)
100 | return z, logdet
101 |
102 | def store_inverse(self):
103 | self.wn.remove_weight_norm()
104 |
105 |
106 | class MultiHeadAttention(nn.Module):
107 | def __init__(self, channels, out_channels, n_heads, window_size=None, heads_share=True, p_dropout=0., block_length=None, proximal_bias=False, proximal_init=False):
108 | super().__init__()
109 | assert channels % n_heads == 0
110 |
111 | self.channels = channels
112 | self.out_channels = out_channels
113 | self.n_heads = n_heads
114 | self.window_size = window_size
115 | self.heads_share = heads_share
116 | self.block_length = block_length
117 | self.proximal_bias = proximal_bias
118 | self.p_dropout = p_dropout
119 | self.attn = None
120 |
121 | self.k_channels = channels // n_heads
122 | self.conv_q = nn.Conv1d(channels, channels, 1)
123 | self.conv_k = nn.Conv1d(channels, channels, 1)
124 | self.conv_v = nn.Conv1d(channels, channels, 1)
125 | if window_size is not None:
126 | n_heads_rel = 1 if heads_share else n_heads
127 | rel_stddev = self.k_channels**-0.5
128 | self.emb_rel_k = nn.Parameter(torch.randn(n_heads_rel, window_size * 2 + 1, self.k_channels) * rel_stddev)
129 | self.emb_rel_v = nn.Parameter(torch.randn(n_heads_rel, window_size * 2 + 1, self.k_channels) * rel_stddev)
130 | self.conv_o = nn.Conv1d(channels, out_channels, 1)
131 | self.drop = nn.Dropout(p_dropout)
132 |
133 | nn.init.xavier_uniform_(self.conv_q.weight)
134 | nn.init.xavier_uniform_(self.conv_k.weight)
135 | if proximal_init:
136 | self.conv_k.weight.data.copy_(self.conv_q.weight.data)
137 | self.conv_k.bias.data.copy_(self.conv_q.bias.data)
138 | nn.init.xavier_uniform_(self.conv_v.weight)
139 |
140 | def forward(self, x, c, attn_mask=None):
141 | q = self.conv_q(x)
142 | k = self.conv_k(c)
143 | v = self.conv_v(c)
144 |
145 | x, self.attn = self.attention(q, k, v, mask=attn_mask)
146 |
147 | x = self.conv_o(x)
148 | return x
149 |
150 | def attention(self, query, key, value, mask=None):
151 | # reshape [b, d, t] -> [b, n_h, t, d_k]
152 | b, d, t_s, t_t = (*key.size(), query.size(2))
153 | query = query.view(b, self.n_heads, self.k_channels, t_t).transpose(2, 3)
154 | key = key.view(b, self.n_heads, self.k_channels, t_s).transpose(2, 3)
155 | value = value.view(b, self.n_heads, self.k_channels, t_s).transpose(2, 3)
156 |
157 | scores = torch.matmul(query, key.transpose(-2, -1)) / math.sqrt(self.k_channels)
158 | if self.window_size is not None:
159 | assert t_s == t_t, "Relative attention is only available for self-attention."
160 | key_relative_embeddings = self._get_relative_embeddings(self.emb_rel_k, t_s)
161 | rel_logits = self._matmul_with_relative_keys(query, key_relative_embeddings)
162 | rel_logits = self._relative_position_to_absolute_position(rel_logits)
163 | scores_local = rel_logits / math.sqrt(self.k_channels)
164 | scores = scores + scores_local
165 | if self.proximal_bias:
166 | assert t_s == t_t, "Proximal bias is only available for self-attention."
167 | scores = scores + self._attention_bias_proximal(t_s).to(device=scores.device, dtype=scores.dtype)
168 | if mask is not None:
169 | scores = scores.masked_fill(mask == 0, -1e4)
170 | if self.block_length is not None:
171 | block_mask = torch.ones_like(scores).triu(-self.block_length).tril(self.block_length)
172 | scores = scores * block_mask + -1e4*(1 - block_mask)
173 | p_attn = F.softmax(scores, dim=-1) # [b, n_h, t_t, t_s]
174 | p_attn = self.drop(p_attn)
175 | output = torch.matmul(p_attn, value)
176 | if self.window_size is not None:
177 | relative_weights = self._absolute_position_to_relative_position(p_attn)
178 | value_relative_embeddings = self._get_relative_embeddings(self.emb_rel_v, t_s)
179 | output = output + self._matmul_with_relative_values(relative_weights, value_relative_embeddings)
180 | output = output.transpose(2, 3).contiguous().view(b, d, t_t) # [b, n_h, t_t, d_k] -> [b, d, t_t]
181 | return output, p_attn
182 |
183 | def _matmul_with_relative_values(self, x, y):
184 | """
185 | x: [b, h, l, m]
186 | y: [h or 1, m, d]
187 | ret: [b, h, l, d]
188 | """
189 | ret = torch.matmul(x, y.unsqueeze(0))
190 | return ret
191 |
192 | def _matmul_with_relative_keys(self, x, y):
193 | """
194 | x: [b, h, l, d]
195 | y: [h or 1, m, d]
196 | ret: [b, h, l, m]
197 | """
198 | ret = torch.matmul(x, y.unsqueeze(0).transpose(-2, -1))
199 | return ret
200 |
201 | def _get_relative_embeddings(self, relative_embeddings, length):
202 | max_relative_position = 2 * self.window_size + 1
203 | # Pad first before slice to avoid using cond ops.
204 | pad_length = max(length - (self.window_size + 1), 0)
205 | slice_start_position = max((self.window_size + 1) - length, 0)
206 | slice_end_position = slice_start_position + 2 * length - 1
207 | if pad_length > 0:
208 | padded_relative_embeddings = F.pad(
209 | relative_embeddings,
210 | commons.convert_pad_shape([[0, 0], [pad_length, pad_length], [0, 0]]))
211 | else:
212 | padded_relative_embeddings = relative_embeddings
213 | used_relative_embeddings = padded_relative_embeddings[:,slice_start_position:slice_end_position]
214 | return used_relative_embeddings
215 |
216 | def _relative_position_to_absolute_position(self, x):
217 | """
218 | x: [b, h, l, 2*l-1]
219 | ret: [b, h, l, l]
220 | """
221 | batch, heads, length, _ = x.size()
222 | # Concat columns of pad to shift from relative to absolute indexing.
223 | x = F.pad(x, commons.convert_pad_shape([[0,0],[0,0],[0,0],[0,1]]))
224 |
225 | # Concat extra elements so to add up to shape (len+1, 2*len-1).
226 | x_flat = x.view([batch, heads, length * 2 * length])
227 | x_flat = F.pad(x_flat, commons.convert_pad_shape([[0,0],[0,0],[0,length-1]]))
228 |
229 | # Reshape and slice out the padded elements.
230 | x_final = x_flat.view([batch, heads, length+1, 2*length-1])[:, :, :length, length-1:]
231 | return x_final
232 |
233 | def _absolute_position_to_relative_position(self, x):
234 | """
235 | x: [b, h, l, l]
236 | ret: [b, h, l, 2*l-1]
237 | """
238 | batch, heads, length, _ = x.size()
239 | # padd along column
240 | x = F.pad(x, commons.convert_pad_shape([[0, 0], [0, 0], [0, 0], [0, length-1]]))
241 | x_flat = x.view([batch, heads, length**2 + length*(length -1)])
242 | # add 0's in the beginning that will skew the elements after reshape
243 | x_flat = F.pad(x_flat, commons.convert_pad_shape([[0, 0], [0, 0], [length, 0]]))
244 | x_final = x_flat.view([batch, heads, length, 2*length])[:,:,:,1:]
245 | return x_final
246 |
247 | def _attention_bias_proximal(self, length):
248 | """Bias for self-attention to encourage attention to close positions.
249 | Args:
250 | length: an integer scalar.
251 | Returns:
252 | a Tensor with shape [1, 1, length, length]
253 | """
254 | r = torch.arange(length, dtype=torch.float32)
255 | diff = torch.unsqueeze(r, 0) - torch.unsqueeze(r, 1)
256 | return torch.unsqueeze(torch.unsqueeze(-torch.log1p(torch.abs(diff)), 0), 0)
257 |
258 |
259 | class FFN(nn.Module):
260 | def __init__(self, in_channels, out_channels, filter_channels, kernel_size, p_dropout=0., activation=None):
261 | super().__init__()
262 | self.in_channels = in_channels
263 | self.out_channels = out_channels
264 | self.filter_channels = filter_channels
265 | self.kernel_size = kernel_size
266 | self.p_dropout = p_dropout
267 | self.activation = activation
268 |
269 | self.conv_1 = nn.Conv1d(in_channels, filter_channels, kernel_size, padding=kernel_size//2)
270 | self.conv_2 = nn.Conv1d(filter_channels, out_channels, kernel_size, padding=kernel_size//2)
271 | self.drop = nn.Dropout(p_dropout)
272 |
273 | def forward(self, x, x_mask):
274 | x = self.conv_1(x * x_mask)
275 | if self.activation == "gelu":
276 | x = x * torch.sigmoid(1.702 * x)
277 | else:
278 | x = torch.relu(x)
279 | x = self.drop(x)
280 | x = self.conv_2(x * x_mask)
281 | return x * x_mask
282 |
283 |
--------------------------------------------------------------------------------
/audio_processing.py:
--------------------------------------------------------------------------------
1 | import torch
2 | import numpy as np
3 | from scipy.signal import get_window
4 | import librosa.util as librosa_util
5 |
6 |
7 | def window_sumsquare(window, n_frames, hop_length=200, win_length=800,
8 | n_fft=800, dtype=np.float32, norm=None):
9 | """
10 | # from librosa 0.6
11 | Compute the sum-square envelope of a window function at a given hop length.
12 |
13 | This is used to estimate modulation effects induced by windowing
14 | observations in short-time fourier transforms.
15 |
16 | Parameters
17 | ----------
18 | window : string, tuple, number, callable, or list-like
19 | Window specification, as in `get_window`
20 |
21 | n_frames : int > 0
22 | The number of analysis frames
23 |
24 | hop_length : int > 0
25 | The number of samples to advance between frames
26 |
27 | win_length : [optional]
28 | The length of the window function. By default, this matches `n_fft`.
29 |
30 | n_fft : int > 0
31 | The length of each analysis frame.
32 |
33 | dtype : np.dtype
34 | The data type of the output
35 |
36 | Returns
37 | -------
38 | wss : np.ndarray, shape=`(n_fft + hop_length * (n_frames - 1))`
39 | The sum-squared envelope of the window function
40 | """
41 | if win_length is None:
42 | win_length = n_fft
43 |
44 | n = n_fft + hop_length * (n_frames - 1)
45 | x = np.zeros(n, dtype=dtype)
46 |
47 | # Compute the squared window at the desired length
48 | win_sq = get_window(window, win_length, fftbins=True)
49 | win_sq = librosa_util.normalize(win_sq, norm=norm)**2
50 | win_sq = librosa_util.pad_center(win_sq, n_fft)
51 |
52 | # Fill the envelope
53 | for i in range(n_frames):
54 | sample = i * hop_length
55 | x[sample:min(n, sample + n_fft)] += win_sq[:max(0, min(n_fft, n - sample))]
56 | return x
57 |
58 |
59 | def griffin_lim(magnitudes, stft_fn, n_iters=30):
60 | """
61 | PARAMS
62 | ------
63 | magnitudes: spectrogram magnitudes
64 | stft_fn: STFT class with transform (STFT) and inverse (ISTFT) methods
65 | """
66 |
67 | angles = np.angle(np.exp(2j * np.pi * np.random.rand(*magnitudes.size())))
68 | angles = angles.astype(np.float32)
69 | angles = torch.autograd.Variable(torch.from_numpy(angles))
70 | signal = stft_fn.inverse(magnitudes, angles).squeeze(1)
71 |
72 | for i in range(n_iters):
73 | _, angles = stft_fn.transform(signal)
74 | signal = stft_fn.inverse(magnitudes, angles).squeeze(1)
75 | return signal
76 |
77 |
78 | def dynamic_range_compression(x, C=1, clip_val=1e-5):
79 | """
80 | PARAMS
81 | ------
82 | C: compression factor
83 | """
84 | return torch.log(torch.clamp(x, min=clip_val) * C)
85 |
86 |
87 | def dynamic_range_decompression(x, C=1):
88 | """
89 | PARAMS
90 | ------
91 | C: compression factor used to compress
92 | """
93 | return torch.exp(x) / C
94 |
--------------------------------------------------------------------------------
/commons.py:
--------------------------------------------------------------------------------
1 | import math
2 | import numpy as np
3 | import torch
4 | from torch import nn
5 | from torch.nn import functional as F
6 |
7 | from librosa.filters import mel as librosa_mel_fn
8 | from audio_processing import dynamic_range_compression
9 | from audio_processing import dynamic_range_decompression
10 | from stft import STFT
11 |
12 |
13 | def intersperse(lst, item):
14 | result = [item] * (len(lst) * 2 + 1)
15 | result[1::2] = lst
16 | return result
17 |
18 |
19 | def mle_loss(z, m, logs, logdet, mask):
20 | l = torch.sum(logs) + 0.5 * torch.sum(torch.exp(-2 * logs) * ((z - m)**2)) # neg normal likelihood w/o the constant term
21 | l = l - torch.sum(logdet) # log jacobian determinant
22 | l = l / torch.sum(torch.ones_like(z) * mask) # averaging across batch, channel and time axes
23 | l = l + 0.5 * math.log(2 * math.pi) # add the remaining constant term
24 | return l
25 |
26 |
27 | def duration_loss(logw, logw_, lengths):
28 | l = torch.sum((logw - logw_)**2) / torch.sum(lengths)
29 | return l
30 |
31 |
32 | @torch.jit.script
33 | def fused_add_tanh_sigmoid_multiply(input_a, input_b, n_channels):
34 | n_channels_int = n_channels[0]
35 | in_act = input_a + input_b
36 | t_act = torch.tanh(in_act[:, :n_channels_int, :])
37 | s_act = torch.sigmoid(in_act[:, n_channels_int:, :])
38 | acts = t_act * s_act
39 | return acts
40 |
41 |
42 | def convert_pad_shape(pad_shape):
43 | l = pad_shape[::-1]
44 | pad_shape = [item for sublist in l for item in sublist]
45 | return pad_shape
46 |
47 |
48 | def shift_1d(x):
49 | x = F.pad(x, convert_pad_shape([[0, 0], [0, 0], [1, 0]]))[:, :, :-1]
50 | return x
51 |
52 |
53 | def sequence_mask(length, max_length=None):
54 | if max_length is None:
55 | max_length = length.max()
56 | x = torch.arange(max_length, dtype=length.dtype, device=length.device)
57 | return x.unsqueeze(0) < length.unsqueeze(1)
58 |
59 |
60 | def maximum_path(value, mask, max_neg_val=-np.inf):
61 | """ Numpy-friendly version. It's about 4 times faster than torch version.
62 | value: [b, t_x, t_y]
63 | mask: [b, t_x, t_y]
64 | """
65 | value = value * mask
66 |
67 | device = value.device
68 | dtype = value.dtype
69 | value = value.cpu().detach().numpy()
70 | mask = mask.cpu().detach().numpy().astype(np.bool)
71 |
72 | b, t_x, t_y = value.shape
73 | direction = np.zeros(value.shape, dtype=np.int64)
74 | v = np.zeros((b, t_x), dtype=np.float32)
75 | x_range = np.arange(t_x, dtype=np.float32).reshape(1,-1)
76 | for j in range(t_y):
77 | v0 = np.pad(v, [[0,0],[1,0]], mode="constant", constant_values=max_neg_val)[:, :-1]
78 | v1 = v
79 | max_mask = (v1 >= v0)
80 | v_max = np.where(max_mask, v1, v0)
81 | direction[:, :, j] = max_mask
82 |
83 | index_mask = (x_range <= j)
84 | v = np.where(index_mask, v_max + value[:, :, j], max_neg_val)
85 | direction = np.where(mask, direction, 1)
86 |
87 | path = np.zeros(value.shape, dtype=np.float32)
88 | index = mask[:, :, 0].sum(1).astype(np.int64) - 1
89 | index_range = np.arange(b)
90 | for j in reversed(range(t_y)):
91 | path[index_range, index, j] = 1
92 | index = index + direction[index_range, index, j] - 1
93 | path = path * mask.astype(np.float32)
94 | path = torch.from_numpy(path).to(device=device, dtype=dtype)
95 | return path
96 |
97 |
98 | def generate_path(duration, mask):
99 | """
100 | duration: [b, t_x]
101 | mask: [b, t_x, t_y]
102 | """
103 | device = duration.device
104 |
105 | b, t_x, t_y = mask.shape
106 | cum_duration = torch.cumsum(duration, 1)
107 | path = torch.zeros(b, t_x, t_y, dtype=mask.dtype).to(device=device)
108 |
109 | cum_duration_flat = cum_duration.view(b * t_x)
110 | path = sequence_mask(cum_duration_flat, t_y).to(mask.dtype)
111 | path = path.view(b, t_x, t_y)
112 | path = path - F.pad(path, convert_pad_shape([[0, 0], [1, 0], [0, 0]]))[:,:-1]
113 | path = path * mask
114 | return path
115 |
116 |
117 | class Adam():
118 | def __init__(self, params, scheduler, dim_model, warmup_steps=4000, lr=1e0, betas=(0.9, 0.98), eps=1e-9):
119 | self.params = params
120 | self.scheduler = scheduler
121 | self.dim_model = dim_model
122 | self.warmup_steps = warmup_steps
123 | self.lr = lr
124 | self.betas = betas
125 | self.eps = eps
126 |
127 | self.step_num = 1
128 | self.cur_lr = lr * self._get_lr_scale()
129 |
130 | self._optim = torch.optim.Adam(params, lr=self.cur_lr, betas=betas, eps=eps)
131 |
132 | def _get_lr_scale(self):
133 | if self.scheduler == "noam":
134 | return np.power(self.dim_model, -0.5) * np.min([np.power(self.step_num, -0.5), self.step_num * np.power(self.warmup_steps, -1.5)])
135 | else:
136 | return 1
137 |
138 | def _update_learning_rate(self):
139 | self.step_num += 1
140 | if self.scheduler == "noam":
141 | self.cur_lr = self.lr * self._get_lr_scale()
142 | for param_group in self._optim.param_groups:
143 | param_group['lr'] = self.cur_lr
144 |
145 | def get_lr(self):
146 | return self.cur_lr
147 |
148 | def step(self):
149 | self._optim.step()
150 | self._update_learning_rate()
151 |
152 | def zero_grad(self):
153 | self._optim.zero_grad()
154 |
155 | def load_state_dict(self, d):
156 | self._optim.load_state_dict(d)
157 |
158 | def state_dict(self):
159 | return self._optim.state_dict()
160 |
161 |
162 | class TacotronSTFT(nn.Module):
163 | def __init__(self, filter_length=1024, hop_length=256, win_length=1024,
164 | n_mel_channels=80, sampling_rate=22050, mel_fmin=0.0,
165 | mel_fmax=8000.0):
166 | super(TacotronSTFT, self).__init__()
167 | self.n_mel_channels = n_mel_channels
168 | self.sampling_rate = sampling_rate
169 | self.stft_fn = STFT(filter_length, hop_length, win_length)
170 | mel_basis = librosa_mel_fn(
171 | sampling_rate, filter_length, n_mel_channels, mel_fmin, mel_fmax)
172 | mel_basis = torch.from_numpy(mel_basis).float()
173 | self.register_buffer('mel_basis', mel_basis)
174 |
175 | def spectral_normalize(self, magnitudes):
176 | output = dynamic_range_compression(magnitudes)
177 | return output
178 |
179 | def spectral_de_normalize(self, magnitudes):
180 | output = dynamic_range_decompression(magnitudes)
181 | return output
182 |
183 | def mel_spectrogram(self, y):
184 | """Computes mel-spectrograms from a batch of waves
185 | PARAMS
186 | ------
187 | y: Variable(torch.FloatTensor) with shape (B, T) in range [-1, 1]
188 |
189 | RETURNS
190 | -------
191 | mel_output: torch.FloatTensor of shape (B, n_mel_channels, T)
192 | """
193 | assert(torch.min(y.data) >= -1)
194 | assert(torch.max(y.data) <= 1)
195 |
196 | magnitudes, phases = self.stft_fn.transform(y)
197 | magnitudes = magnitudes.data
198 | mel_output = torch.matmul(self.mel_basis, magnitudes)
199 | mel_output = self.spectral_normalize(mel_output)
200 | return mel_output
201 |
202 |
203 | def clip_grad_value_(parameters, clip_value, norm_type=2):
204 | if isinstance(parameters, torch.Tensor):
205 | parameters = [parameters]
206 | parameters = list(filter(lambda p: p.grad is not None, parameters))
207 | norm_type = float(norm_type)
208 | clip_value = float(clip_value)
209 |
210 | total_norm = 0
211 | for p in parameters:
212 | param_norm = p.grad.data.norm(norm_type)
213 | total_norm += param_norm.item() ** norm_type
214 |
215 | p.grad.data.clamp_(min=-clip_value, max=clip_value)
216 | total_norm = total_norm ** (1. / norm_type)
217 | return total_norm
218 |
219 |
220 | def squeeze(x, x_mask=None, n_sqz=2):
221 | b, c, t = x.size()
222 |
223 | t = (t // n_sqz) * n_sqz
224 | x = x[:,:,:t]
225 | x_sqz = x.view(b, c, t//n_sqz, n_sqz)
226 | x_sqz = x_sqz.permute(0, 3, 1, 2).contiguous().view(b, c*n_sqz, t//n_sqz)
227 |
228 | if x_mask is not None:
229 | x_mask = x_mask[:,:,n_sqz-1::n_sqz]
230 | else:
231 | x_mask = torch.ones(b, 1, t//n_sqz).to(device=x.device, dtype=x.dtype)
232 | return x_sqz * x_mask, x_mask
233 |
234 |
235 | def unsqueeze(x, x_mask=None, n_sqz=2):
236 | b, c, t = x.size()
237 |
238 | x_unsqz = x.view(b, n_sqz, c//n_sqz, t)
239 | x_unsqz = x_unsqz.permute(0, 2, 3, 1).contiguous().view(b, c//n_sqz, t*n_sqz)
240 |
241 | if x_mask is not None:
242 | x_mask = x_mask.unsqueeze(-1).repeat(1,1,1,n_sqz).view(b, 1, t*n_sqz)
243 | else:
244 | x_mask = torch.ones(b, 1, t*n_sqz).to(device=x.device, dtype=x.dtype)
245 | return x_unsqz * x_mask, x_mask
246 |
247 |
--------------------------------------------------------------------------------
/configs/base.json:
--------------------------------------------------------------------------------
1 | {
2 | "train": {
3 | "use_cuda": true,
4 | "log_interval": 20,
5 | "seed": 1234,
6 | "epochs": 10000,
7 | "learning_rate": 1e0,
8 | "betas": [0.9, 0.98],
9 | "eps": 1e-9,
10 | "warmup_steps": 4000,
11 | "scheduler": "noam",
12 | "batch_size": 32,
13 | "ddi": true,
14 | "fp16_run": true
15 | },
16 | "data": {
17 | "load_mel_from_disk": false,
18 | "training_files":"filelists/ljs_audio_text_train_filelist.txt",
19 | "validation_files":"filelists/ljs_audio_text_val_filelist.txt",
20 | "text_cleaners":["english_cleaners"],
21 | "max_wav_value": 32768.0,
22 | "sampling_rate": 22050,
23 | "filter_length": 1024,
24 | "hop_length": 256,
25 | "win_length": 1024,
26 | "n_mel_channels": 80,
27 | "mel_fmin": 0.0,
28 | "mel_fmax": 8000.0,
29 | "add_noise": true,
30 | "cmudict_path": "data/cmu_dictionary"
31 | },
32 | "model": {
33 | "hidden_channels": 192,
34 | "filter_channels": 768,
35 | "filter_channels_dp": 256,
36 | "kernel_size": 3,
37 | "p_dropout": 0.1,
38 | "n_blocks_dec": 12,
39 | "n_layers_enc": 6,
40 | "n_heads": 2,
41 | "p_dropout_dec": 0.05,
42 | "dilation_rate": 1,
43 | "kernel_size_dec": 5,
44 | "n_block_layers": 4,
45 | "n_sqz": 2,
46 | "prenet": true,
47 | "mean_only": true,
48 | "hidden_channels_enc": 192,
49 | "hidden_channels_dec": 192,
50 | "window_size": 4
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/configs/base_blank.json:
--------------------------------------------------------------------------------
1 | {
2 | "train": {
3 | "use_cuda": true,
4 | "log_interval": 20,
5 | "seed": 1234,
6 | "epochs": 10000,
7 | "learning_rate": 1e0,
8 | "betas": [0.9, 0.98],
9 | "eps": 1e-9,
10 | "warmup_steps": 4000,
11 | "scheduler": "noam",
12 | "batch_size": 32,
13 | "ddi": true,
14 | "fp16_run": true
15 | },
16 | "data": {
17 | "load_mel_from_disk": false,
18 | "training_files":"filelists/ljs_audio_text_train_filelist.txt",
19 | "validation_files":"filelists/ljs_audio_text_val_filelist.txt",
20 | "text_cleaners":["english_cleaners"],
21 | "max_wav_value": 32768.0,
22 | "sampling_rate": 22050,
23 | "filter_length": 1024,
24 | "hop_length": 256,
25 | "win_length": 1024,
26 | "n_mel_channels": 80,
27 | "mel_fmin": 0.0,
28 | "mel_fmax": 8000.0,
29 | "add_noise": true,
30 | "add_blank": true,
31 | "cmudict_path": "data/cmu_dictionary"
32 | },
33 | "model": {
34 | "hidden_channels": 192,
35 | "filter_channels": 768,
36 | "filter_channels_dp": 256,
37 | "kernel_size": 3,
38 | "p_dropout": 0.1,
39 | "n_blocks_dec": 12,
40 | "n_layers_enc": 6,
41 | "n_heads": 2,
42 | "p_dropout_dec": 0.05,
43 | "dilation_rate": 1,
44 | "kernel_size_dec": 5,
45 | "n_block_layers": 4,
46 | "n_sqz": 2,
47 | "prenet": true,
48 | "mean_only": true,
49 | "hidden_channels_enc": 192,
50 | "hidden_channels_dec": 192,
51 | "window_size": 4
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/data/cmu_dictionary:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaywalnut310/glow-tts/13e997689d643410f5d9f1f9a73877ae85e19bc2/data/cmu_dictionary
--------------------------------------------------------------------------------
/data_utils.py:
--------------------------------------------------------------------------------
1 | import random
2 | import numpy as np
3 | import torch
4 | import torch.utils.data
5 |
6 | import commons
7 | from utils import load_wav_to_torch, load_filepaths_and_text
8 | from text import text_to_sequence, cmudict
9 | from text.symbols import symbols
10 |
11 |
12 | class TextMelLoader(torch.utils.data.Dataset):
13 | """
14 | 1) loads audio,text pairs
15 | 2) normalizes text and converts them to sequences of one-hot vectors
16 | 3) computes mel-spectrograms from audio files.
17 | """
18 | def __init__(self, audiopaths_and_text, hparams):
19 | self.audiopaths_and_text = load_filepaths_and_text(audiopaths_and_text)
20 | self.text_cleaners = hparams.text_cleaners
21 | self.max_wav_value = hparams.max_wav_value
22 | self.sampling_rate = hparams.sampling_rate
23 | self.load_mel_from_disk = hparams.load_mel_from_disk
24 | self.add_noise = hparams.add_noise
25 | self.add_blank = getattr(hparams, "add_blank", False) # improved version
26 | if getattr(hparams, "cmudict_path", None) is not None:
27 | self.cmudict = cmudict.CMUDict(hparams.cmudict_path)
28 | self.stft = commons.TacotronSTFT(
29 | hparams.filter_length, hparams.hop_length, hparams.win_length,
30 | hparams.n_mel_channels, hparams.sampling_rate, hparams.mel_fmin,
31 | hparams.mel_fmax)
32 | random.seed(1234)
33 | random.shuffle(self.audiopaths_and_text)
34 |
35 | def get_mel_text_pair(self, audiopath_and_text):
36 | # separate filename and text
37 | audiopath, text = audiopath_and_text[0], audiopath_and_text[1]
38 | text = self.get_text(text)
39 | mel = self.get_mel(audiopath)
40 | return (text, mel)
41 |
42 | def get_mel(self, filename):
43 | if not self.load_mel_from_disk:
44 | audio, sampling_rate = load_wav_to_torch(filename)
45 | if sampling_rate != self.stft.sampling_rate:
46 | raise ValueError("{} {} SR doesn't match target {} SR".format(
47 | sampling_rate, self.stft.sampling_rate))
48 | if self.add_noise:
49 | audio = audio + torch.rand_like(audio)
50 | audio_norm = audio / self.max_wav_value
51 | audio_norm = audio_norm.unsqueeze(0)
52 | melspec = self.stft.mel_spectrogram(audio_norm)
53 | melspec = torch.squeeze(melspec, 0)
54 | else:
55 | melspec = torch.from_numpy(np.load(filename))
56 | assert melspec.size(0) == self.stft.n_mel_channels, (
57 | 'Mel dimension mismatch: given {}, expected {}'.format(
58 | melspec.size(0), self.stft.n_mel_channels))
59 |
60 | return melspec
61 |
62 | def get_text(self, text):
63 | text_norm = text_to_sequence(text, self.text_cleaners, getattr(self, "cmudict", None))
64 | if self.add_blank:
65 | text_norm = commons.intersperse(text_norm, len(symbols)) # add a blank token, whose id number is len(symbols)
66 | text_norm = torch.IntTensor(text_norm)
67 | return text_norm
68 |
69 | def __getitem__(self, index):
70 | return self.get_mel_text_pair(self.audiopaths_and_text[index])
71 |
72 | def __len__(self):
73 | return len(self.audiopaths_and_text)
74 |
75 |
76 | class TextMelCollate():
77 | """ Zero-pads model inputs and targets based on number of frames per step
78 | """
79 | def __init__(self, n_frames_per_step=1):
80 | self.n_frames_per_step = n_frames_per_step
81 |
82 | def __call__(self, batch):
83 | """Collate's training batch from normalized text and mel-spectrogram
84 | PARAMS
85 | ------
86 | batch: [text_normalized, mel_normalized]
87 | """
88 | # Right zero-pad all one-hot text sequences to max input length
89 | input_lengths, ids_sorted_decreasing = torch.sort(
90 | torch.LongTensor([len(x[0]) for x in batch]),
91 | dim=0, descending=True)
92 | max_input_len = input_lengths[0]
93 |
94 | text_padded = torch.LongTensor(len(batch), max_input_len)
95 | text_padded.zero_()
96 | for i in range(len(ids_sorted_decreasing)):
97 | text = batch[ids_sorted_decreasing[i]][0]
98 | text_padded[i, :text.size(0)] = text
99 |
100 | # Right zero-pad mel-spec
101 | num_mels = batch[0][1].size(0)
102 | max_target_len = max([x[1].size(1) for x in batch])
103 | if max_target_len % self.n_frames_per_step != 0:
104 | max_target_len += self.n_frames_per_step - max_target_len % self.n_frames_per_step
105 | assert max_target_len % self.n_frames_per_step == 0
106 |
107 | # include mel padded
108 | mel_padded = torch.FloatTensor(len(batch), num_mels, max_target_len)
109 | mel_padded.zero_()
110 | output_lengths = torch.LongTensor(len(batch))
111 | for i in range(len(ids_sorted_decreasing)):
112 | mel = batch[ids_sorted_decreasing[i]][1]
113 | mel_padded[i, :, :mel.size(1)] = mel
114 | output_lengths[i] = mel.size(1)
115 |
116 | return text_padded, input_lengths, mel_padded, output_lengths
117 |
118 |
119 | """Multi speaker version"""
120 | class TextMelSpeakerLoader(torch.utils.data.Dataset):
121 | """
122 | 1) loads audio, speaker_id, text pairs
123 | 2) normalizes text and converts them to sequences of one-hot vectors
124 | 3) computes mel-spectrograms from audio files.
125 | """
126 | def __init__(self, audiopaths_sid_text, hparams):
127 | self.audiopaths_sid_text = load_filepaths_and_text(audiopaths_sid_text)
128 | self.text_cleaners = hparams.text_cleaners
129 | self.max_wav_value = hparams.max_wav_value
130 | self.sampling_rate = hparams.sampling_rate
131 | self.load_mel_from_disk = hparams.load_mel_from_disk
132 | self.add_noise = hparams.add_noise
133 | self.add_blank = getattr(hparams, "add_blank", False) # improved version
134 | self.min_text_len = getattr(hparams, "min_text_len", 1)
135 | self.max_text_len = getattr(hparams, "max_text_len", 190)
136 | if getattr(hparams, "cmudict_path", None) is not None:
137 | self.cmudict = cmudict.CMUDict(hparams.cmudict_path)
138 | self.stft = commons.TacotronSTFT(
139 | hparams.filter_length, hparams.hop_length, hparams.win_length,
140 | hparams.n_mel_channels, hparams.sampling_rate, hparams.mel_fmin,
141 | hparams.mel_fmax)
142 |
143 | self._filter_text_len()
144 | random.seed(1234)
145 | random.shuffle(self.audiopaths_sid_text)
146 |
147 | def _filter_text_len(self):
148 | audiopaths_sid_text_new = []
149 | for audiopath, sid, text in self.audiopaths_sid_text:
150 | if self.min_text_len <= len(text) and len(text) <= self.max_text_len:
151 | audiopaths_sid_text_new.append([audiopath, sid, text])
152 | self.audiopaths_sid_text = audiopaths_sid_text_new
153 |
154 | def get_mel_text_speaker_pair(self, audiopath_sid_text):
155 | # separate filename, speaker_id and text
156 | audiopath, sid, text = audiopath_sid_text[0], audiopath_sid_text[1], audiopath_sid_text[2]
157 | text = self.get_text(text)
158 | mel = self.get_mel(audiopath)
159 | sid = self.get_sid(sid)
160 | return (text, mel, sid)
161 |
162 | def get_mel(self, filename):
163 | if not self.load_mel_from_disk:
164 | audio, sampling_rate = load_wav_to_torch(filename)
165 | if sampling_rate != self.stft.sampling_rate:
166 | raise ValueError("{} {} SR doesn't match target {} SR".format(
167 | sampling_rate, self.stft.sampling_rate))
168 | if self.add_noise:
169 | audio = audio + torch.rand_like(audio)
170 | audio_norm = audio / self.max_wav_value
171 | audio_norm = audio_norm.unsqueeze(0)
172 | melspec = self.stft.mel_spectrogram(audio_norm)
173 | melspec = torch.squeeze(melspec, 0)
174 | else:
175 | melspec = torch.from_numpy(np.load(filename))
176 | assert melspec.size(0) == self.stft.n_mel_channels, (
177 | 'Mel dimension mismatch: given {}, expected {}'.format(
178 | melspec.size(0), self.stft.n_mel_channels))
179 |
180 | return melspec
181 |
182 | def get_text(self, text):
183 | text_norm = text_to_sequence(text, self.text_cleaners, getattr(self, "cmudict", None))
184 | if self.add_blank:
185 | text_norm = commons.intersperse(text_norm, len(symbols)) # add a blank token, whose id number is len(symbols)
186 | text_norm = torch.IntTensor(text_norm)
187 | return text_norm
188 |
189 | def get_sid(self, sid):
190 | sid = torch.IntTensor([int(sid)])
191 | return sid
192 |
193 | def __getitem__(self, index):
194 | return self.get_mel_text_speaker_pair(self.audiopaths_sid_text[index])
195 |
196 | def __len__(self):
197 | return len(self.audiopaths_sid_text)
198 |
199 |
200 | class TextMelSpeakerCollate():
201 | """ Zero-pads model inputs and targets based on number of frames per step
202 | """
203 | def __init__(self, n_frames_per_step=1):
204 | self.n_frames_per_step = n_frames_per_step
205 |
206 | def __call__(self, batch):
207 | """Collate's training batch from normalized text and mel-spectrogram
208 | PARAMS
209 | ------
210 | batch: [text_normalized, mel_normalized]
211 | """
212 | # Right zero-pad all one-hot text sequences to max input length
213 | input_lengths, ids_sorted_decreasing = torch.sort(
214 | torch.LongTensor([len(x[0]) for x in batch]),
215 | dim=0, descending=True)
216 | max_input_len = input_lengths[0]
217 |
218 | text_padded = torch.LongTensor(len(batch), max_input_len)
219 | text_padded.zero_()
220 | for i in range(len(ids_sorted_decreasing)):
221 | text = batch[ids_sorted_decreasing[i]][0]
222 | text_padded[i, :text.size(0)] = text
223 |
224 | # Right zero-pad mel-spec
225 | num_mels = batch[0][1].size(0)
226 | max_target_len = max([x[1].size(1) for x in batch])
227 | if max_target_len % self.n_frames_per_step != 0:
228 | max_target_len += self.n_frames_per_step - max_target_len % self.n_frames_per_step
229 | assert max_target_len % self.n_frames_per_step == 0
230 |
231 | # include mel padded & sid
232 | mel_padded = torch.FloatTensor(len(batch), num_mels, max_target_len)
233 | mel_padded.zero_()
234 | output_lengths = torch.LongTensor(len(batch))
235 | sid = torch.LongTensor(len(batch))
236 | for i in range(len(ids_sorted_decreasing)):
237 | mel = batch[ids_sorted_decreasing[i]][1]
238 | mel_padded[i, :, :mel.size(1)] = mel
239 | output_lengths[i] = mel.size(1)
240 | sid[i] = batch[ids_sorted_decreasing[i]][2]
241 |
242 | return text_padded, input_lengths, mel_padded, output_lengths, sid
243 |
--------------------------------------------------------------------------------
/filelists/ljs_audio_text_test_filelist.txt:
--------------------------------------------------------------------------------
1 | DUMMY/LJ045-0096.wav|Mrs. De Mohrenschildt thought that Oswald,
2 | DUMMY/LJ049-0022.wav|The Secret Service believed that it was very doubtful that any President would ride regularly in a vehicle with a fixed top, even though transparent.
3 | DUMMY/LJ033-0042.wav|Between the hours of eight and nine p.m. they were occupied with the children in the bedrooms located at the extreme east end of the house.
4 | DUMMY/LJ016-0117.wav|The prisoner had nothing to deal with but wooden panels, and by dint of cutting and chopping he got both the lower panels out.
5 | DUMMY/LJ025-0157.wav|Under these circumstances, unnatural as they are, with proper management, the bean will thrust forth its radicle and its plumule;
6 | DUMMY/LJ042-0219.wav|Oswald demonstrated his thinking in connection with his return to the United States by preparing two sets of identical questions of the type which he might have thought
7 | DUMMY/LJ032-0164.wav|it is not possible to state with scientific certainty that a particular small group of fibers come from a certain piece of clothing
8 | DUMMY/LJ046-0092.wav|has confidence in the dedicated Secret Service men who are ready to lay down their lives for him
9 | DUMMY/LJ050-0118.wav|Since these agencies are already obliged constantly to evaluate the activities of such groups,
10 | DUMMY/LJ043-0016.wav|Jeanne De Mohrenschildt said, quote,
11 | DUMMY/LJ021-0078.wav|no economic panacea, which could simply revive over-night the heavy industries and the trades dependent upon them.
12 | DUMMY/LJ039-0148.wav|Examination of the cartridge cases found on the sixth floor of the Depository Building
13 | DUMMY/LJ047-0202.wav|testified that the information available to the Federal Government about Oswald before the assassination would, if known to PRS,
14 | DUMMY/LJ023-0056.wav|It is an easy document to understand when you remember that it was called into being
15 | DUMMY/LJ021-0025.wav|And in many directions, the intervention of that organized control which we call government
16 | DUMMY/LJ030-0105.wav|Communications in the motorcade.
17 | DUMMY/LJ021-0012.wav|with respect to industry and business, but nearly all are agreed that private enterprise in times such as these
18 | DUMMY/LJ019-0169.wav|and one or two men were allowed to mend clothes and make shoes. The rules made by the Secretary of State were hung up in conspicuous parts of the prison;
19 | DUMMY/LJ039-0088.wav|It just is an aid in seeing in the fact that you only have the one element, the crosshair,
20 | DUMMY/LJ016-0192.wav|"I think I could do that sort of job," said Calcraft, on the spur of the moment.
21 | DUMMY/LJ014-0142.wav|was strewn in front of the dock, and sprinkled it towards the bench with a contemptuous gesture.
22 | DUMMY/LJ012-0015.wav|Weedon and Lecasser to twelve and six months respectively in Coldbath Fields.
23 | DUMMY/LJ048-0033.wav|Prior to November twenty-two, nineteen sixty-three
24 | DUMMY/LJ028-0349.wav|who were each required to send so large a number to Babylon, that in all there were collected no fewer than fifty thousand.
25 | DUMMY/LJ030-0197.wav|At first Mrs. Connally thought that her husband had been killed,
26 | DUMMY/LJ017-0133.wav|Palmer speedily found imitators.
27 | DUMMY/LJ034-0123.wav|Although Brennan testified that the man in the window was standing when he fired the shots, most probably he was either sitting or kneeling.
28 | DUMMY/LJ003-0282.wav|Many years were to elapse before these objections should be fairly met and universally overcome.
29 | DUMMY/LJ032-0204.wav|Special Agent Lyndal L. Shaneyfelt, a photography expert with the FBI,
30 | DUMMY/LJ016-0241.wav|Calcraft served the city of London till eighteen seventy-four, when he was pensioned at the rate of twenty-five shillings per week.
31 | DUMMY/LJ023-0033.wav|we will not allow ourselves to run around in new circles of futile discussion and debate, always postponing the day of decision.
32 | DUMMY/LJ009-0286.wav|There has never been much science in the system of carrying out the extreme penalty in this country; the "finisher of the law"
33 | DUMMY/LJ008-0181.wav|he had his pockets filled with bread and cheese, and it was generally supposed that he had come a long distance to see the fatal show.
34 | DUMMY/LJ015-0052.wav|to the value of twenty thousand pounds.
35 | DUMMY/LJ016-0314.wav|Sir George Grey thought there was a growing feeling in favor of executions within the prison precincts.
36 | DUMMY/LJ047-0056.wav|From August nineteen sixty-two
37 | DUMMY/LJ010-0027.wav|Nor did the methods by which they were perpetrated greatly vary from those in times past.
38 | DUMMY/LJ010-0065.wav|At the former the "Provisional Government" was to be established,
39 | DUMMY/LJ046-0113.wav|The Commission has concluded that at the time of the assassination
40 | DUMMY/LJ028-0410.wav|There among the ruins they still live in the same kind of houses,
41 | DUMMY/LJ044-0137.wav|More seriously, the facts of his defection had become known, leaving him open to almost unanswerable attack by those who opposed his views.
42 | DUMMY/LJ008-0215.wav|One by one the huge uprights of black timber were fitted together,
43 | DUMMY/LJ030-0084.wav|or when the press of the crowd made it impossible for the escort motorcycles to stay in position on the car's rear flanks.
44 | DUMMY/LJ020-0092.wav|Have yourself called on biscuit mornings an hour earlier than usual.
45 | DUMMY/LJ029-0096.wav|On November fourteen, Lawson and Sorrels attended a meeting at Love Field
46 | DUMMY/LJ015-0308.wav|and others who swore to the meetings of the conspirators and their movements. Saward was found guilty,
47 | DUMMY/LJ012-0067.wav|But Mrs. Solomons could not resist the temptation to dabble in stolen goods, and she was found shipping watches of the wrong category to New York.
48 | DUMMY/LJ018-0231.wav|namely, to suppress it and substitute another.
49 | DUMMY/LJ014-0265.wav|and later he became manager of the newly rebuilt Olympic at Wych Street.
50 | DUMMY/LJ024-0102.wav|would be the first to exclaim as soon as an amendment was proposed
51 | DUMMY/LJ007-0233.wav|it consists of several circular perforations, about two inches in diameter,
52 | DUMMY/LJ013-0213.wav|This seems to have decided Courvoisier,
53 | DUMMY/LJ032-0045.wav|This price included nineteen dollars, ninety-five cents for the rifle and the scope, and one dollar, fifty cents for postage and handling.
54 | DUMMY/LJ011-0048.wav|Wherefore let him that thinketh he standeth take heed lest he fall," and was full of the most pointed allusions to the culprit.
55 | DUMMY/LJ005-0294.wav|It was frequently stated in evidence that the jail of the borough was in so unfit a state for the reception of prisoners,
56 | DUMMY/LJ016-0007.wav|There were others less successful.
57 | DUMMY/LJ028-0138.wav|perhaps the tales that travelers told him were exaggerated as travelers' tales are likely to be,
58 | DUMMY/LJ050-0029.wav|that is reflected in definite and comprehensive operating procedures.
59 | DUMMY/LJ014-0121.wav|The prisoners were in due course transferred to Newgate, to be put upon their trial at the Central Criminal Court.
60 | DUMMY/LJ014-0146.wav|They had to handcuff her by force against the most violent resistance, and still she raged and stormed,
61 | DUMMY/LJ046-0111.wav|The Secret Service has attempted to perform this function through the activities of its Protective Research Section
62 | DUMMY/LJ012-0257.wav|But the affair still remained a profound mystery. No light was thrown upon it till, towards the end of March,
63 | DUMMY/LJ002-0260.wav|Yet the public opinion of the whole body seems to have checked dissipation.
64 | DUMMY/LJ031-0014.wav|the Presidential limousine arrived at the emergency entrance of the Parkland Hospital at about twelve:thirty-five p.m.
65 | DUMMY/LJ047-0093.wav|Oswald was arrested and jailed by the New Orleans Police Department for disturbing the peace, in connection with a street fight which broke out when he was accosted
66 | DUMMY/LJ003-0324.wav|gaming of all sorts should be peremptorily forbidden under heavy pains and penalties.
67 | DUMMY/LJ021-0115.wav|we have reached into the heart of the problem which is to provide such annual earnings for the lowest paid worker as will meet his minimum needs.
68 | DUMMY/LJ046-0191.wav|it had established periodic regular review of the status of four hundred individuals;
69 | DUMMY/LJ034-0197.wav|who was one of the first witnesses to alert the police to the Depository as the source of the shots, as has been discussed in chapter three.
70 | DUMMY/LJ002-0253.wav|were governed by rules which they themselves had framed, and under which subscriptions were levied
71 | DUMMY/LJ048-0288.wav|might have been more alert in the Dallas motorcade if they had retired promptly in Fort Worth.
72 | DUMMY/LJ007-0112.wav|Many of the old customs once prevalent in the State Side, so properly condemned and abolished,
73 | DUMMY/LJ017-0189.wav|who was presently attacked in the same way as the others, but, but, thanks to the prompt administration of remedies, he recovered.
74 | DUMMY/LJ042-0230.wav|basically, although I hate the USSR and socialist system I still think marxism can work under different circumstances, end quote.
75 | DUMMY/LJ050-0161.wav|The Secret Service should not and does not plan to develop its own intelligence gathering facilities to duplicate the existing facilities of other Federal agencies.
76 | DUMMY/LJ003-0011.wav|that not more than one bottle of wine or one quart of beer could be issued at one time. No account was taken of the amount of liquors admitted in one day,
77 | DUMMY/LJ008-0206.wav|and caused a number of stout additional barriers to be erected in front of the scaffold,
78 | DUMMY/LJ002-0261.wav|The poorer prisoners were not in abject want, as in other prisons,
79 | DUMMY/LJ012-0189.wav|Hunt, in consideration of the information he had given, escaped death, and was sentenced to transportation for life.
80 | DUMMY/LJ019-0317.wav|The former, which consisted principally of the tread-wheel, cranks, capstans, shot-drill,
81 | DUMMY/LJ011-0041.wav|Visited Mr. Fauntleroy. My application for books for him not having been attended, I had no prayer-book to give him.
82 | DUMMY/LJ023-0089.wav|That is not only my accusation.
83 | DUMMY/LJ044-0224.wav|would not agree with that particular wording, end quote.
84 | DUMMY/LJ013-0104.wav|He found them at length residing at the latter place, one as a landed proprietor, the other as a publican.
85 | DUMMY/LJ013-0055.wav|The jury did not believe him, and the verdict was for the defendants.
86 | DUMMY/LJ014-0306.wav|These had been attributed to political action; some thought that the large purchases in foreign grains, effected at losing prices,
87 | DUMMY/LJ029-0052.wav|To supplement the PRS files, the Secret Service depends largely on local police departments and local offices of other Federal agencies
88 | DUMMY/LJ028-0459.wav|Its bricks, measuring about thirteen inches square and three inches in thickness, were burned and stamped with the usual short inscription:
89 | DUMMY/LJ017-0183.wav|Soon afterwards Dixon died, showing all the symptoms already described.
90 | DUMMY/LJ009-0084.wav|At length the ordinary pauses, and then, in a deep tone, which, though hardly above a whisper, is audible to all, says,
91 | DUMMY/LJ007-0170.wav|That in this vast metropolis, the center of wealth, civilization, and information;
92 | DUMMY/LJ016-0277.wav|This is proved by contemporary accounts, especially one graphic and realistic article which appeared in the 'Times,'
93 | DUMMY/LJ009-0061.wav|He staggers towards the pew, reels into it, stumbles forward, flings himself on the ground, and, by a curious twist of the spine,
94 | DUMMY/LJ019-0201.wav|to select a sufficiently spacious piece of ground, and erect a prison which from foundations to roofs should be in conformity with the newest ideas.
95 | DUMMY/LJ030-0063.wav|He had repeated this wish only a few days before, during his visit to Tampa, Florida.
96 | DUMMY/LJ010-0257.wav|a third miscreant made a similar but far less serious attempt in the month of July following.
97 | DUMMY/LJ009-0106.wav|The keeper tries to appear unmoved, but his eye wanders anxiously over the combustible assembly.
98 | DUMMY/LJ008-0121.wav|After the construction and action of the machine had been explained, the doctor asked the governor what kind of men he had commanded at Goree,
99 | DUMMY/LJ050-0069.wav|the Secret Service had received from the FBI some nine thousand reports on members of the Communist Party.
100 | DUMMY/LJ006-0202.wav|The news-vendor was also a tobacconist,
101 | DUMMY/LJ012-0230.wav|Shortly before the day fixed for execution, Bishop made a full confession, the bulk of which bore the impress of truth,
102 | DUMMY/LJ005-0248.wav|and stated that in his opinion Newgate, as the common jail of Middlesex, was wholly inadequate to the proper confinement of its prisoners.
103 | DUMMY/LJ037-0053.wav|who had been greatly upset by her experience, was able to view a lineup of four men handcuffed together at the police station.
104 | DUMMY/LJ045-0177.wav|For the first time
105 | DUMMY/LJ004-0036.wav|it was hoped that their rulers would hire accommodation in the county prisons, and that the inferior establishments would in course of time disappear.
106 | DUMMY/LJ026-0054.wav|carbohydrates (starch, cellulose) and fats.
107 | DUMMY/LJ020-0085.wav|Break apart from one another and pile on a plate, throwing a clean doily or a small napkin over them. Break open at table.
108 | DUMMY/LJ046-0226.wav|The several military intelligence agencies reported crank mail and similar threats involving the President.
109 | DUMMY/LJ014-0233.wav|he shot an old soldier who had attempted to detain him. He was convicted and executed.
110 | DUMMY/LJ033-0152.wav|The portion of the palm which was identified was the heel of the right palm, i.e., the area near the wrist, on the little finger side.
111 | DUMMY/LJ004-0009.wav|as indefatigable and self-sacrificing, found by personal visitation that the condition of jails throughout the kingdom was,
112 | DUMMY/LJ017-0134.wav|Within a few weeks occurred the Leeds poisoning case, in which the murderer undoubtedly was inspired by the facts made public at Palmer's trial.
113 | DUMMY/LJ019-0318.wav|was to be the rule for all convicted prisoners throughout the early stages of their detention;
114 | DUMMY/LJ020-0093.wav|Rise, wash face and hands, rinse the mouth out and brush back the hair.
115 | DUMMY/LJ012-0188.wav|Probert was then admitted as a witness, and the case was fully proved against Thurtell, who was hanged in front of Hertford Jail.
116 | DUMMY/LJ019-0202.wav|The preference given to the Pentonville system destroyed all hopes of a complete reformation of Newgate.
117 | DUMMY/LJ039-0027.wav|Oswald's revolver
118 | DUMMY/LJ040-0176.wav|He admitted to fantasies about being powerful and sometimes hurting and killing people, but refused to elaborate on them.
119 | DUMMY/LJ018-0354.wav|Doubts were long entertained whether Thomas Wainwright,
120 | DUMMY/LJ031-0185.wav|From the Presidential airplane, the Vice President telephoned Attorney General Robert F. Kennedy,
121 | DUMMY/LJ006-0137.wav|They were not obliged to attend chapel, and seldom if ever went; "prisoners," said one of them under examination, "did not like the trouble of going to chapel."
122 | DUMMY/LJ032-0085.wav|The Hidell signature on the notice of classification was in the handwriting of Oswald.
123 | DUMMY/LJ009-0037.wav|the schoolmaster and the juvenile prisoners being seated round the communion-table, opposite the pulpit.
124 | DUMMY/LJ006-0021.wav|Later on he had devoted himself to the personal investigation of the prisons of the United States.
125 | DUMMY/LJ006-0082.wav|and this particular official took excellent care to select as residents for his own ward those most suitable from his own point of view.
126 | DUMMY/LJ016-0380.wav|with hope to the last. There is always the chance of a flaw in the indictment, of a missing witness, or extenuating circumstances.
127 | DUMMY/LJ019-0344.wav|monitor, or schoolmaster, nor to be engaged in the service of any officer of the prison.
128 | DUMMY/LJ019-0161.wav|These disciplinary improvements were, however, only slowly and gradually introduced.
129 | DUMMY/LJ028-0145.wav|And here I may not omit to tell the use to which the mould dug out of the great moat was turned, nor the manner wherein the wall was wrought.
130 | DUMMY/LJ018-0349.wav|His disclaimer, distinct and detailed on every point, was intended simply for effect.
131 | DUMMY/LJ043-0010.wav|Some of the members of that group saw a good deal of the Oswalds through the fall of nineteen sixty-three,
132 | DUMMY/LJ027-0178.wav|These were undoubtedly perennibranchs. In the Permian and Triassic higher forms appeared, which were certainly caducibranch.
133 | DUMMY/LJ041-0070.wav|He did not rise above the rank of private first class, even though he had passed a qualifying examination for the rank of corporal.
134 | DUMMY/LJ008-0266.wav|Thus in the years between May first, eighteen twenty-seven, and thirtieth April, eighteen thirty-one,
135 | DUMMY/LJ021-0091.wav|In this recent reorganization we have recognized three distinct functions:
136 | DUMMY/LJ019-0129.wav|which marked the growth of public interest in prison affairs, and which was the germ of the new system
137 | DUMMY/LJ018-0215.wav|William Roupell was the eldest but illegitimate son of a wealthy man who subsequently married Roupell's mother, and had further legitimate issue.
138 | DUMMY/LJ015-0194.wav|and behaved so as to justify a belief that he had been a jail-bird all his life.
139 | DUMMY/LJ016-0137.wav|that numbers of men, "lifers," and others with ten, fourteen, or twenty years to do, can be trusted to work out of doors without bolts and bars
140 | DUMMY/LJ002-0289.wav|the latter raised eighteen pence among them to pay for a truss of straw for the poor woman to lie on.
141 | DUMMY/LJ023-0016.wav|In nineteen thirty-three you and I knew that we must never let our economic system get completely out of joint again
142 | DUMMY/LJ011-0141.wav|There were at the moment in Newgate six convicts sentenced to death for forging wills.
143 | DUMMY/LJ016-0283.wav|to do them mere justice, there was at least till then a half-drunken ribald gaiety among the crowd that made them all akin."
144 | DUMMY/LJ035-0082.wav|The only interval was the time necessary to ride in the elevator from the second to the sixth floor and walk back to the southeast corner.
145 | DUMMY/LJ045-0194.wav|Anyone who was familiar with that area of Dallas would have known that the motorcade would probably pass the Texas School Book Depository to get from Main Street
146 | DUMMY/LJ009-0124.wav|occupied when they saw it last, but a few hours ago, by their comrades who are now dead;
147 | DUMMY/LJ030-0162.wav|In the Presidential Limousine
148 | DUMMY/LJ050-0223.wav|The plan provides for an additional two hundred five agents for the Secret Service. Seventeen of this number are proposed for the Protective Research Section;
149 | DUMMY/LJ008-0228.wav|their harsh and half-cracked voices full of maudlin, besotted sympathy for those about to die.
150 | DUMMY/LJ002-0096.wav|The eight courts above enumerated were well supplied with water;
151 | DUMMY/LJ018-0288.wav|After this the other conspirators traveled to obtain genuine bills and master the system of the leading houses at home and abroad.
152 | DUMMY/LJ002-0106.wav|in which latterly a copper had been fixed for the cooking of provisions sent in by charitable persons.
153 | DUMMY/LJ025-0129.wav|On each lobe of the bi-lobed leaf of Venus flytrap are three delicate filaments which stand out at right angles from the surface of the leaf.
154 | DUMMY/LJ044-0013.wav|Hands Off Cuba, end quote, an application form for, and a membership card in,
155 | DUMMY/LJ049-0115.wav|of the person who is actually in the exercise of the executive power, or
156 | DUMMY/LJ019-0145.wav|But reformation was only skin deep. Below the surface many of the old evils still rankled.
157 | DUMMY/LJ019-0355.wav|came up in all respects to modern requirements.
158 | DUMMY/LJ019-0289.wav|There was unrestrained association of untried and convicted, juvenile with adult prisoners, vagrants, misdemeanants, felons.
159 | DUMMY/LJ048-0222.wav|in Fort Worth, there occurred a breach of discipline by some members of the Secret Service who were officially traveling with the President.
160 | DUMMY/LJ016-0367.wav|Under the new system the whole of the arrangements from first to last fell upon the officers.
161 | DUMMY/LJ047-0097.wav|Agent Quigley did not know of Oswald's prior FBI record when he interviewed him,
162 | DUMMY/LJ007-0075.wav|as effectually to rebuke and abash the profane spirit of the more insolent and daring of the criminals.
163 | DUMMY/LJ047-0022.wav|provided by other agencies.
164 | DUMMY/LJ007-0085.wav|at Newgate and York Castle as long as five years; "at Ilchester and Morpeth for seven years; at Warwick for eight years,
165 | DUMMY/LJ047-0075.wav|Hosty had inquired earlier and found no evidence that it was functioning in the Dallas area.
166 | DUMMY/LJ008-0098.wav|One was the "yeoman of the halter," a Newgate official, the executioner's assistant, whom Mr. J. T. Smith, who was present at the execution,
167 | DUMMY/LJ017-0102.wav|The second attack was fatal, and ended in Cook's death from tetanus.
168 | DUMMY/LJ046-0105.wav|Second, the adequacy of other advance preparations for the security of the President, during his visit to Dallas,
169 | DUMMY/LJ018-0206.wav|He was a tall, slender man, with a long face and iron-gray hair.
170 | DUMMY/LJ012-0271.wav|Whether it was greed or a quarrel that drove Greenacre to the desperate deed remains obscure.
171 | DUMMY/LJ005-0086.wav|with such further separation as the justices should deem conducive to good order and discipline.
172 | DUMMY/LJ042-0097.wav|and considerably better living quarters than those accorded to Soviet citizens of equal age and station.
173 | DUMMY/LJ047-0126.wav|we would handle it in due course, in accord with the whole context of the investigation. End quote.
174 | DUMMY/LJ041-0022.wav|Oswald first wrote, quote, Edward Vogel, end quote, an obvious misspelling of Voebel's name,
175 | DUMMY/LJ015-0025.wav|The bank enjoyed an excellent reputation, it had a good connection, and was supposed to be perfectly sound.
176 | DUMMY/LJ012-0194.wav|But Burke and Hare had their imitators further south,
177 | DUMMY/LJ028-0416.wav|(if man may speak so confidently of His great impenetrable counsels), for an eternal Testimony of His great work in the confusion of Man's pride,
178 | DUMMY/LJ007-0130.wav|are all huddled together without discrimination, oversight, or control."
179 | DUMMY/LJ015-0005.wav|About this time Davidson and Gordon, the people above-mentioned,
180 | DUMMY/LJ016-0125.wav|with this, placed against the wall near the chevaux-de-frise, he made an escalade.
181 | DUMMY/LJ014-0224.wav|As Dwyer survived, Cannon escaped the death sentence, which was commuted to penal servitude for life.
182 | DUMMY/LJ005-0019.wav|refuted by abundant evidence, and having no foundation whatever in truth.
183 | DUMMY/LJ042-0221.wav|With either great ambivalence, or cold calculation he prepared completely different answers to the same questions.
184 | DUMMY/LJ001-0063.wav|which was generally more formally Gothic than the printing of the German workmen,
185 | DUMMY/LJ030-0006.wav|They took off in the Presidential plane, Air Force One, at eleven a.m., arriving at San Antonio at one:thirty p.m., Eastern Standard Time.
186 | DUMMY/LJ024-0054.wav|democracy will have failed far beyond the importance to it of any king of precedent concerning the judiciary.
187 | DUMMY/LJ006-0044.wav|the same callous indifference to the moral well-being of the prisoners, the same want of employment and of all disciplinary control.
188 | DUMMY/LJ039-0154.wav|four point eight to five point six seconds if the second shot missed,
189 | DUMMY/LJ050-0090.wav|they seem unduly restrictive in continuing to require some manifestation of animus against a Government official.
190 | DUMMY/LJ028-0421.wav|it was the beginning of the great collections of Babylonian antiquities in the museums of the Western world.
191 | DUMMY/LJ033-0205.wav|then I would say the possibility exists, these fibers could have come from this blanket, end quote.
192 | DUMMY/LJ019-0335.wav|The books and journals he was to keep were minutely specified, and his constant presence in or near the jail was insisted upon.
193 | DUMMY/LJ013-0045.wav|Wallace's relations warned him against his Liverpool friend,
194 | DUMMY/LJ037-0002.wav|Chapter four. The Assassin: Part six.
195 | DUMMY/LJ018-0159.wav|This was all the police wanted to know.
196 | DUMMY/LJ026-0140.wav|In the plant as in the animal metabolism must consist of anabolic and catabolic processes.
197 | DUMMY/LJ014-0171.wav|I will briefly describe one or two of the more remarkable murders in the years immediately following, then pass on to another branch of crime.
198 | DUMMY/LJ037-0007.wav|Three others subsequently identified Oswald from a photograph.
199 | DUMMY/LJ033-0174.wav|microscopic and UV (ultra violet) characteristics, end quote.
200 | DUMMY/LJ040-0110.wav|he apparently adjusted well enough there to have had an average, although gradually deteriorating, school record
201 | DUMMY/LJ039-0192.wav|he had a total of between four point eight and five point six seconds between the two shots which hit
202 | DUMMY/LJ032-0261.wav|When he appeared before the Commission, Michael Paine lifted the blanket
203 | DUMMY/LJ040-0097.wav|Lee was brought up in this atmosphere of constant money problems, and I am sure it had quite an effect on him, and also Robert, end quote.
204 | DUMMY/LJ037-0249.wav|Mrs. Earlene Roberts, the housekeeper at Oswald's roominghouse and the last person known to have seen him before he reached tenth Street and Patton Avenue,
205 | DUMMY/LJ016-0248.wav|Marwood was proud of his calling, and when questioned as to whether his process was satisfactory, replied that he heard "no complaints."
206 | DUMMY/LJ004-0083.wav|As Mr. Buxton pointed out, many old acts of parliament designed to protect the prisoner were still in full force.
207 | DUMMY/LJ014-0029.wav|This was Delarue's watch, fully identified as such, which Hocker told his brother Delarue had given him the morning of the murder.
208 | DUMMY/LJ021-0110.wav|have been best calculated to promote industrial recovery and a permanent improvement of business and labor conditions.
209 | DUMMY/LJ003-0107.wav|he slept in the same bed with a highwayman on one side, and a man charged with murder on the other.
210 | DUMMY/LJ039-0076.wav|Ronald Simmons, chief of the U.S. Army Infantry Weapons Evaluation Branch of the Ballistics Research Laboratory, said, quote,
211 | DUMMY/LJ016-0347.wav|had undoubtedly a solemn, impressive effect upon those outside.
212 | DUMMY/LJ001-0072.wav|After the end of the fifteenth century the degradation of printing, especially in Germany and Italy,
213 | DUMMY/LJ024-0018.wav|Consequently, although there never can be more than fifteen, there may be only fourteen, or thirteen, or twelve.
214 | DUMMY/LJ032-0180.wav|that the fibers were caught in the crevice of the rifle's butt plate, quote, in the recent past, end quote,
215 | DUMMY/LJ010-0083.wav|and measures taken to arrest them when their plans were so far developed that no doubt could remain as to their guilt.
216 | DUMMY/LJ002-0299.wav|and gave the garnish for the common side at that sum, which is five shillings more than Mr. Neild says was extorted on the common side.
217 | DUMMY/LJ048-0143.wav|the Secret Service did not at the time of the assassination have any established procedure governing its relationships with them.
218 | DUMMY/LJ012-0054.wav|Solomons, while waiting to appear in court, persuaded the turnkeys to take him to a public-house, where all might "refresh."
219 | DUMMY/LJ019-0270.wav|Vegetables, especially the potato, that most valuable anti-scorbutic, was too often omitted.
220 | DUMMY/LJ035-0164.wav|three minutes after the shooting.
221 | DUMMY/LJ014-0326.wav|Maltby and Co. would issue warrants on them deliverable to the importer, and the goods were then passed to be stored in neighboring warehouses.
222 | DUMMY/LJ001-0173.wav|The essential point to be remembered is that the ornament, whatever it is, whether picture or pattern-work, should form part of the page,
223 | DUMMY/LJ050-0056.wav|On December twenty-six, nineteen sixty-three, the FBI circulated additional instructions to all its agents,
224 | DUMMY/LJ003-0319.wav|provided only that their security was not jeopardized, and dependent upon the enforcement of another new rule,
225 | DUMMY/LJ006-0040.wav|The fact was that the years as they passed, nearly twenty in all, had worked but little permanent improvement in this detestable prison.
226 | DUMMY/LJ017-0231.wav|His body was found lying in a pool of blood in a night-dress, stabbed over and over again in the left side.
227 | DUMMY/LJ017-0226.wav|One half of the mutineers fell upon him unawares with handspikes and capstan-bars.
228 | DUMMY/LJ004-0239.wav|He had been committed for an offense for which he was acquitted.
229 | DUMMY/LJ048-0112.wav|The Commission also regards the security arrangements worked out by Lawson and Sorrels at Love Field as entirely adequate.
230 | DUMMY/LJ039-0125.wav|that Oswald was a good shot, somewhat better than or equal to -- better than the average let us say.
231 | DUMMY/LJ030-0196.wav|He cried out, quote, Oh, no, no, no. My God, they are going to kill us all, end quote,
232 | DUMMY/LJ010-0228.wav|He was released from Broadmoor in eighteen seventy-eight, and went abroad.
233 | DUMMY/LJ045-0228.wav|On the other hand, he could have traveled some distance with the money he did have and he did return to his room where he obtained his revolver.
234 | DUMMY/LJ028-0168.wav|in the other was the sacred precinct of Jupiter Belus,
235 | DUMMY/LJ021-0140.wav|and in such an effort we should be able to secure for employers and employees and consumers
236 | DUMMY/LJ009-0280.wav|Again the wretched creature succeeded in obtaining foothold, but this time on the left side of the drop.
237 | DUMMY/LJ003-0159.wav|To constitute this the aristocratic quarter, unwarrantable demands were made upon the space properly allotted to the female felons,
238 | DUMMY/LJ016-0274.wav|and the windows of the opposite houses, which commanded a good view, as usual fetched high prices.
239 | DUMMY/LJ035-0014.wav|it sounded high and I immediately kind of looked up,
240 | DUMMY/LJ033-0120.wav|which he believed was where the bag reached when it was laid on the seat with one edge against the door.
241 | DUMMY/LJ045-0015.wav|which Johnson said he did not receive until after the assassination. The letter said in part, quote,
242 | DUMMY/LJ003-0299.wav|the latter end of the nineteenth century, several of which still fall far short of our English ideal,
243 | DUMMY/LJ032-0206.wav|After comparing the rifle in the simulated photograph with the rifle in Exhibit Number one thirty-three A, Shaneyfelt testified, quote,
244 | DUMMY/LJ028-0494.wav|Between the several sections were wide spaces where foot soldiers and charioteers might fight.
245 | DUMMY/LJ005-0099.wav|and report at length upon the condition of the prisons of the country.
246 | DUMMY/LJ015-0144.wav|developed to a colossal extent the frauds he had already practiced as a subordinate.
247 | DUMMY/LJ019-0221.wav|It was intended as far as possible that, except awaiting trial, no prisoner should find himself relegated to Newgate.
248 | DUMMY/LJ003-0088.wav|in one, for seven years -- that of a man sentenced to death, for whom great interest had been made, but whom it was not thought right to pardon.
249 | DUMMY/LJ045-0216.wav|nineteen sixty-three, merely to disarm her and to provide a justification of sorts,
250 | DUMMY/LJ042-0135.wav|that he was not yet twenty years old when he went to the Soviet Union with such high hopes and not quite twenty-three when he returned bitterly disappointed.
251 | DUMMY/LJ049-0196.wav|On the other hand, it is urged that all features of the protection of the President and his family should be committed to an elite and independent corps.
252 | DUMMY/LJ018-0278.wav|This was the well and astutely devised plot of the brothers Bidwell,
253 | DUMMY/LJ030-0238.wav|and then looked around again and saw more of this movement, and so I proceeded to go to the back seat and get on top of him.
254 | DUMMY/LJ018-0309.wav|where probably the money still remains.
255 | DUMMY/LJ041-0199.wav|is shown most clearly by his employment relations after his return from the Soviet Union. Of course, he made his real problems worse to the extent
256 | DUMMY/LJ007-0076.wav|The lax discipline maintained in Newgate was still further deteriorated by the presence of two other classes of prisoners who ought never to have been inmates of such a jail.
257 | DUMMY/LJ039-0118.wav|He had high motivation. He had presumably a good to excellent rifle and good ammunition.
258 | DUMMY/LJ024-0019.wav|And there may be only nine.
259 | DUMMY/LJ008-0085.wav|The fire had not quite burnt out at twelve, in nearly four hours, that is to say.
260 | DUMMY/LJ018-0031.wav|This fixed the crime pretty certainly upon Müller, who had already left the country, thus increasing suspicion under which he lay.
261 | DUMMY/LJ030-0032.wav|Dallas police stood at intervals along the fence and Dallas plain clothes men mixed in the crowd.
262 | DUMMY/LJ050-0004.wav|General Supervision of the Secret Service
263 | DUMMY/LJ039-0096.wav|This is a definite advantage to the shooter, the vehicle moving directly away from him and the downgrade of the street, and he being in an elevated position
264 | DUMMY/LJ041-0195.wav|Oswald's interest in Marxism led some people to avoid him,
265 | DUMMY/LJ047-0158.wav|After a moment's hesitation, she told me that he worked at the Texas School Book Depository near the downtown area of Dallas.
266 | DUMMY/LJ050-0162.wav|In planning its data processing techniques,
267 | DUMMY/LJ001-0051.wav|and paying great attention to the "press work" or actual process of printing,
268 | DUMMY/LJ028-0136.wav|Of all the ancient descriptions of the famous walls and the city they protected, that of Herodotus is the fullest.
269 | DUMMY/LJ034-0134.wav|Shortly after the assassination Brennan noticed
270 | DUMMY/LJ019-0348.wav|Every facility was promised. The sanction of the Secretary of State would not be withheld if plans and estimates were duly submitted,
271 | DUMMY/LJ010-0219.wav|While one stood over the fire with the papers, another stood with lighted torch to fire the house.
272 | DUMMY/LJ011-0245.wav|Mr. Mullay called again, taking with him five hundred pounds in cash. Howard discovered this, and his manner was very suspicious;
273 | DUMMY/LJ030-0035.wav|Organization of the Motorcade
274 | DUMMY/LJ044-0135.wav|While he had drawn some attention to himself and had actually appeared on two radio programs, he had been attacked by Cuban exiles and arrested,
275 | DUMMY/LJ045-0090.wav|He was very much interested in autobiographical works of outstanding statesmen of the United States, to whom his wife thought he compared himself.
276 | DUMMY/LJ026-0034.wav|When any given "protist" has to be classified the case must be decided on its individual merits;
277 | DUMMY/LJ045-0092.wav|as to the fact that he was an outstanding man, end quote.
278 | DUMMY/LJ017-0050.wav|Palmer, who was only thirty-one at the time of his trial, was in appearance short and stout, with a round head
279 | DUMMY/LJ036-0104.wav|Whaley picked Oswald.
280 | DUMMY/LJ019-0055.wav|High authorities were in favor of continuous separation.
281 | DUMMY/LJ010-0030.wav|The brutal ferocity of the wild beast once aroused, the same means, the same weapons were employed to do the dreadful deed,
282 | DUMMY/LJ038-0047.wav|Some of the officers saw Oswald strike McDonald with his fist. Most of them heard a click which they assumed to be a click of the hammer of the revolver.
283 | DUMMY/LJ009-0074.wav|Let us pass on.
284 | DUMMY/LJ048-0069.wav|Efforts made by the Bureau since the assassination, on the other hand,
285 | DUMMY/LJ003-0211.wav|They were never left quite alone for fear of suicide, and for the same reason they were searched for weapons or poisons.
286 | DUMMY/LJ048-0053.wav|It is the conclusion of the Commission that, even in the absence of Secret Service criteria
287 | DUMMY/LJ033-0093.wav|Frazier estimated that the bag was two feet long, quote, give and take a few inches, end quote, and about five or six inches wide.
288 | DUMMY/LJ006-0149.wav|The turnkeys left the prisoners very much to themselves, never entering the wards after locking-up time, at dusk, till unlocking next morning,
289 | DUMMY/LJ018-0211.wav|The false coin was bought by an agent from an agent, and dealings were carried on secretly at the "Clock House" in Seven Dials.
290 | DUMMY/LJ008-0054.wav|This contrivance appears to have been copied with improvements from that which had been used in Dublin at a still earlier date,
291 | DUMMY/LJ040-0052.wav|that his commitment to Marxism was an important factor influencing his conduct during his adult years.
292 | DUMMY/LJ028-0023.wav|Two weeks pass, and at last you stand on the eastern edge of the plateau
293 | DUMMY/LJ009-0184.wav|Lord Ferrers' body was brought to Surgeons' Hall after execution in his own carriage and six;
294 | DUMMY/LJ005-0252.wav|A committee was appointed, under the presidency of the Duke of Richmond
295 | DUMMY/LJ015-0266.wav|has probably no parallel in the annals of crime. Saward himself is a striking and in some respects an unique figure in criminal history.
296 | DUMMY/LJ017-0059.wav|even after sentence, and until within a few hours of execution, he was buoyed up with the hope of reprieve.
297 | DUMMY/LJ024-0034.wav|What do they mean by the words "packing the Court"?
298 | DUMMY/LJ016-0089.wav|He was engaged in whitewashing and cleaning; the officer who had him in charge left him on the stairs leading to the gallery.
299 | DUMMY/LJ039-0227.wav|with two hits, within four point eight and five point six seconds.
300 | DUMMY/LJ001-0096.wav|have now come into general use and are obviously a great improvement on the ordinary "modern style" in use in England, which is in fact the Bodoni type
301 | DUMMY/LJ018-0129.wav|who threatened to betray the theft. But Brewer, either before or after this, succumbed to temptation,
302 | DUMMY/LJ010-0157.wav|and that, as he was starving, he had resolved on this desperate deed,
303 | DUMMY/LJ038-0264.wav|He concluded that, quote, the general rifling characteristics of the rifle are of the same type as those found on the bullet
304 | DUMMY/LJ031-0165.wav|When security arrangements at the airport were complete, the Secret Service made the necessary arrangements for the Vice President to leave the hospital.
305 | DUMMY/LJ018-0244.wav|The effect of establishing the forgeries would be to restore to the Roupell family lands for which a price had already been paid
306 | DUMMY/LJ007-0071.wav|in the face of impediments confessedly discouraging
307 | DUMMY/LJ028-0340.wav|Such of the Babylonians as witnessed the treachery took refuge in the temple of Jupiter Belus;
308 | DUMMY/LJ017-0164.wav|with the idea of subjecting her to the irritant poison slowly but surely until the desired effect, death, was achieved.
309 | DUMMY/LJ048-0197.wav|I then told the officers that their primary duty was traffic and crowd control and that they should be alert for any persons who might attempt to throw anything
310 | DUMMY/LJ013-0098.wav|Mr. Oxenford having denied that he had made any transfer of stock, the matter was at once put into the hands of the police.
311 | DUMMY/LJ012-0049.wav|led him to think seriously of trying his fortunes in another land.
312 | DUMMY/LJ030-0014.wav|quote, that the crowd was about the same as the one which came to see him before but there were one hundred thousand extra people on hand who came to see Mrs. Kennedy.
313 | DUMMY/LJ014-0186.wav|A milliner's porter,
314 | DUMMY/LJ015-0027.wav|Yet even so early as the death of the first Sir John Paul,
315 | DUMMY/LJ047-0049.wav|Marina Oswald, however, recalled that her husband was upset by this interview.
316 | DUMMY/LJ012-0021.wav|at fourteen he was a pickpocket and a "duffer," or a seller of sham goods.
317 | DUMMY/LJ003-0140.wav|otherwise he would have been stripped of his clothes. End quote.
318 | DUMMY/LJ042-0130.wav|Shortly thereafter, less than eighteen months after his defection, about six weeks before he met Marina Prusakova,
319 | DUMMY/LJ019-0180.wav|His letter to the Corporation, under date fourth June,
320 | DUMMY/LJ017-0108.wav|He was struck with the appearance of the corpse, which was not emaciated, as after a long disease ending in death;
321 | DUMMY/LJ006-0268.wav|Women saw men if they merely pretended to be wives; even boys were visited by their sweethearts.
322 | DUMMY/LJ044-0125.wav|of residence in the U.S.S.R. against any cause which I join, by association,
323 | DUMMY/LJ015-0231.wav|It was Tester's business, who had access to the railway company's books, to watch for this.
324 | DUMMY/LJ002-0225.wav|The rentals of rooms and fees went to the warden, whose income was two thousand three hundred seventy-two pounds.
325 | DUMMY/LJ034-0072.wav|The employees raced the elevators to the first floor. Givens saw Oswald standing at the gate on the fifth floor as the elevator went by.
326 | DUMMY/LJ045-0033.wav|He began to treat me better. He helped me more -- although he always did help. But he was more attentive, end quote.
327 | DUMMY/LJ031-0058.wav|to infuse blood and fluids into the circulatory system.
328 | DUMMY/LJ029-0197.wav|During November the Dallas papers reported frequently on the plans for protecting the President, stressing the thoroughness of the preparations.
329 | DUMMY/LJ043-0047.wav|Oswald and his family lived for a brief period with his mother at her urging, but Oswald soon decided to move out.
330 | DUMMY/LJ021-0026.wav|seems necessary to produce the same result of justice and right conduct
331 | DUMMY/LJ003-0230.wav|The prison allowances were eked out by the broken victuals generously given by several eating-house keepers in the city,
332 | DUMMY/LJ037-0252.wav|Ted Callaway, who saw the gunman moments after the shooting, testified that Commission Exhibit Number one sixty-two
333 | DUMMY/LJ031-0008.wav|Meanwhile, Chief Curry ordered the police base station to notify Parkland Hospital that the wounded President was en route.
334 | DUMMY/LJ030-0021.wav|all one had to do was get a high building someday with a telescopic rifle, and there was nothing anybody could do to defend against such an attempt.
335 | DUMMY/LJ046-0179.wav|being reviewed regularly.
336 | DUMMY/LJ025-0118.wav|and that, however diverse may be the fabrics or tissues of which their bodies are composed, all these varied structures result
337 | DUMMY/LJ028-0278.wav|Zopyrus, when they told him, not thinking that it could be true, went and saw the colt with his own eyes;
338 | DUMMY/LJ007-0090.wav|Not only did their presence tend greatly to interfere with the discipline of the prison, but their condition was deplorable in the extreme.
339 | DUMMY/LJ045-0045.wav|that she would be able to leave the Soviet Union. Marina Oswald has denied this.
340 | DUMMY/LJ028-0289.wav|For he cut off his own nose and ears, and then, clipping his hair close and flogging himself with a scourge,
341 | DUMMY/LJ009-0276.wav|Calcraft, the moment he had adjusted the cap and rope, ran down the steps, drew the bolt, and disappeared.
342 | DUMMY/LJ031-0122.wav|treated the gunshot wound in the left thigh.
343 | DUMMY/LJ016-0205.wav|he received a retaining fee of five pounds, five shillings, with the usual guinea for each job;
344 | DUMMY/LJ019-0248.wav|leading to an inequality, uncertainty, and inefficiency of punishment productive of the most prejudicial results.
345 | DUMMY/LJ033-0183.wav|it was not surprising that the replica sack made on December one, nineteen sixty-three,
346 | DUMMY/LJ037-0001.wav|Report of the President's Commission on the Assassination of President Kennedy. The Warren Commission Report. By The President's Commission on the Assassination of President Kennedy.
347 | DUMMY/LJ018-0218.wav|In eighteen fifty-five
348 | DUMMY/LJ001-0102.wav|Here and there a book is printed in France or Germany with some pretension to good taste,
349 | DUMMY/LJ007-0125.wav|It was diverted from its proper uses, and, as the "place of the greatest comfort," was allotted to persons who should not have been sent to Newgate at all.
350 | DUMMY/LJ050-0022.wav|A formal and thorough description of the responsibilities of the advance agent is now in preparation by the Service.
351 | DUMMY/LJ028-0212.wav|On the night of the eleventh day Gobrias killed the son of the King.
352 | DUMMY/LJ028-0357.wav|yet we may be sure that Babylon was taken by Darius only by use of stratagem. Its walls were impregnable.
353 | DUMMY/LJ014-0199.wav|there was no case to make out; why waste money on lawyers for the defense? His demeanor was cool and collected throughout;
354 | DUMMY/LJ016-0077.wav|A man named Lears, under sentence of transportation for an attempt at murder on board ship, got up part of the way,
355 | DUMMY/LJ009-0194.wav|and that executors or persons having lawful possession of the bodies
356 | DUMMY/LJ014-0094.wav|Discovery of the murder came in this wise. O'Connor, a punctual and well-conducted official, was at once missed at the London Docks.
357 | DUMMY/LJ001-0079.wav|Caslon's type is clear and neat, and fairly well designed;
358 | DUMMY/LJ026-0052.wav|In the nutrition of the animal the most essential and characteristic part of the food supply is derived from vegetable
359 | DUMMY/LJ013-0005.wav|One of the earliest of the big operators in fraudulent finance was Edward Beaumont Smith,
360 | DUMMY/LJ033-0072.wav|I then stepped off of it and the officer picked it up in the middle and it bent so.
361 | DUMMY/LJ036-0067.wav|According to McWatters, the Beckley bus was behind the Marsalis bus, but he did not actually see it.
362 | DUMMY/LJ025-0098.wav|and it is probable that amyloid substances are universally present in the animal organism, though not in the precise form of starch.
363 | DUMMY/LJ005-0257.wav|during which time a host of witnesses were examined, and the committee presented three separate reports,
364 | DUMMY/LJ004-0024.wav|Thus in eighteen thirteen the exaction of jail fees had been forbidden by law,
365 | DUMMY/LJ049-0154.wav|In eighteen ninety-four,
366 | DUMMY/LJ039-0059.wav|(three) his experience and practice after leaving the Marine Corps, and (four) the accuracy of the weapon and the quality of the ammunition.
367 | DUMMY/LJ007-0150.wav|He is allowed intercourse with prostitutes who, in nine cases out of ten, have originally conduced to his ruin;
368 | DUMMY/LJ015-0001.wav|Chronicles of Newgate, Volume two. By Arthur Griffiths. Section eighteen: Newgate notorieties continued, part three.
369 | DUMMY/LJ010-0158.wav|feeling, as he said, that he might as well be shot or hanged as remain in such a state.
370 | DUMMY/LJ010-0281.wav|who had borne the Queen's commission, first as cornet, and then lieutenant, in the tenth Hussars.
371 | DUMMY/LJ033-0055.wav|and he could disassemble it more rapidly.
372 | DUMMY/LJ015-0218.wav|A new accomplice was now needed within the company's establishment, and Pierce looked about long before he found the right person.
373 | DUMMY/LJ027-0006.wav|In all these lines the facts are drawn together by a strong thread of unity.
374 | DUMMY/LJ016-0049.wav|He had here completed his ascent.
375 | DUMMY/LJ006-0088.wav|It was not likely that a system which left innocent men -- for the great bulk of new arrivals were still untried
376 | DUMMY/LJ042-0133.wav|a great change must have occurred in Oswald's thinking to induce him to return to the United States.
377 | DUMMY/LJ045-0234.wav|While he did become enraged at at least one point in his interrogation,
378 | DUMMY/LJ046-0033.wav|The adequacy of existing procedures can fairly be assessed only after full consideration of the difficulty of the protective assignment,
379 | DUMMY/LJ037-0061.wav|and having, quote, somewhat bushy, end quote, hair.
380 | DUMMY/LJ032-0025.wav|the officers of Klein's discovered that a rifle bearing serial number C two seven six six had been shipped to one A. Hidell,
381 | DUMMY/LJ047-0197.wav|in view of all the information concerning Oswald in its files, should have alerted the Secret Service to Oswald's presence in Dallas
382 | DUMMY/LJ018-0130.wav|and stole paper on a much larger scale than Brown.
383 | DUMMY/LJ005-0265.wav|It was recommended that the dietaries should be submitted and approved like the rules; that convicted prisoners should not receive any food but the jail allowance;
384 | DUMMY/LJ044-0105.wav|He presented Arnold Johnson, Gus Hall,
385 | DUMMY/LJ015-0043.wav|This went on for some time, and might never have been discovered had some good stroke of luck provided any of the partners
386 | DUMMY/LJ030-0125.wav|On several occasions when the Vice President's car was slowed down by the throng, Special Agent Youngblood stepped out to hold the crowd back.
387 | DUMMY/LJ043-0140.wav|He also studied Dallas bus schedules to prepare for his later use of buses to travel to and from General Walker's house.
388 | DUMMY/LJ002-0220.wav|In consequence of these disclosures, both Bambridge and Huggin, his predecessor in the office, were committed to Newgate,
389 | DUMMY/LJ034-0117.wav|At one:twenty-nine p.m. the police radio reported
390 | DUMMY/LJ018-0276.wav|The first plot was against Mr. Harry Emmanuel, but he escaped, and the attempt was made upon Loudon and Ryder.
391 | DUMMY/LJ004-0077.wav|nor has he a right to poison or starve his fellow-creatures."
392 | DUMMY/LJ042-0194.wav|they should not be confused with slowness, indecision or fear. Only the intellectually fearless could even be remotely attracted to our doctrine,
393 | DUMMY/LJ029-0114.wav|The route chosen from the airport to Main Street was the normal one, except where Harwood Street was selected as the means of access to Main Street
394 | DUMMY/LJ014-0194.wav|The policemen were now in possession;
395 | DUMMY/LJ032-0027.wav|According to its microfilm records, Klein's received an order for a rifle on March thirteen, nineteen sixty-three,
396 | DUMMY/LJ048-0289.wav|However, there is no evidence that these men failed to take any action in Dallas within their power that would have averted the tragedy.
397 | DUMMY/LJ043-0188.wav|that he was the leader of a fascist organization, and when I said that even though all of that might be true, just the same he had no right to take his life,
398 | DUMMY/LJ011-0118.wav|In eighteen twenty-nine the gallows claimed two more victims for this offense.
399 | DUMMY/LJ040-0201.wav|After her interview with Mrs. Oswald,
400 | DUMMY/LJ033-0056.wav|While the rifle may have already been disassembled when Oswald arrived home on Thursday, he had ample time that evening to disassemble the rifle
401 | DUMMY/LJ047-0073.wav|Hosty considered the information to be, quote, stale, unquote, by that time, and did not attempt to verify Oswald's reported statement.
402 | DUMMY/LJ001-0153.wav|only nominally so, however, in many cases, since when he uses a headline he counts that in,
403 | DUMMY/LJ007-0158.wav|or any kind of moral improvement was impossible; the prisoner's career was inevitably downward, till he struck the lowest depths.
404 | DUMMY/LJ028-0502.wav|The Ishtar gateway leading to the palace was encased with beautiful blue glazed bricks,
405 | DUMMY/LJ028-0226.wav|Though Herodotus wrote nearly a hundred years after Babylon fell, his story seems to bear the stamp of truth.
406 | DUMMY/LJ010-0038.wav|as there had been before; as in the year eighteen forty-nine, a year memorable for the Rush murders at Norwich,
407 | DUMMY/LJ019-0241.wav|But in the interval very comprehensive and, I think it must be admitted, salutary changes were successively introduced into the management of prisons.
408 | DUMMY/LJ001-0094.wav|were induced to cut punches for a series of "old style" letters.
409 | DUMMY/LJ001-0015.wav|the forms of printed letters should be beautiful, and that their arrangement on the page should be reasonable and a help to the shapeliness of the letters themselves.
410 | DUMMY/LJ047-0015.wav|From defection to return to Fort Worth.
411 | DUMMY/LJ044-0139.wav|since there was no background to the New Orleans FPCC, quote, organization, end quote, which consisted solely of Oswald.
412 | DUMMY/LJ050-0031.wav|that the Secret Service consciously set about the task of inculcating and maintaining the highest standard of excellence and esprit, for all of its personnel.
413 | DUMMY/LJ050-0235.wav|It has also used other Federal law enforcement agents during Presidential visits to cities in which such agents are stationed.
414 | DUMMY/LJ050-0137.wav|FBI, and the Secret Service.
415 | DUMMY/LJ031-0109.wav|At one:thirty-five p.m., after Governor Connally had been moved to the operating room, Dr. Shaw started the first operation
416 | DUMMY/LJ031-0041.wav|He noted that the President was blue-white or ashen in color; had slow, spasmodic, agonal respiration without any coordination;
417 | DUMMY/LJ021-0139.wav|There should be at least a full and fair trial given to these means of ending industrial warfare;
418 | DUMMY/LJ029-0004.wav|The narrative of these events is based largely on the recollections of the participants,
419 | DUMMY/LJ023-0122.wav|It was said in last year's Democratic platform,
420 | DUMMY/LJ005-0264.wav|inspectors of prisons should be appointed, who should visit all the prisons from time to time and report to the Secretary of State.
421 | DUMMY/LJ002-0105.wav|and beyond it was a room called the "wine room," because formerly used for the sale of wine, but
422 | DUMMY/LJ017-0035.wav|in the interests and for the due protection of the public, that the fullest and fairest inquiry should be made,
423 | DUMMY/LJ048-0252.wav|Three of these agents occupied positions on the running boards of the car, and the fourth was seated in the car.
424 | DUMMY/LJ013-0109.wav|The proceeds of the robbery were lodged in a Boston bank,
425 | DUMMY/LJ039-0139.wav|Oswald obtained a hunting license, joined a hunting club and went hunting about six times, as discussed more fully in chapter six.
426 | DUMMY/LJ044-0047.wav|that anyone ever attacked any street demonstration in which Oswald was involved, except for the Bringuier incident mentioned above,
427 | DUMMY/LJ016-0417.wav|Catherine Wilson, the poisoner, was reserved and reticent to the last, expressing no contrition, but also no fear --
428 | DUMMY/LJ045-0178.wav|he left his wedding ring in a cup on the dresser in his room. He also left one hundred seventy dollars in a wallet in one of the dresser drawers.
429 | DUMMY/LJ009-0172.wav|While in London, for instance, in eighteen twenty-nine, twenty-four persons had been executed for crimes other than murder,
430 | DUMMY/LJ049-0202.wav|incident to its responsibilities.
431 | DUMMY/LJ032-0103.wav|The name "Hidell" was stamped on some of the "Chapter's" printed literature and on the membership application blanks.
432 | DUMMY/LJ013-0091.wav|and Elder had to be assisted by two bank porters, who carried it for him to a carriage waiting near the Mansion House.
433 | DUMMY/LJ037-0208.wav|nineteen dollars, ninety-five cents, plus one dollar, twenty-seven cents shipping charge, had been collected from the consignee, Hidell.
434 | DUMMY/LJ014-0128.wav|her hair was dressed in long crepe bands. She had lace ruffles at her wrist, and wore primrose-colored kid gloves.
435 | DUMMY/LJ015-0007.wav|This affected Cole's credit, and ugly reports were in circulation charging him with the issue of simulated warrants.
436 | DUMMY/LJ036-0169.wav|he would have reached his destination at approximately twelve:fifty-four p.m.
437 | DUMMY/LJ021-0040.wav|The second step we have taken in the restoration of normal business enterprise
438 | DUMMY/LJ015-0036.wav|The bank was already insolvent,
439 | DUMMY/LJ034-0041.wav|Although Bureau experiments had shown that twenty-four hours was a likely maximum time, Latona stated
440 | DUMMY/LJ009-0192.wav|The dissection of executed criminals was abolished soon after the discovery of the crime of burking,
441 | DUMMY/LJ037-0248.wav|The eyewitnesses vary in their identification of the jacket.
442 | DUMMY/LJ015-0289.wav|As each transaction was carried out from a different address, and a different messenger always employed,
443 | DUMMY/LJ005-0072.wav|After a few years of active exertion the Society was rewarded by fresh legislation.
444 | DUMMY/LJ023-0047.wav|The three horses are, of course, the three branches of government -- the Congress, the Executive and the courts.
445 | DUMMY/LJ009-0126.wav|Hardly any one.
446 | DUMMY/LJ034-0097.wav|The window was approximately one hundred twenty feet away.
447 | DUMMY/LJ028-0462.wav|They were laid in bitumen.
448 | DUMMY/LJ046-0055.wav|It is now possible for Presidents to travel the length and breadth of a land far larger than the United States
449 | DUMMY/LJ019-0371.wav|Yet the law was seldom if ever enforced.
450 | DUMMY/LJ039-0207.wav|Although all of the shots were a few inches high and to the right of the target,
451 | DUMMY/LJ002-0174.wav|Mr. Buxton's friends at once paid the forty shillings, and the boy was released.
452 | DUMMY/LJ016-0233.wav|In his own profession
453 | DUMMY/LJ026-0108.wav|It is clear that there are upward and downward currents of water containing food (comparable to blood of an animal),
454 | DUMMY/LJ038-0035.wav|Oswald rose from his seat, bringing up both hands.
455 | DUMMY/LJ026-0148.wav|water which is lost by evaporation, especially from the leaf surface through the stomata;
456 | DUMMY/LJ001-0186.wav|the position of our Society that a work of utility might be also a work of art, if we cared to make it so.
457 | DUMMY/LJ016-0264.wav|The upturned faces of the eager spectators resembled those of the 'gods' at Drury Lane on Boxing Night;
458 | DUMMY/LJ009-0041.wav|The occupants of this terrible black pew were the last always to enter the chapel.
459 | DUMMY/LJ010-0297.wav|But there were other notorious cases of forgery.
460 | DUMMY/LJ040-0018.wav|the Commission is not able to reach any definite conclusions as to whether or not he was, quote, sane, unquote, under prevailing legal standards.
461 | DUMMY/LJ005-0253.wav|"to inquire into and report upon the several jails and houses of correction in the counties, cities, and corporate towns within England and Wales
462 | DUMMY/LJ027-0176.wav|Fishes first appeared in the Devonian and Upper Silurian in very reptilian or rather amphibian forms.
463 | DUMMY/LJ034-0035.wav|The position of this palmprint on the carton was parallel with the long axis of the box, and at right angles with the short axis;
464 | DUMMY/LJ016-0054.wav|But he did not like the risk of entering a room by the fireplace, and the chances of detection it offered.
465 | DUMMY/LJ018-0262.wav|Roupell received the announcement with a cheerful countenance,
466 | DUMMY/LJ044-0237.wav|with thirteen dollars, eighty-seven cents when considerably greater resources were available to him.
467 | DUMMY/LJ034-0166.wav|Two other witnesses were able to offer partial descriptions of a man they saw in the southeast corner window
468 | DUMMY/LJ016-0238.wav|"just to steady their legs a little;" in other words, to add his weight to that of the hanging bodies.
469 | DUMMY/LJ042-0198.wav|The discussion above has already set forth examples of his expression of hatred for the United States.
470 | DUMMY/LJ031-0189.wav|At two:thirty-eight p.m., Eastern Standard Time, Lyndon Baines Johnson took the oath of office as the thirty-sixth President of the United States.
471 | DUMMY/LJ050-0084.wav|or, quote, other high government officials in the nature of a complaint coupled with an expressed or implied determination to use a means,
472 | DUMMY/LJ044-0158.wav|As for my return entrance visa please consider it separately. End quote.
473 | DUMMY/LJ045-0082.wav|it appears that Marina Oswald also complained that her husband was not able to provide more material things for her.
474 | DUMMY/LJ045-0190.wav|appeared in The Dallas Times Herald on November fifteen, nineteen sixty-three.
475 | DUMMY/LJ035-0155.wav|The only exit from the office in the direction Oswald was moving was through the door to the front stairway.
476 | DUMMY/LJ044-0004.wav|Political Activities
477 | DUMMY/LJ046-0016.wav|The Commission has not undertaken a comprehensive examination of all facets of this subject;
478 | DUMMY/LJ019-0368.wav|The latter too was to be laid before the House of Commons.
479 | DUMMY/LJ010-0062.wav|But they proceeded in all seriousness, and would have shrunk from no outrage or atrocity in furtherance of their foolhardy enterprise.
480 | DUMMY/LJ033-0159.wav|It was from Oswald's right hand, in which he carried the long package as he walked from Frazier's car to the building.
481 | DUMMY/LJ002-0171.wav|The boy declared he saw no one, and accordingly passed through without paying the toll of a penny.
482 | DUMMY/LJ002-0298.wav|in his evidence in eighteen fourteen, said it was more,
483 | DUMMY/LJ012-0219.wav|and in one corner, at some depth, a bundle of clothes were unearthed, which, with a hairy cap,
484 | DUMMY/LJ017-0190.wav|After this came the charge of administering oil of vitriol, which failed, as has been described.
485 | DUMMY/LJ019-0179.wav|This, with a scheme for limiting the jail to untried prisoners, had been urgently recommended by Lord John Russell in eighteen thirty.
486 | DUMMY/LJ050-0188.wav|each patrolman might be given a prepared booklet of instructions explaining what is expected of him. The Secret Service has expressed concern
487 | DUMMY/LJ006-0043.wav|The disgraceful overcrowding had been partially ended, but the same evils of indiscriminate association were still present; there was the old neglect of decency,
488 | DUMMY/LJ029-0060.wav|A number of people who resembled some of those in the photographs were placed under surveillance at the Trade Mart.
489 | DUMMY/LJ019-0052.wav|Both systems came to us from the United States. The difference was really more in degree than in principle,
490 | DUMMY/LJ037-0081.wav|Later in the day each woman found an empty shell on the ground near the house. These two shells were delivered to the police.
491 | DUMMY/LJ048-0200.wav|paying particular attention to the crowd for any unusual activity.
492 | DUMMY/LJ016-0426.wav|come along, gallows.
493 | DUMMY/LJ008-0182.wav|A tremendous crowd assembled when Bellingham was executed in eighteen twelve for the murder of Spencer Percival, at that time prime minister;
494 | DUMMY/LJ043-0107.wav|Upon moving to New Orleans on April twenty-four, nineteen sixty-three,
495 | DUMMY/LJ006-0084.wav|and so numerous were his opportunities of showing favoritism, that all the prisoners may be said to be in his power.
496 | DUMMY/LJ025-0081.wav|has no permanent digestive cavity or mouth, but takes in its food anywhere and digests, so to speak, all over its body.
497 | DUMMY/LJ019-0042.wav|These were either satisfied with a makeshift, and modified existing buildings, without close regard to their suitability, or for a long time did nothing at all.
498 | DUMMY/LJ047-0240.wav|They agree that Hosty told Revill
499 | DUMMY/LJ032-0012.wav|the resistance to arrest and the attempted shooting of another police officer by the man (Lee Harvey Oswald) subsequently accused of assassinating President Kennedy
500 | DUMMY/LJ050-0209.wav|The assistant to the Director of the FBI testified that
501 |
--------------------------------------------------------------------------------
/filelists/ljs_audio_text_val_filelist.txt:
--------------------------------------------------------------------------------
1 | DUMMY/LJ022-0023.wav|The overwhelming majority of people in this country know how to sift the wheat from the chaff in what they hear and what they read.
2 | DUMMY/LJ043-0030.wav|If somebody did that to me, a lousy trick like that, to take my wife away, and all the furniture, I would be mad as hell, too.
3 | DUMMY/LJ005-0201.wav|as is shown by the report of the Commissioners to inquire into the state of the municipal corporations in eighteen thirty-five.
4 | DUMMY/LJ001-0110.wav|Even the Caslon type when enlarged shows great shortcomings in this respect:
5 | DUMMY/LJ003-0345.wav|All the committee could do in this respect was to throw the responsibility on others.
6 | DUMMY/LJ007-0154.wav|These pungent and well-grounded strictures applied with still greater force to the unconvicted prisoner, the man who came to the prison innocent, and still uncontaminated,
7 | DUMMY/LJ018-0098.wav|and recognized as one of the frequenters of the bogus law-stationers. His arrest led to that of others.
8 | DUMMY/LJ047-0044.wav|Oswald was, however, willing to discuss his contacts with Soviet authorities. He denied having any involvement with Soviet intelligence agencies
9 | DUMMY/LJ031-0038.wav|The first physician to see the President at Parkland Hospital was Dr. Charles J. Carrico, a resident in general surgery.
10 | DUMMY/LJ048-0194.wav|during the morning of November twenty-two prior to the motorcade.
11 | DUMMY/LJ049-0026.wav|On occasion the Secret Service has been permitted to have an agent riding in the passenger compartment with the President.
12 | DUMMY/LJ004-0152.wav|although at Mr. Buxton's visit a new jail was in process of erection, the first step towards reform since Howard's visitation in seventeen seventy-four.
13 | DUMMY/LJ008-0278.wav|or theirs might be one of many, and it might be considered necessary to "make an example."
14 | DUMMY/LJ043-0002.wav|The Warren Commission Report. By The President's Commission on the Assassination of President Kennedy. Chapter seven. Lee Harvey Oswald:
15 | DUMMY/LJ009-0114.wav|Mr. Wakefield winds up his graphic but somewhat sensational account by describing another religious service, which may appropriately be inserted here.
16 | DUMMY/LJ028-0506.wav|A modern artist would have difficulty in doing such accurate work.
17 | DUMMY/LJ050-0168.wav|with the particular purposes of the agency involved. The Commission recognizes that this is a controversial area
18 | DUMMY/LJ039-0223.wav|Oswald's Marine training in marksmanship, his other rifle experience and his established familiarity with this particular weapon
19 | DUMMY/LJ029-0032.wav|According to O'Donnell, quote, we had a motorcade wherever we went, end quote.
20 | DUMMY/LJ031-0070.wav|Dr. Clark, who most closely observed the head wound,
21 | DUMMY/LJ034-0198.wav|Euins, who was on the southwest corner of Elm and Houston Streets testified that he could not describe the man he saw in the window.
22 | DUMMY/LJ026-0068.wav|Energy enters the plant, to a small extent,
23 | DUMMY/LJ039-0075.wav|once you know that you must put the crosshairs on the target and that is all that is necessary.
24 | DUMMY/LJ004-0096.wav|the fatal consequences whereof might be prevented if the justices of the peace were duly authorized
25 | DUMMY/LJ005-0014.wav|Speaking on a debate on prison matters, he declared that
26 | DUMMY/LJ012-0161.wav|he was reported to have fallen away to a shadow.
27 | DUMMY/LJ018-0239.wav|His disappearance gave color and substance to evil reports already in circulation that the will and conveyance above referred to
28 | DUMMY/LJ019-0257.wav|Here the tread-wheel was in use, there cellular cranks, or hard-labor machines.
29 | DUMMY/LJ028-0008.wav|you tap gently with your heel upon the shoulder of the dromedary to urge her on.
30 | DUMMY/LJ024-0083.wav|This plan of mine is no attack on the Court;
31 | DUMMY/LJ042-0129.wav|No night clubs or bowling alleys, no places of recreation except the trade union dances. I have had enough.
32 | DUMMY/LJ036-0103.wav|The police asked him whether he could pick out his passenger from the lineup.
33 | DUMMY/LJ046-0058.wav|During his Presidency, Franklin D. Roosevelt made almost four hundred journeys and traveled more than three hundred fifty thousand miles.
34 | DUMMY/LJ014-0076.wav|He was seen afterwards smoking and talking with his hosts in their back parlor, and never seen again alive.
35 | DUMMY/LJ002-0043.wav|long narrow rooms -- one thirty-six feet, six twenty-three feet, and the eighth eighteen,
36 | DUMMY/LJ009-0076.wav|We come to the sermon.
37 | DUMMY/LJ017-0131.wav|even when the high sheriff had told him there was no possibility of a reprieve, and within a few hours of execution.
38 | DUMMY/LJ046-0184.wav|but there is a system for the immediate notification of the Secret Service by the confining institution when a subject is released or escapes.
39 | DUMMY/LJ014-0263.wav|When other pleasures palled he took a theatre, and posed as a munificent patron of the dramatic art.
40 | DUMMY/LJ042-0096.wav|(old exchange rate) in addition to his factory salary of approximately equal amount
41 | DUMMY/LJ049-0050.wav|Hill had both feet on the car and was climbing aboard to assist President and Mrs. Kennedy.
42 | DUMMY/LJ019-0186.wav|seeing that since the establishment of the Central Criminal Court, Newgate received prisoners for trial from several counties,
43 | DUMMY/LJ028-0307.wav|then let twenty days pass, and at the end of that time station near the Chaldasan gates a body of four thousand.
44 | DUMMY/LJ012-0235.wav|While they were in a state of insensibility the murder was committed.
45 | DUMMY/LJ034-0053.wav|reached the same conclusion as Latona that the prints found on the cartons were those of Lee Harvey Oswald.
46 | DUMMY/LJ014-0030.wav|These were damnatory facts which well supported the prosecution.
47 | DUMMY/LJ015-0203.wav|but were the precautions too minute, the vigilance too close to be eluded or overcome?
48 | DUMMY/LJ028-0093.wav|but his scribe wrote it in the manner customary for the scribes of those days to write of their royal masters.
49 | DUMMY/LJ002-0018.wav|The inadequacy of the jail was noticed and reported upon again and again by the grand juries of the city of London,
50 | DUMMY/LJ028-0275.wav|At last, in the twentieth month,
51 | DUMMY/LJ012-0042.wav|which he kept concealed in a hiding-place with a trap-door just under his bed.
52 | DUMMY/LJ011-0096.wav|He married a lady also belonging to the Society of Friends, who brought him a large fortune, which, and his own money, he put into a city firm,
53 | DUMMY/LJ036-0077.wav|Roger D. Craig, a deputy sheriff of Dallas County,
54 | DUMMY/LJ016-0318.wav|Other officials, great lawyers, governors of prisons, and chaplains supported this view.
55 | DUMMY/LJ013-0164.wav|who came from his room ready dressed, a suspicious circumstance, as he was always late in the morning.
56 | DUMMY/LJ027-0141.wav|is closely reproduced in the life-history of existing deer. Or, in other words,
57 | DUMMY/LJ028-0335.wav|accordingly they committed to him the command of their whole army, and put the keys of their city into his hands.
58 | DUMMY/LJ031-0202.wav|Mrs. Kennedy chose the hospital in Bethesda for the autopsy because the President had served in the Navy.
59 | DUMMY/LJ021-0145.wav|From those willing to join in establishing this hoped-for period of peace,
60 | DUMMY/LJ016-0288.wav|"Müller, Müller, He's the man," till a diversion was created by the appearance of the gallows, which was received with continuous yells.
61 | DUMMY/LJ028-0081.wav|Years later, when the archaeologists could readily distinguish the false from the true,
62 | DUMMY/LJ018-0081.wav|his defense being that he had intended to commit suicide, but that, on the appearance of this officer who had wronged him,
63 | DUMMY/LJ021-0066.wav|together with a great increase in the payrolls, there has come a substantial rise in the total of industrial profits
64 | DUMMY/LJ009-0238.wav|After this the sheriffs sent for another rope, but the spectators interfered, and the man was carried back to jail.
65 | DUMMY/LJ005-0079.wav|and improve the morals of the prisoners, and shall insure the proper measure of punishment to convicted offenders.
66 | DUMMY/LJ035-0019.wav|drove to the northwest corner of Elm and Houston, and parked approximately ten feet from the traffic signal.
67 | DUMMY/LJ036-0174.wav|This is the approximate time he entered the roominghouse, according to Earlene Roberts, the housekeeper there.
68 | DUMMY/LJ046-0146.wav|The criteria in effect prior to November twenty-two, nineteen sixty-three, for determining whether to accept material for the PRS general files
69 | DUMMY/LJ017-0044.wav|and the deepest anxiety was felt that the crime, if crime there had been, should be brought home to its perpetrator.
70 | DUMMY/LJ017-0070.wav|but his sporting operations did not prosper, and he became a needy man, always driven to desperate straits for cash.
71 | DUMMY/LJ014-0020.wav|He was soon afterwards arrested on suspicion, and a search of his lodgings brought to light several garments saturated with blood;
72 | DUMMY/LJ016-0020.wav|He never reached the cistern, but fell back into the yard, injuring his legs severely.
73 | DUMMY/LJ045-0230.wav|when he was finally apprehended in the Texas Theatre. Although it is not fully corroborated by others who were present,
74 | DUMMY/LJ035-0129.wav|and she must have run down the stairs ahead of Oswald and would probably have seen or heard him.
75 | DUMMY/LJ008-0307.wav|afterwards express a wish to murder the Recorder for having kept them so long in suspense.
76 | DUMMY/LJ008-0294.wav|nearly indefinitely deferred.
77 | DUMMY/LJ047-0148.wav|On October twenty-five,
78 | DUMMY/LJ008-0111.wav|They entered a "stone cold room," and were presently joined by the prisoner.
79 | DUMMY/LJ034-0042.wav|that he could only testify with certainty that the print was less than three days old.
80 | DUMMY/LJ037-0234.wav|Mrs. Mary Brock, the wife of a mechanic who worked at the station, was there at the time and she saw a white male,
81 | DUMMY/LJ040-0002.wav|Chapter seven. Lee Harvey Oswald: Background and Possible Motives, Part one.
82 | DUMMY/LJ045-0140.wav|The arguments he used to justify his use of the alias suggest that Oswald may have come to think that the whole world was becoming involved
83 | DUMMY/LJ012-0035.wav|the number and names on watches, were carefully removed or obliterated after the goods passed out of his hands.
84 | DUMMY/LJ012-0250.wav|On the seventh July, eighteen thirty-seven,
85 | DUMMY/LJ016-0179.wav|contracted with sheriffs and conveners to work by the job.
86 | DUMMY/LJ016-0138.wav|at a distance from the prison.
87 | DUMMY/LJ027-0052.wav|These principles of homology are essential to a correct interpretation of the facts of morphology.
88 | DUMMY/LJ031-0134.wav|On one occasion Mrs. Johnson, accompanied by two Secret Service agents, left the room to see Mrs. Kennedy and Mrs. Connally.
89 | DUMMY/LJ019-0273.wav|which Sir Joshua Jebb told the committee he considered the proper elements of penal discipline.
90 | DUMMY/LJ014-0110.wav|At the first the boxes were impounded, opened, and found to contain many of O'Connor's effects.
91 | DUMMY/LJ034-0160.wav|on Brennan's subsequent certain identification of Lee Harvey Oswald as the man he saw fire the rifle.
92 | DUMMY/LJ038-0199.wav|eleven. If I am alive and taken prisoner,
93 | DUMMY/LJ014-0010.wav|yet he could not overcome the strange fascination it had for him, and remained by the side of the corpse till the stretcher came.
94 | DUMMY/LJ033-0047.wav|I noticed when I went out that the light was on, end quote,
95 | DUMMY/LJ040-0027.wav|He was never satisfied with anything.
96 | DUMMY/LJ048-0228.wav|and others who were present say that no agent was inebriated or acted improperly.
97 | DUMMY/LJ003-0111.wav|He was in consequence put out of the protection of their internal law, end quote. Their code was a subject of some curiosity.
98 | DUMMY/LJ008-0258.wav|Let me retrace my steps, and speak more in detail of the treatment of the condemned in those bloodthirsty and brutally indifferent days,
99 | DUMMY/LJ029-0022.wav|The original plan called for the President to spend only one day in the State, making whirlwind visits to Dallas, Fort Worth, San Antonio, and Houston.
100 | DUMMY/LJ004-0045.wav|Mr. Sturges Bourne, Sir James Mackintosh, Sir James Scarlett, and William Wilberforce.
101 |
--------------------------------------------------------------------------------
/inference.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": null,
6 | "metadata": {},
7 | "outputs": [],
8 | "source": [
9 | "%matplotlib inline\n",
10 | "import matplotlib.pyplot as plt\n",
11 | "import IPython.display as ipd\n",
12 | "\n",
13 | "import sys\n",
14 | "sys.path.append('./waveglow/')\n",
15 | "\n",
16 | "import librosa\n",
17 | "import numpy as np\n",
18 | "import os\n",
19 | "import glob\n",
20 | "import json\n",
21 | "\n",
22 | "import torch\n",
23 | "from text import text_to_sequence, cmudict\n",
24 | "from text.symbols import symbols\n",
25 | "import commons\n",
26 | "import attentions\n",
27 | "import modules\n",
28 | "import models\n",
29 | "import utils\n",
30 | "\n",
31 | "# load WaveGlow\n",
32 | "waveglow_path = './waveglow/waveglow_256channels_ljs_v3.pt' # or change to the latest version of the pretrained WaveGlow.\n",
33 | "waveglow = torch.load(waveglow_path)['model']\n",
34 | "waveglow = waveglow.remove_weightnorm(waveglow)\n",
35 | "_ = waveglow.cuda().eval()\n",
36 | "from apex import amp\n",
37 | "waveglow, _ = amp.initialize(waveglow, [], opt_level=\"O3\") # Try if you want to boost up synthesis speed."
38 | ]
39 | },
40 | {
41 | "cell_type": "code",
42 | "execution_count": null,
43 | "metadata": {},
44 | "outputs": [],
45 | "source": [
46 | "# If you are using your own trained model\n",
47 | "model_dir = \"./logs/your_dir/\"\n",
48 | "hps = utils.get_hparams_from_dir(model_dir)\n",
49 | "checkpoint_path = utils.latest_checkpoint_path(model_dir)\n",
50 | "\n",
51 | "# If you are using a provided pretrained model\n",
52 | "# hps = utils.get_hparams_from_file(\"./configs/any_config_file.json\")\n",
53 | "# checkpoint_path = \"/path/to/pretrained_model\"\n",
54 | "\n",
55 | "model = models.FlowGenerator(\n",
56 | " len(symbols) + getattr(hps.data, \"add_blank\", False),\n",
57 | " out_channels=hps.data.n_mel_channels,\n",
58 | " **hps.model).to(\"cuda\")\n",
59 | "\n",
60 | "utils.load_checkpoint(checkpoint_path, model)\n",
61 | "model.decoder.store_inverse() # do not calcuate jacobians for fast decoding\n",
62 | "_ = model.eval()\n",
63 | "\n",
64 | "cmu_dict = cmudict.CMUDict(hps.data.cmudict_path)\n",
65 | "\n",
66 | "# normalizing & type casting\n",
67 | "def normalize_audio(x, max_wav_value=hps.data.max_wav_value):\n",
68 | " return np.clip((x / np.abs(x).max()) * max_wav_value, -32768, 32767).astype(\"int16\")"
69 | ]
70 | },
71 | {
72 | "cell_type": "code",
73 | "execution_count": null,
74 | "metadata": {},
75 | "outputs": [],
76 | "source": [
77 | "tst_stn = \"Glow TTS is really awesome !\" \n",
78 | "\n",
79 | "if getattr(hps.data, \"add_blank\", False):\n",
80 | " text_norm = text_to_sequence(tst_stn.strip(), ['english_cleaners'], cmu_dict)\n",
81 | " text_norm = commons.intersperse(text_norm, len(symbols))\n",
82 | "else: # If not using \"add_blank\" option during training, adding spaces at the beginning and the end of utterance improves quality\n",
83 | " tst_stn = \" \" + tst_stn.strip() + \" \"\n",
84 | " text_norm = text_to_sequence(tst_stn.strip(), ['english_cleaners'], cmu_dict)\n",
85 | "sequence = np.array(text_norm)[None, :]\n",
86 | "print(\"\".join([symbols[c] if c < len(symbols) else \"\" for c in sequence[0]]))\n",
87 | "x_tst = torch.autograd.Variable(torch.from_numpy(sequence)).cuda().long()\n",
88 | "x_tst_lengths = torch.tensor([x_tst.shape[1]]).cuda()"
89 | ]
90 | },
91 | {
92 | "cell_type": "code",
93 | "execution_count": null,
94 | "metadata": {},
95 | "outputs": [],
96 | "source": [
97 | "with torch.no_grad():\n",
98 | " noise_scale = .667\n",
99 | " length_scale = 1.0\n",
100 | " (y_gen_tst, *_), *_, (attn_gen, *_) = model(x_tst, x_tst_lengths, gen=True, noise_scale=noise_scale, length_scale=length_scale)\n",
101 | " try:\n",
102 | " audio = waveglow.infer(y_gen_tst.half(), sigma=.666)\n",
103 | " except:\n",
104 | " audio = waveglow.infer(y_gen_tst, sigma=.666)\n",
105 | "ipd.Audio(normalize_audio(audio[0].clamp(-1,1).data.cpu().float().numpy()), rate=hps.data.sampling_rate)"
106 | ]
107 | }
108 | ],
109 | "metadata": {
110 | "kernelspec": {
111 | "display_name": "Python 3",
112 | "language": "python",
113 | "name": "python3"
114 | },
115 | "language_info": {
116 | "codemirror_mode": {
117 | "name": "ipython",
118 | "version": 3
119 | },
120 | "file_extension": ".py",
121 | "mimetype": "text/x-python",
122 | "name": "python",
123 | "nbconvert_exporter": "python",
124 | "pygments_lexer": "ipython3",
125 | "version": "3.6.9"
126 | }
127 | },
128 | "nbformat": 4,
129 | "nbformat_minor": 4
130 | }
131 |
--------------------------------------------------------------------------------
/inference_hifigan.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": null,
6 | "metadata": {},
7 | "outputs": [],
8 | "source": [
9 | "%matplotlib inline\n",
10 | "import matplotlib.pyplot as plt\n",
11 | "import IPython.display as ipd\n",
12 | "\n",
13 | "import librosa\n",
14 | "import numpy as np\n",
15 | "import os\n",
16 | "import glob\n",
17 | "import json\n",
18 | "\n",
19 | "import torch\n",
20 | "from text import text_to_sequence, cmudict\n",
21 | "from text.symbols import symbols\n",
22 | "import commons\n",
23 | "import attentions\n",
24 | "import modules\n",
25 | "import models\n",
26 | "import utils"
27 | ]
28 | },
29 | {
30 | "cell_type": "code",
31 | "execution_count": null,
32 | "metadata": {},
33 | "outputs": [],
34 | "source": [
35 | "# If you are using your own trained model\n",
36 | "model_dir = \"./logs/your_dir/\"\n",
37 | "hps = utils.get_hparams_from_dir(model_dir)\n",
38 | "checkpoint_path = utils.latest_checkpoint_path(model_dir)\n",
39 | "\n",
40 | "# If you are using a provided pretrained model\n",
41 | "# hps = utils.get_hparams_from_file(\"./configs/any_config_file.json\")\n",
42 | "# checkpoint_path = \"/path/to/pretrained_model\"\n",
43 | "\n",
44 | "model = models.FlowGenerator(\n",
45 | " len(symbols) + getattr(hps.data, \"add_blank\", False),\n",
46 | " out_channels=hps.data.n_mel_channels,\n",
47 | " **hps.model).to(\"cuda\")\n",
48 | "\n",
49 | "utils.load_checkpoint(checkpoint_path, model)\n",
50 | "model.decoder.store_inverse() # do not calcuate jacobians for fast decoding\n",
51 | "_ = model.eval()\n",
52 | "\n",
53 | "cmu_dict = cmudict.CMUDict(hps.data.cmudict_path)"
54 | ]
55 | },
56 | {
57 | "cell_type": "code",
58 | "execution_count": null,
59 | "metadata": {},
60 | "outputs": [],
61 | "source": [
62 | "tst_stn = \"Glow TTS is really awesome !\" \n",
63 | "\n",
64 | "if getattr(hps.data, \"add_blank\", False):\n",
65 | " text_norm = text_to_sequence(tst_stn.strip(), ['english_cleaners'], cmu_dict)\n",
66 | " text_norm = commons.intersperse(text_norm, len(symbols))\n",
67 | "else: # If not using \"add_blank\" option during training, adding spaces at the beginning and the end of utterance improves quality\n",
68 | " tst_stn = \" \" + tst_stn.strip() + \" \"\n",
69 | " text_norm = text_to_sequence(tst_stn.strip(), ['english_cleaners'], cmu_dict)\n",
70 | "sequence = np.array(text_norm)[None, :]\n",
71 | "print(\"\".join([symbols[c] if c < len(symbols) else \"\" for c in sequence[0]]))\n",
72 | "x_tst = torch.autograd.Variable(torch.from_numpy(sequence)).cuda().long()\n",
73 | "x_tst_lengths = torch.tensor([x_tst.shape[1]]).cuda()"
74 | ]
75 | },
76 | {
77 | "cell_type": "code",
78 | "execution_count": null,
79 | "metadata": {},
80 | "outputs": [],
81 | "source": [
82 | "with torch.no_grad():\n",
83 | " noise_scale = .667\n",
84 | " length_scale = 1.0\n",
85 | " (y_gen_tst, *_), *_, (attn_gen, *_) = model(x_tst, x_tst_lengths, gen=True, noise_scale=noise_scale, length_scale=length_scale)\n",
86 | "\n",
87 | "# save mel-frames\n",
88 | "if not os.path.exists('./hifi-gan/test_mel_files'):\n",
89 | " os.makedirs('./hifi-gan/test_mel_files')\n",
90 | "np.save(\"./hifi-gan/test_mel_files/sample.npy\", y_gen_tst.cpu().detach().numpy())"
91 | ]
92 | },
93 | {
94 | "cell_type": "code",
95 | "execution_count": null,
96 | "metadata": {},
97 | "outputs": [],
98 | "source": [
99 | "# Use finetuned HiFi-GAN with Tacotron 2, which is provided in the repo of HiFi-GAN.\n",
100 | "!python ./hifi-gan/inference_e2e.py --checkpoint_file /path/to/finetuned_model"
101 | ]
102 | },
103 | {
104 | "cell_type": "code",
105 | "execution_count": null,
106 | "metadata": {},
107 | "outputs": [],
108 | "source": [
109 | "ipd.Audio(\"./hifi-gan/generated_files_from_mel/sample_generated_e2e.wav\")"
110 | ]
111 | }
112 | ],
113 | "metadata": {
114 | "kernelspec": {
115 | "display_name": "Python 3",
116 | "language": "python",
117 | "name": "python3"
118 | },
119 | "language_info": {
120 | "codemirror_mode": {
121 | "name": "ipython",
122 | "version": 3
123 | },
124 | "file_extension": ".py",
125 | "mimetype": "text/x-python",
126 | "name": "python",
127 | "nbconvert_exporter": "python",
128 | "pygments_lexer": "ipython3",
129 | "version": "3.6.9"
130 | }
131 | },
132 | "nbformat": 4,
133 | "nbformat_minor": 4
134 | }
135 |
--------------------------------------------------------------------------------
/init.py:
--------------------------------------------------------------------------------
1 | import os
2 | import json
3 | import argparse
4 | import math
5 | import torch
6 | from torch import nn, optim
7 | from torch.nn import functional as F
8 | from torch.utils.data import DataLoader
9 |
10 | from data_utils import TextMelLoader, TextMelCollate
11 | import models
12 | import commons
13 | import utils
14 | from text.symbols import symbols
15 |
16 |
17 | class FlowGenerator_DDI(models.FlowGenerator):
18 | """A helper for Data-dependent Initialization"""
19 | def __init__(self, *args, **kwargs):
20 | super().__init__(*args, **kwargs)
21 | for f in self.decoder.flows:
22 | if getattr(f, "set_ddi", False):
23 | f.set_ddi(True)
24 |
25 |
26 | def main():
27 | hps = utils.get_hparams()
28 | logger = utils.get_logger(hps.model_dir)
29 | logger.info(hps)
30 | utils.check_git_hash(hps.model_dir)
31 |
32 | torch.manual_seed(hps.train.seed)
33 |
34 | train_dataset = TextMelLoader(hps.data.training_files, hps.data)
35 | collate_fn = TextMelCollate(1)
36 | train_loader = DataLoader(train_dataset, num_workers=8, shuffle=True,
37 | batch_size=hps.train.batch_size, pin_memory=True,
38 | drop_last=True, collate_fn=collate_fn)
39 |
40 | generator = FlowGenerator_DDI(
41 | len(symbols) + getattr(hps.data, "add_blank", False),
42 | out_channels=hps.data.n_mel_channels,
43 | **hps.model).cuda()
44 | optimizer_g = commons.Adam(generator.parameters(), scheduler=hps.train.scheduler, dim_model=hps.model.hidden_channels, warmup_steps=hps.train.warmup_steps, lr=hps.train.learning_rate, betas=hps.train.betas, eps=hps.train.eps)
45 |
46 | generator.train()
47 | for batch_idx, (x, x_lengths, y, y_lengths) in enumerate(train_loader):
48 | x, x_lengths = x.cuda(), x_lengths.cuda()
49 | y, y_lengths = y.cuda(), y_lengths.cuda()
50 |
51 | _ = generator(x, x_lengths, y, y_lengths, gen=False)
52 | break
53 |
54 | utils.save_checkpoint(generator, optimizer_g, hps.train.learning_rate, 0, os.path.join(hps.model_dir, "ddi_G.pth"))
55 |
56 |
57 | if __name__ == "__main__":
58 | main()
59 |
--------------------------------------------------------------------------------
/models.py:
--------------------------------------------------------------------------------
1 | import math
2 | import torch
3 | from torch import nn
4 | from torch.nn import functional as F
5 |
6 | import modules
7 | import commons
8 | import attentions
9 | import monotonic_align
10 |
11 |
12 | class DurationPredictor(nn.Module):
13 | def __init__(self, in_channels, filter_channels, kernel_size, p_dropout):
14 | super().__init__()
15 |
16 | self.in_channels = in_channels
17 | self.filter_channels = filter_channels
18 | self.kernel_size = kernel_size
19 | self.p_dropout = p_dropout
20 |
21 | self.drop = nn.Dropout(p_dropout)
22 | self.conv_1 = nn.Conv1d(in_channels, filter_channels, kernel_size, padding=kernel_size//2)
23 | self.norm_1 = attentions.LayerNorm(filter_channels)
24 | self.conv_2 = nn.Conv1d(filter_channels, filter_channels, kernel_size, padding=kernel_size//2)
25 | self.norm_2 = attentions.LayerNorm(filter_channels)
26 | self.proj = nn.Conv1d(filter_channels, 1, 1)
27 |
28 | def forward(self, x, x_mask):
29 | x = self.conv_1(x * x_mask)
30 | x = torch.relu(x)
31 | x = self.norm_1(x)
32 | x = self.drop(x)
33 | x = self.conv_2(x * x_mask)
34 | x = torch.relu(x)
35 | x = self.norm_2(x)
36 | x = self.drop(x)
37 | x = self.proj(x * x_mask)
38 | return x * x_mask
39 |
40 |
41 | class TextEncoder(nn.Module):
42 | def __init__(self,
43 | n_vocab,
44 | out_channels,
45 | hidden_channels,
46 | filter_channels,
47 | filter_channels_dp,
48 | n_heads,
49 | n_layers,
50 | kernel_size,
51 | p_dropout,
52 | window_size=None,
53 | block_length=None,
54 | mean_only=False,
55 | prenet=False,
56 | gin_channels=0):
57 |
58 | super().__init__()
59 |
60 | self.n_vocab = n_vocab
61 | self.out_channels = out_channels
62 | self.hidden_channels = hidden_channels
63 | self.filter_channels = filter_channels
64 | self.filter_channels_dp = filter_channels_dp
65 | self.n_heads = n_heads
66 | self.n_layers = n_layers
67 | self.kernel_size = kernel_size
68 | self.p_dropout = p_dropout
69 | self.window_size = window_size
70 | self.block_length = block_length
71 | self.mean_only = mean_only
72 | self.prenet = prenet
73 | self.gin_channels = gin_channels
74 |
75 | self.emb = nn.Embedding(n_vocab, hidden_channels)
76 | nn.init.normal_(self.emb.weight, 0.0, hidden_channels**-0.5)
77 |
78 | if prenet:
79 | self.pre = modules.ConvReluNorm(hidden_channels, hidden_channels, hidden_channels, kernel_size=5, n_layers=3, p_dropout=0.5)
80 | self.encoder = attentions.Encoder(
81 | hidden_channels,
82 | filter_channels,
83 | n_heads,
84 | n_layers,
85 | kernel_size,
86 | p_dropout,
87 | window_size=window_size,
88 | block_length=block_length,
89 | )
90 |
91 | self.proj_m = nn.Conv1d(hidden_channels, out_channels, 1)
92 | if not mean_only:
93 | self.proj_s = nn.Conv1d(hidden_channels, out_channels, 1)
94 | self.proj_w = DurationPredictor(hidden_channels + gin_channels, filter_channels_dp, kernel_size, p_dropout)
95 |
96 | def forward(self, x, x_lengths, g=None):
97 | x = self.emb(x) * math.sqrt(self.hidden_channels) # [b, t, h]
98 | x = torch.transpose(x, 1, -1) # [b, h, t]
99 | x_mask = torch.unsqueeze(commons.sequence_mask(x_lengths, x.size(2)), 1).to(x.dtype)
100 |
101 | if self.prenet:
102 | x = self.pre(x, x_mask)
103 | x = self.encoder(x, x_mask)
104 |
105 | if g is not None:
106 | g_exp = g.expand(-1, -1, x.size(-1))
107 | x_dp = torch.cat([torch.detach(x), g_exp], 1)
108 | else:
109 | x_dp = torch.detach(x)
110 |
111 | x_m = self.proj_m(x) * x_mask
112 | if not self.mean_only:
113 | x_logs = self.proj_s(x) * x_mask
114 | else:
115 | x_logs = torch.zeros_like(x_m)
116 |
117 | logw = self.proj_w(x_dp, x_mask)
118 | return x_m, x_logs, logw, x_mask
119 |
120 |
121 | class FlowSpecDecoder(nn.Module):
122 | def __init__(self,
123 | in_channels,
124 | hidden_channels,
125 | kernel_size,
126 | dilation_rate,
127 | n_blocks,
128 | n_layers,
129 | p_dropout=0.,
130 | n_split=4,
131 | n_sqz=2,
132 | sigmoid_scale=False,
133 | gin_channels=0):
134 | super().__init__()
135 |
136 | self.in_channels = in_channels
137 | self.hidden_channels = hidden_channels
138 | self.kernel_size = kernel_size
139 | self.dilation_rate = dilation_rate
140 | self.n_blocks = n_blocks
141 | self.n_layers = n_layers
142 | self.p_dropout = p_dropout
143 | self.n_split = n_split
144 | self.n_sqz = n_sqz
145 | self.sigmoid_scale = sigmoid_scale
146 | self.gin_channels = gin_channels
147 |
148 | self.flows = nn.ModuleList()
149 | for b in range(n_blocks):
150 | self.flows.append(modules.ActNorm(channels=in_channels * n_sqz))
151 | self.flows.append(modules.InvConvNear(channels=in_channels * n_sqz, n_split=n_split))
152 | self.flows.append(
153 | attentions.CouplingBlock(
154 | in_channels * n_sqz,
155 | hidden_channels,
156 | kernel_size=kernel_size,
157 | dilation_rate=dilation_rate,
158 | n_layers=n_layers,
159 | gin_channels=gin_channels,
160 | p_dropout=p_dropout,
161 | sigmoid_scale=sigmoid_scale))
162 |
163 | def forward(self, x, x_mask, g=None, reverse=False):
164 | if not reverse:
165 | flows = self.flows
166 | logdet_tot = 0
167 | else:
168 | flows = reversed(self.flows)
169 | logdet_tot = None
170 |
171 | if self.n_sqz > 1:
172 | x, x_mask = commons.squeeze(x, x_mask, self.n_sqz)
173 | for f in flows:
174 | if not reverse:
175 | x, logdet = f(x, x_mask, g=g, reverse=reverse)
176 | logdet_tot += logdet
177 | else:
178 | x, logdet = f(x, x_mask, g=g, reverse=reverse)
179 | if self.n_sqz > 1:
180 | x, x_mask = commons.unsqueeze(x, x_mask, self.n_sqz)
181 | return x, logdet_tot
182 |
183 | def store_inverse(self):
184 | for f in self.flows:
185 | f.store_inverse()
186 |
187 |
188 | class FlowGenerator(nn.Module):
189 | def __init__(self,
190 | n_vocab,
191 | hidden_channels,
192 | filter_channels,
193 | filter_channels_dp,
194 | out_channels,
195 | kernel_size=3,
196 | n_heads=2,
197 | n_layers_enc=6,
198 | p_dropout=0.,
199 | n_blocks_dec=12,
200 | kernel_size_dec=5,
201 | dilation_rate=5,
202 | n_block_layers=4,
203 | p_dropout_dec=0.,
204 | n_speakers=0,
205 | gin_channels=0,
206 | n_split=4,
207 | n_sqz=1,
208 | sigmoid_scale=False,
209 | window_size=None,
210 | block_length=None,
211 | mean_only=False,
212 | hidden_channels_enc=None,
213 | hidden_channels_dec=None,
214 | prenet=False,
215 | **kwargs):
216 |
217 | super().__init__()
218 | self.n_vocab = n_vocab
219 | self.hidden_channels = hidden_channels
220 | self.filter_channels = filter_channels
221 | self.filter_channels_dp = filter_channels_dp
222 | self.out_channels = out_channels
223 | self.kernel_size = kernel_size
224 | self.n_heads = n_heads
225 | self.n_layers_enc = n_layers_enc
226 | self.p_dropout = p_dropout
227 | self.n_blocks_dec = n_blocks_dec
228 | self.kernel_size_dec = kernel_size_dec
229 | self.dilation_rate = dilation_rate
230 | self.n_block_layers = n_block_layers
231 | self.p_dropout_dec = p_dropout_dec
232 | self.n_speakers = n_speakers
233 | self.gin_channels = gin_channels
234 | self.n_split = n_split
235 | self.n_sqz = n_sqz
236 | self.sigmoid_scale = sigmoid_scale
237 | self.window_size = window_size
238 | self.block_length = block_length
239 | self.mean_only = mean_only
240 | self.hidden_channels_enc = hidden_channels_enc
241 | self.hidden_channels_dec = hidden_channels_dec
242 | self.prenet = prenet
243 |
244 | self.encoder = TextEncoder(
245 | n_vocab,
246 | out_channels,
247 | hidden_channels_enc or hidden_channels,
248 | filter_channels,
249 | filter_channels_dp,
250 | n_heads,
251 | n_layers_enc,
252 | kernel_size,
253 | p_dropout,
254 | window_size=window_size,
255 | block_length=block_length,
256 | mean_only=mean_only,
257 | prenet=prenet,
258 | gin_channels=gin_channels)
259 |
260 | self.decoder = FlowSpecDecoder(
261 | out_channels,
262 | hidden_channels_dec or hidden_channels,
263 | kernel_size_dec,
264 | dilation_rate,
265 | n_blocks_dec,
266 | n_block_layers,
267 | p_dropout=p_dropout_dec,
268 | n_split=n_split,
269 | n_sqz=n_sqz,
270 | sigmoid_scale=sigmoid_scale,
271 | gin_channels=gin_channels)
272 |
273 | if n_speakers > 1:
274 | self.emb_g = nn.Embedding(n_speakers, gin_channels)
275 | nn.init.uniform_(self.emb_g.weight, -0.1, 0.1)
276 |
277 | def forward(self, x, x_lengths, y=None, y_lengths=None, g=None, gen=False, noise_scale=1., length_scale=1.):
278 | if g is not None:
279 | g = F.normalize(self.emb_g(g)).unsqueeze(-1) # [b, h]
280 | x_m, x_logs, logw, x_mask = self.encoder(x, x_lengths, g=g)
281 |
282 | if gen:
283 | w = torch.exp(logw) * x_mask * length_scale
284 | w_ceil = torch.ceil(w)
285 | y_lengths = torch.clamp_min(torch.sum(w_ceil, [1, 2]), 1).long()
286 | y_max_length = None
287 | else:
288 | y_max_length = y.size(2)
289 | y, y_lengths, y_max_length = self.preprocess(y, y_lengths, y_max_length)
290 | z_mask = torch.unsqueeze(commons.sequence_mask(y_lengths, y_max_length), 1).to(x_mask.dtype)
291 | attn_mask = torch.unsqueeze(x_mask, -1) * torch.unsqueeze(z_mask, 2)
292 |
293 | if gen:
294 | attn = commons.generate_path(w_ceil.squeeze(1), attn_mask.squeeze(1)).unsqueeze(1)
295 | z_m = torch.matmul(attn.squeeze(1).transpose(1, 2), x_m.transpose(1, 2)).transpose(1, 2) # [b, t', t], [b, t, d] -> [b, d, t']
296 | z_logs = torch.matmul(attn.squeeze(1).transpose(1, 2), x_logs.transpose(1, 2)).transpose(1, 2) # [b, t', t], [b, t, d] -> [b, d, t']
297 | logw_ = torch.log(1e-8 + torch.sum(attn, -1)) * x_mask
298 |
299 | z = (z_m + torch.exp(z_logs) * torch.randn_like(z_m) * noise_scale) * z_mask
300 | y, logdet = self.decoder(z, z_mask, g=g, reverse=True)
301 | return (y, z_m, z_logs, logdet, z_mask), (x_m, x_logs, x_mask), (attn, logw, logw_)
302 | else:
303 | z, logdet = self.decoder(y, z_mask, g=g, reverse=False)
304 | with torch.no_grad():
305 | x_s_sq_r = torch.exp(-2 * x_logs)
306 | logp1 = torch.sum(-0.5 * math.log(2 * math.pi) - x_logs, [1]).unsqueeze(-1) # [b, t, 1]
307 | logp2 = torch.matmul(x_s_sq_r.transpose(1,2), -0.5 * (z ** 2)) # [b, t, d] x [b, d, t'] = [b, t, t']
308 | logp3 = torch.matmul((x_m * x_s_sq_r).transpose(1,2), z) # [b, t, d] x [b, d, t'] = [b, t, t']
309 | logp4 = torch.sum(-0.5 * (x_m ** 2) * x_s_sq_r, [1]).unsqueeze(-1) # [b, t, 1]
310 | logp = logp1 + logp2 + logp3 + logp4 # [b, t, t']
311 |
312 | attn = monotonic_align.maximum_path(logp, attn_mask.squeeze(1)).unsqueeze(1).detach()
313 | z_m = torch.matmul(attn.squeeze(1).transpose(1, 2), x_m.transpose(1, 2)).transpose(1, 2) # [b, t', t], [b, t, d] -> [b, d, t']
314 | z_logs = torch.matmul(attn.squeeze(1).transpose(1, 2), x_logs.transpose(1, 2)).transpose(1, 2) # [b, t', t], [b, t, d] -> [b, d, t']
315 | logw_ = torch.log(1e-8 + torch.sum(attn, -1)) * x_mask
316 | return (z, z_m, z_logs, logdet, z_mask), (x_m, x_logs, x_mask), (attn, logw, logw_)
317 |
318 | def preprocess(self, y, y_lengths, y_max_length):
319 | if y_max_length is not None:
320 | y_max_length = (y_max_length // self.n_sqz) * self.n_sqz
321 | y = y[:,:,:y_max_length]
322 | y_lengths = (y_lengths // self.n_sqz) * self.n_sqz
323 | return y, y_lengths, y_max_length
324 |
325 | def store_inverse(self):
326 | self.decoder.store_inverse()
327 |
--------------------------------------------------------------------------------
/modules.py:
--------------------------------------------------------------------------------
1 | import copy
2 | import math
3 | import numpy as np
4 | import scipy
5 | import torch
6 | from torch import nn
7 | from torch.nn import functional as F
8 |
9 | import commons
10 |
11 |
12 | class LayerNorm(nn.Module):
13 | def __init__(self, channels, eps=1e-4):
14 | super().__init__()
15 | self.channels = channels
16 | self.eps = eps
17 |
18 | self.gamma = nn.Parameter(torch.ones(channels))
19 | self.beta = nn.Parameter(torch.zeros(channels))
20 |
21 | def forward(self, x):
22 | n_dims = len(x.shape)
23 | mean = torch.mean(x, 1, keepdim=True)
24 | variance = torch.mean((x -mean)**2, 1, keepdim=True)
25 |
26 | x = (x - mean) * torch.rsqrt(variance + self.eps)
27 |
28 | shape = [1, -1] + [1] * (n_dims - 2)
29 | x = x * self.gamma.view(*shape) + self.beta.view(*shape)
30 | return x
31 |
32 |
33 | class ConvReluNorm(nn.Module):
34 | def __init__(self, in_channels, hidden_channels, out_channels, kernel_size, n_layers, p_dropout):
35 | super().__init__()
36 | self.in_channels = in_channels
37 | self.hidden_channels = hidden_channels
38 | self.out_channels = out_channels
39 | self.kernel_size = kernel_size
40 | self.n_layers = n_layers
41 | self.p_dropout = p_dropout
42 | assert n_layers > 1, "Number of layers should be larger than 0."
43 |
44 | self.conv_layers = nn.ModuleList()
45 | self.norm_layers = nn.ModuleList()
46 | self.conv_layers.append(nn.Conv1d(in_channels, hidden_channels, kernel_size, padding=kernel_size//2))
47 | self.norm_layers.append(LayerNorm(hidden_channels))
48 | self.relu_drop = nn.Sequential(
49 | nn.ReLU(),
50 | nn.Dropout(p_dropout))
51 | for _ in range(n_layers-1):
52 | self.conv_layers.append(nn.Conv1d(hidden_channels, hidden_channels, kernel_size, padding=kernel_size//2))
53 | self.norm_layers.append(LayerNorm(hidden_channels))
54 | self.proj = nn.Conv1d(hidden_channels, out_channels, 1)
55 | self.proj.weight.data.zero_()
56 | self.proj.bias.data.zero_()
57 |
58 | def forward(self, x, x_mask):
59 | x_org = x
60 | for i in range(self.n_layers):
61 | x = self.conv_layers[i](x * x_mask)
62 | x = self.norm_layers[i](x)
63 | x = self.relu_drop(x)
64 | x = x_org + self.proj(x)
65 | return x * x_mask
66 |
67 |
68 | class WN(torch.nn.Module):
69 | def __init__(self, in_channels, hidden_channels, kernel_size, dilation_rate, n_layers, gin_channels=0, p_dropout=0):
70 | super(WN, self).__init__()
71 | assert(kernel_size % 2 == 1)
72 | assert(hidden_channels % 2 == 0)
73 | self.in_channels = in_channels
74 | self.hidden_channels =hidden_channels
75 | self.kernel_size = kernel_size,
76 | self.dilation_rate = dilation_rate
77 | self.n_layers = n_layers
78 | self.gin_channels = gin_channels
79 | self.p_dropout = p_dropout
80 |
81 | self.in_layers = torch.nn.ModuleList()
82 | self.res_skip_layers = torch.nn.ModuleList()
83 | self.drop = nn.Dropout(p_dropout)
84 |
85 | if gin_channels != 0:
86 | cond_layer = torch.nn.Conv1d(gin_channels, 2*hidden_channels*n_layers, 1)
87 | self.cond_layer = torch.nn.utils.weight_norm(cond_layer, name='weight')
88 |
89 | for i in range(n_layers):
90 | dilation = dilation_rate ** i
91 | padding = int((kernel_size * dilation - dilation) / 2)
92 | in_layer = torch.nn.Conv1d(hidden_channels, 2*hidden_channels, kernel_size,
93 | dilation=dilation, padding=padding)
94 | in_layer = torch.nn.utils.weight_norm(in_layer, name='weight')
95 | self.in_layers.append(in_layer)
96 |
97 | # last one is not necessary
98 | if i < n_layers - 1:
99 | res_skip_channels = 2 * hidden_channels
100 | else:
101 | res_skip_channels = hidden_channels
102 |
103 | res_skip_layer = torch.nn.Conv1d(hidden_channels, res_skip_channels, 1)
104 | res_skip_layer = torch.nn.utils.weight_norm(res_skip_layer, name='weight')
105 | self.res_skip_layers.append(res_skip_layer)
106 |
107 | def forward(self, x, x_mask=None, g=None, **kwargs):
108 | output = torch.zeros_like(x)
109 | n_channels_tensor = torch.IntTensor([self.hidden_channels])
110 |
111 | if g is not None:
112 | g = self.cond_layer(g)
113 |
114 | for i in range(self.n_layers):
115 | x_in = self.in_layers[i](x)
116 | x_in = self.drop(x_in)
117 | if g is not None:
118 | cond_offset = i * 2 * self.hidden_channels
119 | g_l = g[:,cond_offset:cond_offset+2*self.hidden_channels,:]
120 | else:
121 | g_l = torch.zeros_like(x_in)
122 |
123 | acts = commons.fused_add_tanh_sigmoid_multiply(
124 | x_in,
125 | g_l,
126 | n_channels_tensor)
127 |
128 | res_skip_acts = self.res_skip_layers[i](acts)
129 | if i < self.n_layers - 1:
130 | x = (x + res_skip_acts[:,:self.hidden_channels,:]) * x_mask
131 | output = output + res_skip_acts[:,self.hidden_channels:,:]
132 | else:
133 | output = output + res_skip_acts
134 | return output * x_mask
135 |
136 | def remove_weight_norm(self):
137 | if self.gin_channels != 0:
138 | torch.nn.utils.remove_weight_norm(self.cond_layer)
139 | for l in self.in_layers:
140 | torch.nn.utils.remove_weight_norm(l)
141 | for l in self.res_skip_layers:
142 | torch.nn.utils.remove_weight_norm(l)
143 |
144 |
145 | class ActNorm(nn.Module):
146 | def __init__(self, channels, ddi=False, **kwargs):
147 | super().__init__()
148 | self.channels = channels
149 | self.initialized = not ddi
150 |
151 | self.logs = nn.Parameter(torch.zeros(1, channels, 1))
152 | self.bias = nn.Parameter(torch.zeros(1, channels, 1))
153 |
154 | def forward(self, x, x_mask=None, reverse=False, **kwargs):
155 | if x_mask is None:
156 | x_mask = torch.ones(x.size(0), 1, x.size(2)).to(device=x.device, dtype=x.dtype)
157 | x_len = torch.sum(x_mask, [1, 2])
158 | if not self.initialized:
159 | self.initialize(x, x_mask)
160 | self.initialized = True
161 |
162 | if reverse:
163 | z = (x - self.bias) * torch.exp(-self.logs) * x_mask
164 | logdet = None
165 | else:
166 | z = (self.bias + torch.exp(self.logs) * x) * x_mask
167 | logdet = torch.sum(self.logs) * x_len # [b]
168 |
169 | return z, logdet
170 |
171 | def store_inverse(self):
172 | pass
173 |
174 | def set_ddi(self, ddi):
175 | self.initialized = not ddi
176 |
177 | def initialize(self, x, x_mask):
178 | with torch.no_grad():
179 | denom = torch.sum(x_mask, [0, 2])
180 | m = torch.sum(x * x_mask, [0, 2]) / denom
181 | m_sq = torch.sum(x * x * x_mask, [0, 2]) / denom
182 | v = m_sq - (m ** 2)
183 | logs = 0.5 * torch.log(torch.clamp_min(v, 1e-6))
184 |
185 | bias_init = (-m * torch.exp(-logs)).view(*self.bias.shape).to(dtype=self.bias.dtype)
186 | logs_init = (-logs).view(*self.logs.shape).to(dtype=self.logs.dtype)
187 |
188 | self.bias.data.copy_(bias_init)
189 | self.logs.data.copy_(logs_init)
190 |
191 |
192 | class InvConvNear(nn.Module):
193 | def __init__(self, channels, n_split=4, no_jacobian=False, **kwargs):
194 | super().__init__()
195 | assert(n_split % 2 == 0)
196 | self.channels = channels
197 | self.n_split = n_split
198 | self.no_jacobian = no_jacobian
199 |
200 | w_init = torch.qr(torch.FloatTensor(self.n_split, self.n_split).normal_())[0]
201 | if torch.det(w_init) < 0:
202 | w_init[:,0] = -1 * w_init[:,0]
203 | self.weight = nn.Parameter(w_init)
204 |
205 | def forward(self, x, x_mask=None, reverse=False, **kwargs):
206 | b, c, t = x.size()
207 | assert(c % self.n_split == 0)
208 | if x_mask is None:
209 | x_mask = 1
210 | x_len = torch.ones((b,), dtype=x.dtype, device=x.device) * t
211 | else:
212 | x_len = torch.sum(x_mask, [1, 2])
213 |
214 | x = x.view(b, 2, c // self.n_split, self.n_split // 2, t)
215 | x = x.permute(0, 1, 3, 2, 4).contiguous().view(b, self.n_split, c // self.n_split, t)
216 |
217 | if reverse:
218 | if hasattr(self, "weight_inv"):
219 | weight = self.weight_inv
220 | else:
221 | weight = torch.inverse(self.weight.float()).to(dtype=self.weight.dtype)
222 | logdet = None
223 | else:
224 | weight = self.weight
225 | if self.no_jacobian:
226 | logdet = 0
227 | else:
228 | logdet = torch.logdet(self.weight) * (c / self.n_split) * x_len # [b]
229 |
230 | weight = weight.view(self.n_split, self.n_split, 1, 1)
231 | z = F.conv2d(x, weight)
232 |
233 | z = z.view(b, 2, self.n_split // 2, c // self.n_split, t)
234 | z = z.permute(0, 1, 3, 2, 4).contiguous().view(b, c, t) * x_mask
235 | return z, logdet
236 |
237 | def store_inverse(self):
238 | self.weight_inv = torch.inverse(self.weight.float()).to(dtype=self.weight.dtype)
239 |
--------------------------------------------------------------------------------
/monotonic_align/__init__.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import torch
3 | from .monotonic_align.core import maximum_path_c
4 |
5 |
6 | def maximum_path(value, mask):
7 | """ Cython optimised version.
8 | value: [b, t_x, t_y]
9 | mask: [b, t_x, t_y]
10 | """
11 | value = value * mask
12 | device = value.device
13 | dtype = value.dtype
14 | value = value.data.cpu().numpy().astype(np.float32)
15 | path = np.zeros_like(value).astype(np.int32)
16 | mask = mask.data.cpu().numpy()
17 |
18 | t_x_max = mask.sum(1)[:, 0].astype(np.int32)
19 | t_y_max = mask.sum(2)[:, 0].astype(np.int32)
20 | maximum_path_c(path, value, t_x_max, t_y_max)
21 | return torch.from_numpy(path).to(device=device, dtype=dtype)
22 |
--------------------------------------------------------------------------------
/monotonic_align/core.pyx:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | cimport numpy as np
3 | cimport cython
4 | from cython.parallel import prange
5 |
6 |
7 | @cython.boundscheck(False)
8 | @cython.wraparound(False)
9 | cdef void maximum_path_each(int[:,::1] path, float[:,::1] value, int t_x, int t_y, float max_neg_val) nogil:
10 | cdef int x
11 | cdef int y
12 | cdef float v_prev
13 | cdef float v_cur
14 | cdef float tmp
15 | cdef int index = t_x - 1
16 |
17 | for y in range(t_y):
18 | for x in range(max(0, t_x + y - t_y), min(t_x, y + 1)):
19 | if x == y:
20 | v_cur = max_neg_val
21 | else:
22 | v_cur = value[x, y-1]
23 | if x == 0:
24 | if y == 0:
25 | v_prev = 0.
26 | else:
27 | v_prev = max_neg_val
28 | else:
29 | v_prev = value[x-1, y-1]
30 | value[x, y] = max(v_cur, v_prev) + value[x, y]
31 |
32 | for y in range(t_y - 1, -1, -1):
33 | path[index, y] = 1
34 | if index != 0 and (index == y or value[index, y-1] < value[index-1, y-1]):
35 | index = index - 1
36 |
37 |
38 | @cython.boundscheck(False)
39 | @cython.wraparound(False)
40 | cpdef void maximum_path_c(int[:,:,::1] paths, float[:,:,::1] values, int[::1] t_xs, int[::1] t_ys, float max_neg_val=-1e9) nogil:
41 | cdef int b = values.shape[0]
42 |
43 | cdef int i
44 | for i in prange(b, nogil=True):
45 | maximum_path_each(paths[i], values[i], t_xs[i], t_ys[i], max_neg_val)
46 |
--------------------------------------------------------------------------------
/monotonic_align/setup.py:
--------------------------------------------------------------------------------
1 | from distutils.core import setup
2 | from Cython.Build import cythonize
3 | import numpy
4 |
5 | setup(
6 | name = 'monotonic_align',
7 | ext_modules = cythonize("core.pyx"),
8 | include_dirs=[numpy.get_include()]
9 | )
10 |
--------------------------------------------------------------------------------
/resources/fig_1a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaywalnut310/glow-tts/13e997689d643410f5d9f1f9a73877ae85e19bc2/resources/fig_1a.png
--------------------------------------------------------------------------------
/resources/fig_1b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaywalnut310/glow-tts/13e997689d643410f5d9f1f9a73877ae85e19bc2/resources/fig_1b.png
--------------------------------------------------------------------------------
/stft.py:
--------------------------------------------------------------------------------
1 | """
2 | BSD 3-Clause License
3 |
4 | Copyright (c) 2017, Prem Seetharaman
5 | All rights reserved.
6 |
7 | * Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are met:
9 |
10 | * Redistributions of source code must retain the above copyright notice,
11 | this list of conditions and the following disclaimer.
12 |
13 | * Redistributions in binary form must reproduce the above copyright notice, this
14 | list of conditions and the following disclaimer in the
15 | documentation and/or other materials provided with the distribution.
16 |
17 | * Neither the name of the copyright holder nor the names of its
18 | contributors may be used to endorse or promote products derived from this
19 | software without specific prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
25 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 | """
32 |
33 | import torch
34 | import numpy as np
35 | import torch.nn.functional as F
36 | from torch.autograd import Variable
37 | from scipy.signal import get_window
38 | from librosa.util import pad_center, tiny
39 | from librosa import stft, istft
40 | from audio_processing import window_sumsquare
41 |
42 |
43 | class STFT(torch.nn.Module):
44 | """adapted from Prem Seetharaman's https://github.com/pseeth/pytorch-stft"""
45 | def __init__(self, filter_length=800, hop_length=200, win_length=800,
46 | window='hann'):
47 | super(STFT, self).__init__()
48 | self.filter_length = filter_length
49 | self.hop_length = hop_length
50 | self.win_length = win_length
51 | self.window = window
52 | self.forward_transform = None
53 | scale = self.filter_length / self.hop_length
54 | fourier_basis = np.fft.fft(np.eye(self.filter_length))
55 |
56 | cutoff = int((self.filter_length / 2 + 1))
57 | fourier_basis = np.vstack([np.real(fourier_basis[:cutoff, :]),
58 | np.imag(fourier_basis[:cutoff, :])])
59 |
60 | forward_basis = torch.FloatTensor(fourier_basis[:, None, :])
61 | inverse_basis = torch.FloatTensor(
62 | np.linalg.pinv(scale * fourier_basis).T[:, None, :])
63 |
64 | if window is not None:
65 | assert(filter_length >= win_length)
66 | # get window and zero center pad it to filter_length
67 | fft_window = get_window(window, win_length, fftbins=True)
68 | fft_window = pad_center(fft_window, filter_length)
69 | fft_window = torch.from_numpy(fft_window).float()
70 |
71 | # window the bases
72 | forward_basis *= fft_window
73 | inverse_basis *= fft_window
74 |
75 | self.register_buffer('forward_basis', forward_basis.float())
76 | self.register_buffer('inverse_basis', inverse_basis.float())
77 |
78 | def transform(self, input_data):
79 | num_batches = input_data.size(0)
80 | num_samples = input_data.size(1)
81 |
82 | self.num_samples = num_samples
83 |
84 | if input_data.device.type == "cuda":
85 | # similar to librosa, reflect-pad the input
86 | input_data = input_data.view(num_batches, 1, num_samples)
87 | input_data = F.pad(
88 | input_data.unsqueeze(1),
89 | (int(self.filter_length / 2), int(self.filter_length / 2), 0, 0),
90 | mode='reflect')
91 | input_data = input_data.squeeze(1)
92 |
93 | forward_transform = F.conv1d(
94 | input_data,
95 | self.forward_basis,
96 | stride=self.hop_length,
97 | padding=0)
98 |
99 | cutoff = int((self.filter_length / 2) + 1)
100 | real_part = forward_transform[:, :cutoff, :]
101 | imag_part = forward_transform[:, cutoff:, :]
102 | else:
103 | x = input_data.detach().numpy()
104 | real_part = []
105 | imag_part = []
106 | for y in x:
107 | y_ = stft(y, self.filter_length, self.hop_length, self.win_length, self.window)
108 | real_part.append(y_.real[None,:,:])
109 | imag_part.append(y_.imag[None,:,:])
110 | real_part = np.concatenate(real_part, 0)
111 | imag_part = np.concatenate(imag_part, 0)
112 |
113 | real_part = torch.from_numpy(real_part).to(input_data.dtype)
114 | imag_part = torch.from_numpy(imag_part).to(input_data.dtype)
115 |
116 | magnitude = torch.sqrt(real_part**2 + imag_part**2)
117 | phase = torch.atan2(imag_part.data, real_part.data)
118 |
119 | return magnitude, phase
120 |
121 | def inverse(self, magnitude, phase):
122 | recombine_magnitude_phase = torch.cat(
123 | [magnitude*torch.cos(phase), magnitude*torch.sin(phase)], dim=1)
124 |
125 | if magnitude.device.type == "cuda":
126 | inverse_transform = F.conv_transpose1d(
127 | recombine_magnitude_phase,
128 | self.inverse_basis,
129 | stride=self.hop_length,
130 | padding=0)
131 |
132 | if self.window is not None:
133 | window_sum = window_sumsquare(
134 | self.window, magnitude.size(-1), hop_length=self.hop_length,
135 | win_length=self.win_length, n_fft=self.filter_length,
136 | dtype=np.float32)
137 | # remove modulation effects
138 | approx_nonzero_indices = torch.from_numpy(
139 | np.where(window_sum > tiny(window_sum))[0])
140 | window_sum = torch.from_numpy(window_sum).to(inverse_transform.device)
141 | inverse_transform[:, :, approx_nonzero_indices] /= window_sum[approx_nonzero_indices]
142 |
143 | # scale by hop ratio
144 | inverse_transform *= float(self.filter_length) / self.hop_length
145 |
146 | inverse_transform = inverse_transform[:, :, int(self.filter_length/2):]
147 | inverse_transform = inverse_transform[:, :, :-int(self.filter_length/2):]
148 | inverse_transform = inverse_transform.squeeze(1)
149 | else:
150 | x_org = recombine_magnitude_phase.detach().numpy()
151 | n_b, n_f, n_t = x_org.shape
152 | x = np.empty([n_b, n_f//2, n_t], dtype=np.complex64)
153 | x.real = x_org[:,:n_f//2]
154 | x.imag = x_org[:,n_f//2:]
155 | inverse_transform = []
156 | for y in x:
157 | y_ = istft(y, self.hop_length, self.win_length, self.window)
158 | inverse_transform.append(y_[None,:])
159 | inverse_transform = np.concatenate(inverse_transform, 0)
160 | inverse_transform = torch.from_numpy(inverse_transform).to(recombine_magnitude_phase.dtype)
161 |
162 | return inverse_transform
163 |
164 | def forward(self, input_data):
165 | self.magnitude, self.phase = self.transform(input_data)
166 | reconstruction = self.inverse(self.magnitude, self.phase)
167 | return reconstruction
168 |
--------------------------------------------------------------------------------
/text/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2017 Keith Ito
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/text/__init__.py:
--------------------------------------------------------------------------------
1 | """ from https://github.com/keithito/tacotron """
2 | import re
3 | from text import cleaners
4 | from text.symbols import symbols
5 |
6 |
7 | # Mappings from symbol to numeric ID and vice versa:
8 | _symbol_to_id = {s: i for i, s in enumerate(symbols)}
9 | _id_to_symbol = {i: s for i, s in enumerate(symbols)}
10 |
11 | # Regular expression matching text enclosed in curly braces:
12 | _curly_re = re.compile(r'(.*?)\{(.+?)\}(.*)')
13 |
14 |
15 | def get_arpabet(word, dictionary):
16 | word_arpabet = dictionary.lookup(word)
17 | if word_arpabet is not None:
18 | return "{" + word_arpabet[0] + "}"
19 | else:
20 | return word
21 |
22 |
23 | def text_to_sequence(text, cleaner_names, dictionary=None):
24 | '''Converts a string of text to a sequence of IDs corresponding to the symbols in the text.
25 |
26 | The text can optionally have ARPAbet sequences enclosed in curly braces embedded
27 | in it. For example, "Turn left on {HH AW1 S S T AH0 N} Street."
28 |
29 | Args:
30 | text: string to convert to a sequence
31 | cleaner_names: names of the cleaner functions to run the text through
32 | dictionary: arpabet class with arpabet dictionary
33 |
34 | Returns:
35 | List of integers corresponding to the symbols in the text
36 | '''
37 | sequence = []
38 |
39 | space = _symbols_to_sequence(' ')
40 | # Check for curly braces and treat their contents as ARPAbet:
41 | while len(text):
42 | m = _curly_re.match(text)
43 | if not m:
44 | clean_text = _clean_text(text, cleaner_names)
45 | if dictionary is not None:
46 | clean_text = [get_arpabet(w, dictionary) for w in clean_text.split(" ")]
47 | for i in range(len(clean_text)):
48 | t = clean_text[i]
49 | if t.startswith("{"):
50 | sequence += _arpabet_to_sequence(t[1:-1])
51 | else:
52 | sequence += _symbols_to_sequence(t)
53 | sequence += space
54 | else:
55 | sequence += _symbols_to_sequence(clean_text)
56 | break
57 | sequence += _symbols_to_sequence(_clean_text(m.group(1), cleaner_names))
58 | sequence += _arpabet_to_sequence(m.group(2))
59 | text = m.group(3)
60 |
61 | # remove trailing space
62 | if dictionary is not None:
63 | sequence = sequence[:-1] if sequence[-1] == space[0] else sequence
64 | return sequence
65 |
66 |
67 | def sequence_to_text(sequence):
68 | '''Converts a sequence of IDs back to a string'''
69 | result = ''
70 | for symbol_id in sequence:
71 | if symbol_id in _id_to_symbol:
72 | s = _id_to_symbol[symbol_id]
73 | # Enclose ARPAbet back in curly braces:
74 | if len(s) > 1 and s[0] == '@':
75 | s = '{%s}' % s[1:]
76 | result += s
77 | return result.replace('}{', ' ')
78 |
79 |
80 | def _clean_text(text, cleaner_names):
81 | for name in cleaner_names:
82 | cleaner = getattr(cleaners, name)
83 | if not cleaner:
84 | raise Exception('Unknown cleaner: %s' % name)
85 | text = cleaner(text)
86 | return text
87 |
88 |
89 | def _symbols_to_sequence(symbols):
90 | return [_symbol_to_id[s] for s in symbols if _should_keep_symbol(s)]
91 |
92 |
93 | def _arpabet_to_sequence(text):
94 | return _symbols_to_sequence(['@' + s for s in text.split()])
95 |
96 |
97 | def _should_keep_symbol(s):
98 | return s in _symbol_to_id and s is not '_' and s is not '~'
99 |
--------------------------------------------------------------------------------
/text/cleaners.py:
--------------------------------------------------------------------------------
1 | """ from https://github.com/keithito/tacotron """
2 |
3 | '''
4 | Cleaners are transformations that run over the input text at both training and eval time.
5 |
6 | Cleaners can be selected by passing a comma-delimited list of cleaner names as the "cleaners"
7 | hyperparameter. Some cleaners are English-specific. You'll typically want to use:
8 | 1. "english_cleaners" for English text
9 | 2. "transliteration_cleaners" for non-English text that can be transliterated to ASCII using
10 | the Unidecode library (https://pypi.python.org/pypi/Unidecode)
11 | 3. "basic_cleaners" if you do not want to transliterate (in this case, you should also update
12 | the symbols in symbols.py to match your data).
13 | '''
14 |
15 | import re
16 | from unidecode import unidecode
17 | from .numbers import normalize_numbers
18 |
19 |
20 | # Regular expression matching whitespace:
21 | _whitespace_re = re.compile(r'\s+')
22 |
23 | # List of (regular expression, replacement) pairs for abbreviations:
24 | _abbreviations = [(re.compile('\\b%s\\.' % x[0], re.IGNORECASE), x[1]) for x in [
25 | ('mrs', 'misess'),
26 | ('mr', 'mister'),
27 | ('dr', 'doctor'),
28 | ('st', 'saint'),
29 | ('co', 'company'),
30 | ('jr', 'junior'),
31 | ('maj', 'major'),
32 | ('gen', 'general'),
33 | ('drs', 'doctors'),
34 | ('rev', 'reverend'),
35 | ('lt', 'lieutenant'),
36 | ('hon', 'honorable'),
37 | ('sgt', 'sergeant'),
38 | ('capt', 'captain'),
39 | ('esq', 'esquire'),
40 | ('ltd', 'limited'),
41 | ('col', 'colonel'),
42 | ('ft', 'fort'),
43 | ]]
44 |
45 |
46 | def expand_abbreviations(text):
47 | for regex, replacement in _abbreviations:
48 | text = re.sub(regex, replacement, text)
49 | return text
50 |
51 |
52 | def expand_numbers(text):
53 | return normalize_numbers(text)
54 |
55 |
56 | def lowercase(text):
57 | return text.lower()
58 |
59 |
60 | def collapse_whitespace(text):
61 | return re.sub(_whitespace_re, ' ', text)
62 |
63 |
64 | def convert_to_ascii(text):
65 | return unidecode(text)
66 |
67 |
68 | def basic_cleaners(text):
69 | '''Basic pipeline that lowercases and collapses whitespace without transliteration.'''
70 | text = lowercase(text)
71 | text = collapse_whitespace(text)
72 | return text
73 |
74 |
75 | def transliteration_cleaners(text):
76 | '''Pipeline for non-English text that transliterates to ASCII.'''
77 | text = convert_to_ascii(text)
78 | text = lowercase(text)
79 | text = collapse_whitespace(text)
80 | return text
81 |
82 |
83 | def english_cleaners(text):
84 | '''Pipeline for English text, including number and abbreviation expansion.'''
85 | text = convert_to_ascii(text)
86 | text = lowercase(text)
87 | text = expand_numbers(text)
88 | text = expand_abbreviations(text)
89 | text = collapse_whitespace(text)
90 | return text
91 |
--------------------------------------------------------------------------------
/text/cmudict.py:
--------------------------------------------------------------------------------
1 | """ from https://github.com/keithito/tacotron """
2 |
3 | import re
4 |
5 |
6 | valid_symbols = [
7 | 'AA', 'AA0', 'AA1', 'AA2', 'AE', 'AE0', 'AE1', 'AE2', 'AH', 'AH0', 'AH1', 'AH2',
8 | 'AO', 'AO0', 'AO1', 'AO2', 'AW', 'AW0', 'AW1', 'AW2', 'AY', 'AY0', 'AY1', 'AY2',
9 | 'B', 'CH', 'D', 'DH', 'EH', 'EH0', 'EH1', 'EH2', 'ER', 'ER0', 'ER1', 'ER2', 'EY',
10 | 'EY0', 'EY1', 'EY2', 'F', 'G', 'HH', 'IH', 'IH0', 'IH1', 'IH2', 'IY', 'IY0', 'IY1',
11 | 'IY2', 'JH', 'K', 'L', 'M', 'N', 'NG', 'OW', 'OW0', 'OW1', 'OW2', 'OY', 'OY0',
12 | 'OY1', 'OY2', 'P', 'R', 'S', 'SH', 'T', 'TH', 'UH', 'UH0', 'UH1', 'UH2', 'UW',
13 | 'UW0', 'UW1', 'UW2', 'V', 'W', 'Y', 'Z', 'ZH'
14 | ]
15 |
16 | _valid_symbol_set = set(valid_symbols)
17 |
18 |
19 | class CMUDict:
20 | '''Thin wrapper around CMUDict data. http://www.speech.cs.cmu.edu/cgi-bin/cmudict'''
21 | def __init__(self, file_or_path, keep_ambiguous=True):
22 | if isinstance(file_or_path, str):
23 | with open(file_or_path, encoding='latin-1') as f:
24 | entries = _parse_cmudict(f)
25 | else:
26 | entries = _parse_cmudict(file_or_path)
27 | if not keep_ambiguous:
28 | entries = {word: pron for word, pron in entries.items() if len(pron) == 1}
29 | self._entries = entries
30 |
31 |
32 | def __len__(self):
33 | return len(self._entries)
34 |
35 |
36 | def lookup(self, word):
37 | '''Returns list of ARPAbet pronunciations of the given word.'''
38 | return self._entries.get(word.upper())
39 |
40 |
41 |
42 | _alt_re = re.compile(r'\([0-9]+\)')
43 |
44 |
45 | def _parse_cmudict(file):
46 | cmudict = {}
47 | for line in file:
48 | if len(line) and (line[0] >= 'A' and line[0] <= 'Z' or line[0] == "'"):
49 | parts = line.split(' ')
50 | word = re.sub(_alt_re, '', parts[0])
51 | pronunciation = _get_pronunciation(parts[1])
52 | if pronunciation:
53 | if word in cmudict:
54 | cmudict[word].append(pronunciation)
55 | else:
56 | cmudict[word] = [pronunciation]
57 | return cmudict
58 |
59 |
60 | def _get_pronunciation(s):
61 | parts = s.strip().split(' ')
62 | for part in parts:
63 | if part not in _valid_symbol_set:
64 | return None
65 | return ' '.join(parts)
66 |
--------------------------------------------------------------------------------
/text/numbers.py:
--------------------------------------------------------------------------------
1 | """ from https://github.com/keithito/tacotron """
2 |
3 | import inflect
4 | import re
5 |
6 |
7 | _inflect = inflect.engine()
8 | _comma_number_re = re.compile(r'([0-9][0-9\,]+[0-9])')
9 | _decimal_number_re = re.compile(r'([0-9]+\.[0-9]+)')
10 | _pounds_re = re.compile(r'£([0-9\,]*[0-9]+)')
11 | _dollars_re = re.compile(r'\$([0-9\.\,]*[0-9]+)')
12 | _ordinal_re = re.compile(r'[0-9]+(st|nd|rd|th)')
13 | _number_re = re.compile(r'[0-9]+')
14 |
15 |
16 | def _remove_commas(m):
17 | return m.group(1).replace(',', '')
18 |
19 |
20 | def _expand_decimal_point(m):
21 | return m.group(1).replace('.', ' point ')
22 |
23 |
24 | def _expand_dollars(m):
25 | match = m.group(1)
26 | parts = match.split('.')
27 | if len(parts) > 2:
28 | return match + ' dollars' # Unexpected format
29 | dollars = int(parts[0]) if parts[0] else 0
30 | cents = int(parts[1]) if len(parts) > 1 and parts[1] else 0
31 | if dollars and cents:
32 | dollar_unit = 'dollar' if dollars == 1 else 'dollars'
33 | cent_unit = 'cent' if cents == 1 else 'cents'
34 | return '%s %s, %s %s' % (dollars, dollar_unit, cents, cent_unit)
35 | elif dollars:
36 | dollar_unit = 'dollar' if dollars == 1 else 'dollars'
37 | return '%s %s' % (dollars, dollar_unit)
38 | elif cents:
39 | cent_unit = 'cent' if cents == 1 else 'cents'
40 | return '%s %s' % (cents, cent_unit)
41 | else:
42 | return 'zero dollars'
43 |
44 |
45 | def _expand_ordinal(m):
46 | return _inflect.number_to_words(m.group(0))
47 |
48 |
49 | def _expand_number(m):
50 | num = int(m.group(0))
51 | if num > 1000 and num < 3000:
52 | if num == 2000:
53 | return 'two thousand'
54 | elif num > 2000 and num < 2010:
55 | return 'two thousand ' + _inflect.number_to_words(num % 100)
56 | elif num % 100 == 0:
57 | return _inflect.number_to_words(num // 100) + ' hundred'
58 | else:
59 | return _inflect.number_to_words(num, andword='', zero='oh', group=2).replace(', ', ' ')
60 | else:
61 | return _inflect.number_to_words(num, andword='')
62 |
63 |
64 | def normalize_numbers(text):
65 | text = re.sub(_comma_number_re, _remove_commas, text)
66 | text = re.sub(_pounds_re, r'\1 pounds', text)
67 | text = re.sub(_dollars_re, _expand_dollars, text)
68 | text = re.sub(_decimal_number_re, _expand_decimal_point, text)
69 | text = re.sub(_ordinal_re, _expand_ordinal, text)
70 | text = re.sub(_number_re, _expand_number, text)
71 | return text
72 |
--------------------------------------------------------------------------------
/text/symbols.py:
--------------------------------------------------------------------------------
1 | """ from https://github.com/keithito/tacotron """
2 |
3 | '''
4 | Defines the set of symbols used in text input to the model.
5 |
6 | The default is a set of ASCII characters that works well for English or text that has been run through Unidecode. For other data, you can modify _characters. See TRAINING_DATA.md for details. '''
7 | from text import cmudict
8 |
9 | _pad = '_'
10 | _punctuation = '!\'(),.:;? '
11 | _special = '-'
12 | _letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
13 |
14 | # Prepend "@" to ARPAbet symbols to ensure uniqueness (some are the same as uppercase letters):
15 | _arpabet = ['@' + s for s in cmudict.valid_symbols]
16 |
17 | # Export all symbols:
18 | symbols = [_pad] + list(_special) + list(_punctuation) + list(_letters) + _arpabet
19 |
--------------------------------------------------------------------------------
/train.py:
--------------------------------------------------------------------------------
1 | import os
2 | import json
3 | import argparse
4 | import math
5 | import torch
6 | from torch import nn, optim
7 | from torch.nn import functional as F
8 | from torch.utils.data import DataLoader
9 | from torch.utils.tensorboard import SummaryWriter
10 | import torch.multiprocessing as mp
11 | import torch.distributed as dist
12 | from apex.parallel import DistributedDataParallel as DDP
13 | from apex import amp
14 |
15 | from data_utils import TextMelLoader, TextMelCollate
16 | import models
17 | import commons
18 | import utils
19 | from text.symbols import symbols
20 |
21 |
22 | global_step = 0
23 |
24 |
25 | def main():
26 | """Assume Single Node Multi GPUs Training Only"""
27 | assert torch.cuda.is_available(), "CPU training is not allowed."
28 |
29 | n_gpus = torch.cuda.device_count()
30 | os.environ['MASTER_ADDR'] = 'localhost'
31 | os.environ['MASTER_PORT'] = '80000'
32 |
33 | hps = utils.get_hparams()
34 | mp.spawn(train_and_eval, nprocs=n_gpus, args=(n_gpus, hps,))
35 |
36 |
37 | def train_and_eval(rank, n_gpus, hps):
38 | global global_step
39 | if rank == 0:
40 | logger = utils.get_logger(hps.model_dir)
41 | logger.info(hps)
42 | utils.check_git_hash(hps.model_dir)
43 | writer = SummaryWriter(log_dir=hps.model_dir)
44 | writer_eval = SummaryWriter(log_dir=os.path.join(hps.model_dir, "eval"))
45 |
46 | dist.init_process_group(backend='nccl', init_method='env://', world_size=n_gpus, rank=rank)
47 | torch.manual_seed(hps.train.seed)
48 | torch.cuda.set_device(rank)
49 |
50 | train_dataset = TextMelLoader(hps.data.training_files, hps.data)
51 | train_sampler = torch.utils.data.distributed.DistributedSampler(
52 | train_dataset,
53 | num_replicas=n_gpus,
54 | rank=rank,
55 | shuffle=True)
56 | collate_fn = TextMelCollate(1)
57 | train_loader = DataLoader(train_dataset, num_workers=8, shuffle=False,
58 | batch_size=hps.train.batch_size, pin_memory=True,
59 | drop_last=True, collate_fn=collate_fn, sampler=train_sampler)
60 | if rank == 0:
61 | val_dataset = TextMelLoader(hps.data.validation_files, hps.data)
62 | val_loader = DataLoader(val_dataset, num_workers=8, shuffle=False,
63 | batch_size=hps.train.batch_size, pin_memory=True,
64 | drop_last=True, collate_fn=collate_fn)
65 |
66 | generator = models.FlowGenerator(
67 | n_vocab=len(symbols) + getattr(hps.data, "add_blank", False),
68 | out_channels=hps.data.n_mel_channels,
69 | **hps.model).cuda(rank)
70 | optimizer_g = commons.Adam(generator.parameters(), scheduler=hps.train.scheduler, dim_model=hps.model.hidden_channels, warmup_steps=hps.train.warmup_steps, lr=hps.train.learning_rate, betas=hps.train.betas, eps=hps.train.eps)
71 | if hps.train.fp16_run:
72 | generator, optimizer_g._optim = amp.initialize(generator, optimizer_g._optim, opt_level="O1")
73 | generator = DDP(generator)
74 | epoch_str = 1
75 | global_step = 0
76 | try:
77 | _, _, _, epoch_str = utils.load_checkpoint(utils.latest_checkpoint_path(hps.model_dir, "G_*.pth"), generator, optimizer_g)
78 | epoch_str += 1
79 | optimizer_g.step_num = (epoch_str - 1) * len(train_loader)
80 | optimizer_g._update_learning_rate()
81 | global_step = (epoch_str - 1) * len(train_loader)
82 | except:
83 | if hps.train.ddi and os.path.isfile(os.path.join(hps.model_dir, "ddi_G.pth")):
84 | _ = utils.load_checkpoint(os.path.join(hps.model_dir, "ddi_G.pth"), generator, optimizer_g)
85 |
86 | for epoch in range(epoch_str, hps.train.epochs + 1):
87 | if rank==0:
88 | train(rank, epoch, hps, generator, optimizer_g, train_loader, logger, writer)
89 | evaluate(rank, epoch, hps, generator, optimizer_g, val_loader, logger, writer_eval)
90 | utils.save_checkpoint(generator, optimizer_g, hps.train.learning_rate, epoch, os.path.join(hps.model_dir, "G_{}.pth".format(epoch)))
91 | else:
92 | train(rank, epoch, hps, generator, optimizer_g, train_loader, None, None)
93 |
94 |
95 | def train(rank, epoch, hps, generator, optimizer_g, train_loader, logger, writer):
96 | train_loader.sampler.set_epoch(epoch)
97 | global global_step
98 |
99 | generator.train()
100 | for batch_idx, (x, x_lengths, y, y_lengths) in enumerate(train_loader):
101 | x, x_lengths = x.cuda(rank, non_blocking=True), x_lengths.cuda(rank, non_blocking=True)
102 | y, y_lengths = y.cuda(rank, non_blocking=True), y_lengths.cuda(rank, non_blocking=True)
103 |
104 | # Train Generator
105 | optimizer_g.zero_grad()
106 |
107 | (z, z_m, z_logs, logdet, z_mask), (x_m, x_logs, x_mask), (attn, logw, logw_) = generator(x, x_lengths, y, y_lengths, gen=False)
108 | l_mle = commons.mle_loss(z, z_m, z_logs, logdet, z_mask)
109 | l_length = commons.duration_loss(logw, logw_, x_lengths)
110 |
111 | loss_gs = [l_mle, l_length]
112 | loss_g = sum(loss_gs)
113 |
114 | if hps.train.fp16_run:
115 | with amp.scale_loss(loss_g, optimizer_g._optim) as scaled_loss:
116 | scaled_loss.backward()
117 | grad_norm = commons.clip_grad_value_(amp.master_params(optimizer_g._optim), 5)
118 | else:
119 | loss_g.backward()
120 | grad_norm = commons.clip_grad_value_(generator.parameters(), 5)
121 | optimizer_g.step()
122 |
123 | if rank==0:
124 | if batch_idx % hps.train.log_interval == 0:
125 | (y_gen, *_), *_ = generator.module(x[:1], x_lengths[:1], gen=True)
126 | logger.info('Train Epoch: {} [{}/{} ({:.0f}%)]\tLoss: {:.6f}'.format(
127 | epoch, batch_idx * len(x), len(train_loader.dataset),
128 | 100. * batch_idx / len(train_loader),
129 | loss_g.item()))
130 | logger.info([x.item() for x in loss_gs] + [global_step, optimizer_g.get_lr()])
131 |
132 | scalar_dict = {"loss/g/total": loss_g, "learning_rate": optimizer_g.get_lr(), "grad_norm": grad_norm}
133 | scalar_dict.update({"loss/g/{}".format(i): v for i, v in enumerate(loss_gs)})
134 | utils.summarize(
135 | writer=writer,
136 | global_step=global_step,
137 | images={"y_org": utils.plot_spectrogram_to_numpy(y[0].data.cpu().numpy()),
138 | "y_gen": utils.plot_spectrogram_to_numpy(y_gen[0].data.cpu().numpy()),
139 | "attn": utils.plot_alignment_to_numpy(attn[0,0].data.cpu().numpy()),
140 | },
141 | scalars=scalar_dict)
142 | global_step += 1
143 |
144 | if rank == 0:
145 | logger.info('====> Epoch: {}'.format(epoch))
146 |
147 |
148 | def evaluate(rank, epoch, hps, generator, optimizer_g, val_loader, logger, writer_eval):
149 | if rank == 0:
150 | global global_step
151 | generator.eval()
152 | losses_tot = []
153 | with torch.no_grad():
154 | for batch_idx, (x, x_lengths, y, y_lengths) in enumerate(val_loader):
155 | x, x_lengths = x.cuda(rank, non_blocking=True), x_lengths.cuda(rank, non_blocking=True)
156 | y, y_lengths = y.cuda(rank, non_blocking=True), y_lengths.cuda(rank, non_blocking=True)
157 |
158 |
159 | (z, z_m, z_logs, logdet, z_mask), (x_m, x_logs, x_mask), (attn, logw, logw_) = generator(x, x_lengths, y, y_lengths, gen=False)
160 | l_mle = commons.mle_loss(z, z_m, z_logs, logdet, z_mask)
161 | l_length = commons.duration_loss(logw, logw_, x_lengths)
162 |
163 | loss_gs = [l_mle, l_length]
164 | loss_g = sum(loss_gs)
165 |
166 | if batch_idx == 0:
167 | losses_tot = loss_gs
168 | else:
169 | losses_tot = [x + y for (x, y) in zip(losses_tot, loss_gs)]
170 |
171 | if batch_idx % hps.train.log_interval == 0:
172 | logger.info('Eval Epoch: {} [{}/{} ({:.0f}%)]\tLoss: {:.6f}'.format(
173 | epoch, batch_idx * len(x), len(val_loader.dataset),
174 | 100. * batch_idx / len(val_loader),
175 | loss_g.item()))
176 | logger.info([x.item() for x in loss_gs])
177 |
178 |
179 | losses_tot = [x/len(val_loader) for x in losses_tot]
180 | loss_tot = sum(losses_tot)
181 | scalar_dict = {"loss/g/total": loss_tot}
182 | scalar_dict.update({"loss/g/{}".format(i): v for i, v in enumerate(losses_tot)})
183 | utils.summarize(
184 | writer=writer_eval,
185 | global_step=global_step,
186 | scalars=scalar_dict)
187 | logger.info('====> Epoch: {}'.format(epoch))
188 |
189 |
190 | if __name__ == "__main__":
191 | main()
192 |
--------------------------------------------------------------------------------
/train_ddi.sh:
--------------------------------------------------------------------------------
1 | config=$1
2 | modeldir=$2
3 |
4 | python init.py -c $config -m $modeldir
5 | python train.py -c $config -m $modeldir
6 |
--------------------------------------------------------------------------------
/utils.py:
--------------------------------------------------------------------------------
1 | import os
2 | import glob
3 | import sys
4 | import argparse
5 | import logging
6 | import json
7 | import subprocess
8 | import numpy as np
9 | from scipy.io.wavfile import read
10 | import torch
11 |
12 | MATPLOTLIB_FLAG = False
13 |
14 | logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
15 | logger = logging
16 |
17 | def load_checkpoint(checkpoint_path, model, optimizer=None):
18 | assert os.path.isfile(checkpoint_path)
19 | checkpoint_dict = torch.load(checkpoint_path, map_location='cpu')
20 | iteration = 1
21 | if 'iteration' in checkpoint_dict.keys():
22 | iteration = checkpoint_dict['iteration']
23 | if 'learning_rate' in checkpoint_dict.keys():
24 | learning_rate = checkpoint_dict['learning_rate']
25 | if optimizer is not None and 'optimizer' in checkpoint_dict.keys():
26 | optimizer.load_state_dict(checkpoint_dict['optimizer'])
27 | saved_state_dict = checkpoint_dict['model']
28 | if hasattr(model, 'module'):
29 | state_dict = model.module.state_dict()
30 | else:
31 | state_dict = model.state_dict()
32 | new_state_dict= {}
33 | for k, v in state_dict.items():
34 | try:
35 | new_state_dict[k] = saved_state_dict[k]
36 | except:
37 | logger.info("%s is not in the checkpoint" % k)
38 | new_state_dict[k] = v
39 | if hasattr(model, 'module'):
40 | model.module.load_state_dict(new_state_dict)
41 | else:
42 | model.load_state_dict(new_state_dict)
43 | logger.info("Loaded checkpoint '{}' (iteration {})" .format(
44 | checkpoint_path, iteration))
45 | return model, optimizer, learning_rate, iteration
46 |
47 |
48 | def save_checkpoint(model, optimizer, learning_rate, iteration, checkpoint_path):
49 | logger.info("Saving model and optimizer state at iteration {} to {}".format(
50 | iteration, checkpoint_path))
51 | if hasattr(model, 'module'):
52 | state_dict = model.module.state_dict()
53 | else:
54 | state_dict = model.state_dict()
55 | torch.save({'model': state_dict,
56 | 'iteration': iteration,
57 | 'optimizer': optimizer.state_dict(),
58 | 'learning_rate': learning_rate}, checkpoint_path)
59 |
60 |
61 | def summarize(writer, global_step, scalars={}, histograms={}, images={}):
62 | for k, v in scalars.items():
63 | writer.add_scalar(k, v, global_step)
64 | for k, v in histograms.items():
65 | writer.add_histogram(k, v, global_step)
66 | for k, v in images.items():
67 | writer.add_image(k, v, global_step, dataformats='HWC')
68 |
69 |
70 | def latest_checkpoint_path(dir_path, regex="G_*.pth"):
71 | f_list = glob.glob(os.path.join(dir_path, regex))
72 | f_list.sort(key=lambda f: int("".join(filter(str.isdigit, f))))
73 | x = f_list[-1]
74 | print(x)
75 | return x
76 |
77 |
78 | def plot_spectrogram_to_numpy(spectrogram):
79 | global MATPLOTLIB_FLAG
80 | if not MATPLOTLIB_FLAG:
81 | import matplotlib
82 | matplotlib.use("Agg")
83 | MATPLOTLIB_FLAG = True
84 | mpl_logger = logging.getLogger('matplotlib')
85 | mpl_logger.setLevel(logging.WARNING)
86 | import matplotlib.pylab as plt
87 | import numpy as np
88 |
89 | fig, ax = plt.subplots()
90 | im = ax.imshow(spectrogram, aspect="auto", origin="lower",
91 | interpolation='none')
92 | plt.colorbar(im, ax=ax)
93 | plt.xlabel("Frames")
94 | plt.ylabel("Channels")
95 | plt.tight_layout()
96 |
97 | fig.canvas.draw()
98 | data = np.fromstring(fig.canvas.tostring_rgb(), dtype=np.uint8, sep='')
99 | data = data.reshape(fig.canvas.get_width_height()[::-1] + (3,))
100 | plt.close()
101 | return data
102 |
103 |
104 | def plot_alignment_to_numpy(alignment, info=None):
105 | global MATPLOTLIB_FLAG
106 | if not MATPLOTLIB_FLAG:
107 | import matplotlib
108 | matplotlib.use("Agg")
109 | MATPLOTLIB_FLAG = True
110 | mpl_logger = logging.getLogger('matplotlib')
111 | mpl_logger.setLevel(logging.WARNING)
112 | import matplotlib.pylab as plt
113 | import numpy as np
114 |
115 | fig, ax = plt.subplots(figsize=(6, 4))
116 | im = ax.imshow(alignment, aspect='auto', origin='lower',
117 | interpolation='none')
118 | fig.colorbar(im, ax=ax)
119 | xlabel = 'Decoder timestep'
120 | if info is not None:
121 | xlabel += '\n\n' + info
122 | plt.xlabel(xlabel)
123 | plt.ylabel('Encoder timestep')
124 | plt.tight_layout()
125 |
126 | fig.canvas.draw()
127 | data = np.fromstring(fig.canvas.tostring_rgb(), dtype=np.uint8, sep='')
128 | data = data.reshape(fig.canvas.get_width_height()[::-1] + (3,))
129 | plt.close()
130 | return data
131 |
132 |
133 | def load_wav_to_torch(full_path):
134 | sampling_rate, data = read(full_path)
135 | return torch.FloatTensor(data.astype(np.float32)), sampling_rate
136 |
137 |
138 | def load_filepaths_and_text(filename, split="|"):
139 | with open(filename, encoding='utf-8') as f:
140 | filepaths_and_text = [line.strip().split(split) for line in f]
141 | return filepaths_and_text
142 |
143 |
144 | def get_hparams(init=True):
145 | parser = argparse.ArgumentParser()
146 | parser.add_argument('-c', '--config', type=str, default="./configs/base.json",
147 | help='JSON file for configuration')
148 | parser.add_argument('-m', '--model', type=str, required=True,
149 | help='Model name')
150 |
151 | args = parser.parse_args()
152 | model_dir = os.path.join("./logs", args.model)
153 |
154 | if not os.path.exists(model_dir):
155 | os.makedirs(model_dir)
156 |
157 | config_path = args.config
158 | config_save_path = os.path.join(model_dir, "config.json")
159 | if init:
160 | with open(config_path, "r") as f:
161 | data = f.read()
162 | with open(config_save_path, "w") as f:
163 | f.write(data)
164 | else:
165 | with open(config_save_path, "r") as f:
166 | data = f.read()
167 | config = json.loads(data)
168 |
169 | hparams = HParams(**config)
170 | hparams.model_dir = model_dir
171 | return hparams
172 |
173 |
174 | def get_hparams_from_dir(model_dir):
175 | config_save_path = os.path.join(model_dir, "config.json")
176 | with open(config_save_path, "r") as f:
177 | data = f.read()
178 | config = json.loads(data)
179 |
180 | hparams =HParams(**config)
181 | hparams.model_dir = model_dir
182 | return hparams
183 |
184 |
185 | def get_hparams_from_file(config_path):
186 | with open(config_path, "r") as f:
187 | data = f.read()
188 | config = json.loads(data)
189 |
190 | hparams =HParams(**config)
191 | return hparams
192 |
193 |
194 | def check_git_hash(model_dir):
195 | source_dir = os.path.dirname(os.path.realpath(__file__))
196 | if not os.path.exists(os.path.join(source_dir, ".git")):
197 | logger.warn("{} is not a git repository, therefore hash value comparison will be ignored.".format(
198 | source_dir
199 | ))
200 | return
201 |
202 | cur_hash = subprocess.getoutput("git rev-parse HEAD")
203 |
204 | path = os.path.join(model_dir, "githash")
205 | if os.path.exists(path):
206 | saved_hash = open(path).read()
207 | if saved_hash != cur_hash:
208 | logger.warn("git hash values are different. {}(saved) != {}(current)".format(
209 | saved_hash[:8], cur_hash[:8]))
210 | else:
211 | open(path, "w").write(cur_hash)
212 |
213 |
214 | def get_logger(model_dir, filename="train.log"):
215 | global logger
216 | logger = logging.getLogger(os.path.basename(model_dir))
217 | logger.setLevel(logging.DEBUG)
218 |
219 | formatter = logging.Formatter("%(asctime)s\t%(name)s\t%(levelname)s\t%(message)s")
220 | if not os.path.exists(model_dir):
221 | os.makedirs(model_dir)
222 | h = logging.FileHandler(os.path.join(model_dir, filename))
223 | h.setLevel(logging.DEBUG)
224 | h.setFormatter(formatter)
225 | logger.addHandler(h)
226 | return logger
227 |
228 |
229 | class HParams():
230 | def __init__(self, **kwargs):
231 | for k, v in kwargs.items():
232 | if type(v) == dict:
233 | v = HParams(**v)
234 | self[k] = v
235 |
236 | def keys(self):
237 | return self.__dict__.keys()
238 |
239 | def items(self):
240 | return self.__dict__.items()
241 |
242 | def values(self):
243 | return self.__dict__.values()
244 |
245 | def __len__(self):
246 | return len(self.__dict__)
247 |
248 | def __getitem__(self, key):
249 | return getattr(self, key)
250 |
251 | def __setitem__(self, key, value):
252 | return setattr(self, key, value)
253 |
254 | def __contains__(self, key):
255 | return key in self.__dict__
256 |
257 | def __repr__(self):
258 | return self.__dict__.__repr__()
259 |
--------------------------------------------------------------------------------