repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
TTS | TTS-master/TTS/speaker_encoder/utils/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/speaker_encoder/utils/io.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/speaker_encoder/utils/visual.py | import umap
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
matplotlib.use("Agg")
colormap = (
np.array(
[
[76, 255, 0],
[0, 127, 70],
[255, 0, 0],
[255, 217, 38],
[0, 135, 255],
[165, 0, 165],
[255, ... | 1,172 | 23.957447 | 76 | py |
TTS | TTS-master/TTS/bin/convert_tacotron2_tflite.py | # Convert Tensorflow Tacotron2 model to TF-Lite binary
import argparse
from TTS.utils.io import load_config
from TTS.tts.utils.text.symbols import symbols, phonemes
from TTS.tts.tf.utils.generic_utils import setup_model
from TTS.tts.tf.utils.io import load_checkpoint
from TTS.tts.tf.utils.tflite import convert_tacotr... | 1,243 | 31.736842 | 79 | py |
TTS | TTS-master/TTS/bin/train_tacotron.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import glob
import os
import sys
import time
import traceback
from random import randrange
import numpy as np
import torch
from torch.utils.data import DataLoader
from TTS.tts.datasets.preprocess import load_meta_data
from TTS.tts.datasets.TTSDataset impo... | 31,270 | 41.719945 | 200 | py |
TTS | TTS-master/TTS/bin/compute_attention_masks.py | import argparse
import importlib
import os
import numpy as np
import torch
from torch.utils.data import DataLoader
from tqdm import tqdm
from argparse import RawTextHelpFormatter
from TTS.tts.datasets.TTSDataset import MyDataset
from TTS.tts.utils.generic_utils import setup_model
from TTS.tts.utils.io import load_chec... | 6,431 | 37.51497 | 116 | py |
TTS | TTS-master/TTS/bin/train_vocoder_gan.py | import argparse
import glob
import os
import sys
import time
import traceback
from inspect import signature
import torch
from torch.utils.data import DataLoader
from TTS.utils.audio import AudioProcessor
from TTS.utils.console_logger import ConsoleLogger
from TTS.utils.generic_utils import (KeepAverage, count_paramete... | 24,482 | 35.816541 | 129 | py |
TTS | TTS-master/TTS/bin/train_speedy_speech.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import glob
import os
import sys
import time
import traceback
import numpy as np
from random import randrange
import torch
# DISTRIBUTED
from torch.nn.parallel import DistributedDataParallel as DDP_th
from torch.utils.data import DataLoader
from torch.uti... | 24,811 | 39.084006 | 132 | py |
TTS | TTS-master/TTS/bin/tune_wavegrad.py | """Search a good noise schedule for WaveGrad for a given number of inferece iterations"""
import argparse
from itertools import product as cartesian_product
import numpy as np
import torch
from torch.utils.data import DataLoader
from tqdm import tqdm
from TTS.utils.audio import AudioProcessor
from TTS.utils.io import ... | 3,538 | 37.467391 | 140 | py |
TTS | TTS-master/TTS/bin/convert_tacotron2_torch_to_tf.py | # %%
# %%
import argparse
from difflib import SequenceMatcher
import os
import sys
# %%
# print variable match
from pprint import pprint
import numpy as np
import tensorflow as tf
import torch
from TTS.tts.tf.models.tacotron2 import Tacotron2
from TTS.tts.tf.utils.convert_torch_to_tf_utils import (
compare_torch_t... | 8,452 | 38.5 | 112 | py |
TTS | TTS-master/TTS/bin/convert_melgan_torch_to_tf.py | import argparse
from difflib import SequenceMatcher
import os
import numpy as np
import tensorflow as tf
import torch
from TTS.utils.io import load_config
from TTS.vocoder.tf.utils.convert_torch_to_tf_utils import (
compare_torch_tf, convert_tf_name, transfer_weights_torch_to_tf)
from TTS.vocoder.tf.utils.generic... | 3,833 | 31.769231 | 77 | py |
TTS | TTS-master/TTS/bin/train_encoder.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import os
import sys
import time
import traceback
import torch
from torch.utils.data import DataLoader
from TTS.speaker_encoder.dataset import MyDataset
from TTS.speaker_encoder.losses import AngleProtoLoss, GE2ELoss
from TTS.speaker_encoder.model import ... | 9,856 | 34.843636 | 132 | py |
TTS | TTS-master/TTS/bin/train_glow_tts.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import glob
import os
import sys
import time
import traceback
from random import randrange
import torch
# DISTRIBUTED
from torch.nn.parallel import DistributedDataParallel as DDP_th
from torch.utils.data import DataLoader
from torch.utils.data.distributed... | 25,835 | 38.264438 | 129 | py |
TTS | TTS-master/TTS/bin/distribute.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import pathlib
import time
import subprocess
import argparse
import torch
def main():
"""
Call train.py as a new process and pass command arguments
"""
parser = argparse.ArgumentParser()
parser.add_argument(
'--script',
... | 2,021 | 27.885714 | 129 | py |
TTS | TTS-master/TTS/bin/synthesize.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import os
import sys
import string
from argparse import RawTextHelpFormatter
# pylint: disable=redefined-outer-name, unused-argument
from pathlib import Path
from TTS.utils.manage import ModelManager
from TTS.utils.synthesizer import Synthesizer
def str... | 7,107 | 31.605505 | 275 | py |
TTS | TTS-master/TTS/bin/convert_melgan_tflite.py | # Convert Tensorflow Tacotron2 model to TF-Lite binary
import argparse
from TTS.utils.io import load_config
from TTS.vocoder.tf.utils.generic_utils import setup_generator
from TTS.vocoder.tf.utils.io import load_checkpoint
from TTS.vocoder.tf.utils.tflite import convert_melgan_to_tflite
parser = argparse.ArgumentPa... | 1,028 | 30.181818 | 77 | py |
TTS | TTS-master/TTS/bin/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/bin/train_vocoder_wavegrad.py | import argparse
import glob
import os
import sys
import time
import traceback
import numpy as np
import torch
# DISTRIBUTED
from torch.nn.parallel import DistributedDataParallel as DDP_th
from torch.optim import Adam
from torch.utils.data import DataLoader
from torch.utils.data.distributed import DistributedSampler
fr... | 18,329 | 34.800781 | 124 | py |
TTS | TTS-master/TTS/bin/train_vocoder_wavernn.py | import argparse
import os
import sys
import traceback
import time
import glob
import random
import torch
from torch.utils.data import DataLoader
# from torch.utils.data.distributed import DistributedSampler
from TTS.tts.utils.visual import plot_spectrogram
from TTS.utils.audio import AudioProcessor
from TTS.utils.ra... | 19,468 | 35.053704 | 129 | py |
TTS | TTS-master/TTS/bin/compute_statistics.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import glob
import argparse
import numpy as np
from tqdm import tqdm
from TTS.tts.datasets.preprocess import load_meta_data
from TTS.utils.io import load_config
from TTS.utils.audio import AudioProcessor
def main():
"""Run preprocessing process."""
p... | 2,994 | 31.912088 | 96 | py |
TTS | TTS-master/TTS/bin/compute_embeddings.py | import argparse
import glob
import os
import numpy as np
from tqdm import tqdm
import torch
from TTS.speaker_encoder.model import SpeakerEncoder
from TTS.utils.audio import AudioProcessor
from TTS.utils.io import load_config
from TTS.tts.utils.speakers import save_speaker_mapping
from TTS.tts.datasets.preprocess impo... | 4,439 | 32.89313 | 183 | py |
TTS | TTS-master/TTS/tts/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/tts/models/tacotron_abstract.py | import copy
from abc import ABC, abstractmethod
import torch
from torch import nn
from TTS.tts.utils.generic_utils import sequence_mask
class TacotronAbstract(ABC, nn.Module):
def __init__(self,
num_chars,
num_speakers,
r,
postnet_output_dim=80... | 9,066 | 39.119469 | 121 | py |
TTS | TTS-master/TTS/tts/models/speedy_speech.py | import torch
from torch import nn
from TTS.tts.layers.speedy_speech.decoder import Decoder
from TTS.tts.layers.speedy_speech.duration_predictor import DurationPredictor
from TTS.tts.layers.speedy_speech.encoder import Encoder, PositionalEncoding
from TTS.tts.utils.generic_utils import sequence_mask
from TTS.tts.layers.... | 8,367 | 40.84 | 207 | py |
TTS | TTS-master/TTS/tts/models/tacotron.py | # coding: utf-8
import torch
from torch import nn
from TTS.tts.layers.gst_layers import GST
from TTS.tts.layers.tacotron import Decoder, Encoder, PostCBHG
from TTS.tts.models.tacotron_abstract import TacotronAbstract
class Tacotron(TacotronAbstract):
"""Tacotron as in https://arxiv.org/abs/1703.10135
It's a... | 11,909 | 54.654206 | 152 | py |
TTS | TTS-master/TTS/tts/models/tacotron2.py | import torch
from torch import nn
from TTS.tts.layers.gst_layers import GST
from TTS.tts.layers.tacotron2 import Decoder, Encoder, Postnet
from TTS.tts.models.tacotron_abstract import TacotronAbstract
# TODO: match function arguments with tacotron
class Tacotron2(TacotronAbstract):
"""Tacotron2 as in https://arxi... | 13,010 | 54.131356 | 152 | py |
TTS | TTS-master/TTS/tts/models/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/tts/models/glow_tts.py | import math
import torch
from torch import nn
from torch.nn import functional as F
from TTS.tts.layers.glow_tts.encoder import Encoder
from TTS.tts.layers.glow_tts.decoder import Decoder
from TTS.tts.utils.generic_utils import sequence_mask
from TTS.tts.layers.glow_tts.monotonic_align import maximum_path, generate_pat... | 11,148 | 46.645299 | 138 | py |
TTS | TTS-master/TTS/tts/datasets/TTSDataset.py | import collections
import os
import random
from multiprocessing import Manager, Pool
import numpy as np
import torch
import tqdm
from torch.utils.data import Dataset
from TTS.tts.utils.data import (prepare_data, prepare_stop_target,
prepare_tensor)
from TTS.tts.utils.text import (pad_wi... | 14,558 | 40.597143 | 187 | py |
TTS | TTS-master/TTS/tts/datasets/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/tts/datasets/preprocess.py | import os
from glob import glob
import re
import sys
from pathlib import Path
from tqdm import tqdm
from TTS.tts.utils.generic_utils import split_dataset
####################
# UTILITIES
####################
def load_meta_data(datasets, eval_split=True):
meta_data_train_all = []
meta_data_eval_all = [] if e... | 12,950 | 36.979472 | 122 | py |
TTS | TTS-master/TTS/tts/layers/common_layers.py | import torch
from torch import nn
from torch.nn import functional as F
class Linear(nn.Module):
"""Linear layer with a specific initialization.
Args:
in_features (int): number of channels in the input tensor.
out_features (int): number of channels in the output tensor.
bias (bool, opt... | 4,799 | 36.795276 | 162 | py |
TTS | TTS-master/TTS/tts/layers/losses.py | import math
import numpy as np
import torch
from torch import nn
from inspect import signature
from torch.nn import functional
from TTS.tts.utils.generic_utils import sequence_mask
from TTS.tts.utils.ssim import ssim
# pylint: disable=abstract-method Method
# relates https://github.com/pytorch/pytorch/issues/42305
cl... | 18,140 | 39.493304 | 114 | py |
TTS | TTS-master/TTS/tts/layers/tacotron.py | # coding: utf-8
import torch
from torch import nn
from .common_layers import Prenet
from .attentions import init_attn
class BatchNormConv1d(nn.Module):
r"""A wrapper for Conv1d with BatchNorm. It sets the activation
function between Conv and BatchNorm layers. BatchNorm layer
is initialized with the TF def... | 19,771 | 37.317829 | 118 | py |
TTS | TTS-master/TTS/tts/layers/gst_layers.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class GST(nn.Module):
"""Global Style Token Module for factorizing prosody in speech.
See https://arxiv.org/pdf/1803.09017"""
def __init__(self, num_mel, num_heads, num_style_tokens, gst_embedding_dim, speaker_embedding_dim=None):
... | 6,268 | 34.619318 | 108 | py |
TTS | TTS-master/TTS/tts/layers/tacotron2.py | import torch
from torch import nn
from torch.nn import functional as F
from .common_layers import Prenet, Linear
from .attentions import init_attn
# NOTE: linter has a problem with the current TF release
#pylint: disable=no-value-for-parameter
#pylint: disable=unexpected-keyword-arg
class ConvBNBlock(nn.Module):
r... | 16,992 | 38.983529 | 100 | py |
TTS | TTS-master/TTS/tts/layers/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/tts/layers/attentions.py | import torch
from torch import nn
from torch.nn import functional as F
from TTS.tts.layers.common_layers import Linear
from scipy.stats import betabinom
class LocationLayer(nn.Module):
"""Layers for Location Sensitive Attention
Args:
attention_dim (int): number of channels in the input tensor.
... | 20,308 | 41.047619 | 169 | py |
TTS | TTS-master/TTS/tts/layers/speedy_speech/encoder.py | import math
import torch
from torch import nn
from TTS.tts.layers.glow_tts.transformer import RelativePositionTransformer
from TTS.tts.layers.generic.res_conv_bn import ResidualConv1dBNBlock
class PositionalEncoding(nn.Module):
"""Sinusoidal positional encoding for non-recurrent neural networks.
Implementa... | 7,871 | 36.485714 | 120 | py |
TTS | TTS-master/TTS/tts/layers/speedy_speech/duration_predictor.py | from torch import nn
from TTS.tts.layers.generic.res_conv_bn import Conv1dBN
class DurationPredictor(nn.Module):
"""Speedy Speech duration predictor model.
Predicts phoneme durations from encoder outputs.
Note:
Outputs interpreted as log(durations)
To get actual durations, do exp transfo... | 1,056 | 25.425 | 70 | py |
TTS | TTS-master/TTS/tts/layers/speedy_speech/decoder.py | import torch
from torch import nn
from TTS.tts.layers.generic.res_conv_bn import Conv1dBNBlock, ResidualConv1dBNBlock, Conv1dBN
from TTS.tts.layers.generic.wavenet import WNBlocks
from TTS.tts.layers.glow_tts.transformer import RelativePositionTransformer
class WaveNetDecoder(nn.Module):
"""WaveNet based decoder ... | 7,226 | 36.640625 | 120 | py |
TTS | TTS-master/TTS/tts/layers/speedy_speech/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/tts/layers/generic/gated_conv.py | from torch import nn
from .normalization import LayerNorm
class GatedConvBlock(nn.Module):
"""Gated convolutional block as in https://arxiv.org/pdf/1612.08083.pdf
Args:
in_out_channels (int): number of input/output channels.
kernel_size (int): convolution kernel size.
dropout_p (float... | 1,487 | 33.604651 | 76 | py |
TTS | TTS-master/TTS/tts/layers/generic/res_conv_bn.py | from torch import nn
class ZeroTemporalPad(nn.Module):
"""Pad sequences to equal lentgh in the temporal dimension"""
def __init__(self, kernel_size, dilation):
super().__init__()
total_pad = (dilation * (kernel_size - 1))
begin = total_pad // 2
end = total_pad - begin
s... | 4,646 | 38.05042 | 129 | py |
TTS | TTS-master/TTS/tts/layers/generic/wavenet.py | import torch
from torch import nn
@torch.jit.script
def fused_add_tanh_sigmoid_multiply(input_a, input_b, n_channels):
n_channels_int = n_channels[0]
in_act = input_a + input_b
t_act = torch.tanh(in_act[:, :n_channels_int, :])
s_act = torch.sigmoid(in_act[:, n_channels_int:, :])
acts = t_act * s_a... | 7,028 | 40.347059 | 95 | py |
TTS | TTS-master/TTS/tts/layers/generic/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/tts/layers/generic/normalization.py | import torch
from torch import nn
class LayerNorm(nn.Module):
def __init__(self, channels, eps=1e-4):
"""Layer norm for the 2nd dimension of the input.
Args:
channels (int): number of channels (2nd dimension) of the input.
eps (float): to prevent 0 division
Shapes:... | 3,553 | 32.214953 | 98 | py |
TTS | TTS-master/TTS/tts/layers/generic/time_depth_sep_conv.py | import torch
from torch import nn
class TimeDepthSeparableConv(nn.Module):
"""Time depth separable convolution as in https://arxiv.org/pdf/1904.02619.pdf
It shows competative results with less computation and memory footprint."""
def __init__(self,
in_channels,
hid_channe... | 2,716 | 28.215054 | 82 | py |
TTS | TTS-master/TTS/tts/layers/glow_tts/encoder.py | import math
import torch
from torch import nn
from TTS.tts.layers.glow_tts.transformer import RelativePositionTransformer
from TTS.tts.layers.generic.gated_conv import GatedConvBlock
from TTS.tts.utils.generic_utils import sequence_mask
from TTS.tts.layers.glow_tts.glow import ResidualConv1dLayerNormBlock
from TTS.tts... | 7,749 | 40.44385 | 91 | py |
TTS | TTS-master/TTS/tts/layers/glow_tts/glow.py | import torch
from torch import nn
from torch.nn import functional as F
from TTS.tts.layers.generic.wavenet import WN
from ..generic.normalization import LayerNorm
class ResidualConv1dLayerNormBlock(nn.Module):
def __init__(self, in_channels, hidden_channels, out_channels, kernel_size,
num_layers... | 8,196 | 35.923423 | 111 | py |
TTS | TTS-master/TTS/tts/layers/glow_tts/duration_predictor.py | import torch
from torch import nn
from ..generic.normalization import LayerNorm
class DurationPredictor(nn.Module):
"""Glow-TTS duration prediction model.
[2 x (conv1d_kxk -> relu -> layer_norm -> dropout)] -> conv1d_1x1 -> durs
Args:
in_channels ([type]): [description]
hidde... | 1,849 | 30.896552 | 77 | py |
TTS | TTS-master/TTS/tts/layers/glow_tts/transformer.py | import math
import torch
from torch import nn
from torch.nn import functional as F
from TTS.tts.layers.glow_tts.glow import LayerNorm
class RelativePositionMultiHeadAttention(nn.Module):
"""Multi-head attention with Relative Positional embedding.
https://arxiv.org/pdf/1809.04281.pdf
It learns positional... | 16,544 | 40.259352 | 128 | py |
TTS | TTS-master/TTS/tts/layers/glow_tts/decoder.py | import torch
from torch import nn
from TTS.tts.layers.glow_tts.glow import InvConvNear, CouplingBlock
from TTS.tts.layers.generic.normalization import ActNorm
def squeeze(x, x_mask=None, num_sqz=2):
"""GlowTTS squeeze operation
Increase number of channels and reduce number of time steps
by the same facto... | 4,876 | 35.669173 | 88 | py |
TTS | TTS-master/TTS/tts/layers/glow_tts/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/tts/layers/glow_tts/monotonic_align/setup.py | # from distutils.core import setup
# from Cython.Build import cythonize
# import numpy
# setup(name='monotonic_align',
# ext_modules=cythonize("core.pyx"),
# include_dirs=[numpy.get_include()])
| 207 | 25 | 43 | py |
TTS | TTS-master/TTS/tts/layers/glow_tts/monotonic_align/__init__.py | import numpy as np
import torch
from torch.nn import functional as F
from TTS.tts.utils.generic_utils import sequence_mask
try:
# TODO: fix pypi cython installation problem.
from TTS.tts.layers.glow_tts.monotonic_align.core import maximum_path_c
CYTHON = True
except ModuleNotFoundError:
CYTHON = False
... | 3,237 | 30.134615 | 94 | py |
TTS | TTS-master/TTS/tts/utils/ssim.py | # taken from https://github.com/Po-Hsun-Su/pytorch-ssim
from math import exp
import torch
import torch.nn.functional as F
from torch.autograd import Variable
def gaussian(window_size, sigma):
gauss = torch.Tensor([exp(-(x - window_size//2)**2/float(2*sigma**2)) for x in range(window_size)])
return gauss/gau... | 2,619 | 33.473684 | 104 | py |
TTS | TTS-master/TTS/tts/utils/generic_utils.py | import re
import torch
import importlib
import numpy as np
from collections import Counter
from TTS.utils.generic_utils import check_argument
def split_dataset(items):
speakers = [item[-1] for item in items]
is_multi_speaker = len(set(speakers)) > 1
eval_split_size = min(500, int(len(items) * 0.01))
... | 17,513 | 58.774744 | 138 | py |
TTS | TTS-master/TTS/tts/utils/speakers.py | import os
import json
def make_speakers_json_path(out_path):
"""Returns conventional speakers.json location."""
return os.path.join(out_path, "speakers.json")
def load_speaker_mapping(out_path):
"""Loads speaker mapping if already present."""
try:
if os.path.splitext(out_path)[1] == '.json':... | 4,063 | 54.671233 | 292 | py |
TTS | TTS-master/TTS/tts/utils/synthesis.py | import pkg_resources
installed = {pkg.key for pkg in pkg_resources.working_set} #pylint: disable=not-an-iterable
if 'tensorflow' in installed or 'tensorflow-gpu' in installed:
import tensorflow as tf
import torch
import numpy as np
from .text import text_to_sequence, phoneme_to_sequence
def text_to_seqvec(text, ... | 12,251 | 42.446809 | 166 | py |
TTS | TTS-master/TTS/tts/utils/data.py | import numpy as np
def _pad_data(x, length):
_pad = 0
assert x.ndim == 1
return np.pad(
x, (0, length - x.shape[0]), mode='constant', constant_values=_pad)
def prepare_data(inputs):
max_len = max((len(x) for x in inputs))
return np.stack([_pad_data(x, max_len) for x in inputs])
def _pa... | 1,921 | 23.961039 | 77 | py |
TTS | TTS-master/TTS/tts/utils/measures.py | def alignment_diagonal_score(alignments, binary=False):
"""
Compute how diagonal alignment predictions are. It is useful
to measure the alignment consistency of a model
Args:
alignments (torch.Tensor): batch of alignments.
binary (bool): if True, ignore scores and consider attention
... | 545 | 33.125 | 68 | py |
TTS | TTS-master/TTS/tts/utils/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/tts/utils/io.py | import os
import torch
import datetime
import pickle as pickle_tts
from TTS.utils.io import RenamingUnpickler
def load_checkpoint(model, checkpoint_path, amp=None, use_cuda=False, eval=False):
"""Load ```TTS.tts.models``` checkpoints.
Args:
model (TTS.tts.models): model object to load the weights f... | 4,518 | 38.99115 | 111 | py |
TTS | TTS-master/TTS/tts/utils/visual.py | import librosa
import matplotlib
import numpy as np
import torch
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from TTS.tts.utils.text import phoneme_to_sequence, sequence_to_phoneme
def plot_alignment(alignment,
info=None,
fig_size=(16, 10),
title=Non... | 4,586 | 31.531915 | 87 | py |
TTS | TTS-master/TTS/tts/utils/text/number_norm.py | """ from https://github.com/keithito/tacotron """
import inflect
import re
from typing import Dict
_inflect = inflect.engine()
_comma_number_re = re.compile(r'([0-9][0-9\,]+[0-9])')
_decimal_number_re = re.compile(r'([0-9]+\.[0-9]+)')
_currency_re = re.compile(r'(£|\$|¥)([0-9\,\.]*[0-9]+)')
_ordinal_re = re.compile(r... | 2,921 | 28.22 | 72 | py |
TTS | TTS-master/TTS/tts/utils/text/cleaners.py | '''
Cleaners are transformations that run over the input text at both training and eval time.
Cleaners can be selected by passing a comma-delimited list of cleaner names as the "cleaners"
hyperparameter. Some cleaners are English-specific. You'll typically want to use:
1. "english_cleaners" for English text
2. "tr... | 4,055 | 29.268657 | 100 | py |
TTS | TTS-master/TTS/tts/utils/text/time.py | import re
import inflect
_inflect = inflect.engine()
_time_re = re.compile(r"""\b
((0?[0-9])|(1[0-1])|(1[2-9])|(2[0-3])) # hours
:
([0-5][0-9]) # minutes
\s*(a\\.m\\.|am|pm|p\\.m\\.|a\\.... | 1,184 | 25.333333 | 75 | py |
TTS | TTS-master/TTS/tts/utils/text/abbreviations.py | import re
# List of (regular expression, replacement) pairs for abbreviations in english:
abbreviations_en = [(re.compile('\\b%s\\.' % x[0], re.IGNORECASE), x[1])
for x in [
('mrs', 'misess'),
('mr', 'mister'),
('dr', 'doctor'),
... | 2,587 | 41.42623 | 79 | py |
TTS | TTS-master/TTS/tts/utils/text/cmudict.py | # -*- coding: utf-8 -*-
import re
VALID_SYMBOLS = [
'AA', 'AA0', 'AA1', 'AA2', 'AE', 'AE0', 'AE1', 'AE2', 'AH', 'AH0', 'AH1',
'AH2', 'AO', 'AO0', 'AO1', 'AO2', 'AW', 'AW0', 'AW1', 'AW2', 'AY', 'AY0',
'AY1', 'AY2', 'B', 'CH', 'D', 'DH', 'EH', 'EH0', 'EH1', 'EH2', 'ER', 'ER0',
'ER1', 'ER2', 'EY', 'EY0',... | 2,652 | 32.582278 | 88 | py |
TTS | TTS-master/TTS/tts/utils/text/symbols.py | # -*- coding: utf-8 -*-
'''
Defines the set of symbols used in text input to the model.
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.
'''
def make_symbols(characters, phonem... | 1,772 | 35.9375 | 133 | py |
TTS | TTS-master/TTS/tts/utils/text/__init__.py | # -*- coding: utf-8 -*-
import re
from packaging import version
import phonemizer
from phonemizer.phonemize import phonemize
from TTS.tts.utils.text import cleaners
from TTS.tts.utils.text.symbols import make_symbols, symbols, phonemes, _phoneme_punctuations, _bos, \
_eos
# pylint: disable=unnecessary-comprehensi... | 7,403 | 35.294118 | 167 | py |
TTS | TTS-master/TTS/tts/tf/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/tts/tf/models/tacotron2.py | import tensorflow as tf
from tensorflow import keras
from TTS.tts.tf.layers.tacotron2 import Encoder, Decoder, Postnet
from TTS.tts.tf.utils.tf_utils import shape_list
#pylint: disable=too-many-ancestors, abstract-method
class Tacotron2(keras.models.Model):
def __init__(self,
num_chars,
... | 5,151 | 46.703704 | 131 | py |
TTS | TTS-master/TTS/tts/tf/layers/common_layers.py | import tensorflow as tf
from tensorflow import keras
from tensorflow.python.ops import math_ops
# from tensorflow_addons.seq2seq import BahdanauAttention
# NOTE: linter has a problem with the current TF release
#pylint: disable=no-value-for-parameter
#pylint: disable=unexpected-keyword-arg
class Linear(keras.layers.L... | 12,264 | 41.439446 | 162 | py |
TTS | TTS-master/TTS/tts/tf/layers/tacotron2.py | import tensorflow as tf
from tensorflow import keras
from TTS.tts.tf.utils.tf_utils import shape_list
from TTS.tts.tf.layers.common_layers import Prenet, Attention
# NOTE: linter has a problem with the current TF release
#pylint: disable=no-value-for-parameter
#pylint: disable=unexpected-keyword-arg
class ConvBNBlock... | 15,199 | 49.165017 | 139 | py |
TTS | TTS-master/TTS/tts/tf/utils/tf_utils.py | import tensorflow as tf
def shape_list(x):
"""Deal with dynamic shape in tensorflow cleanly."""
static = x.shape.as_list()
dynamic = tf.shape(x)
return [dynamic[i] if s is None else s for i, s in enumerate(static)]
| 233 | 25 | 73 | py |
TTS | TTS-master/TTS/tts/tf/utils/generic_utils.py | import datetime
import importlib
import pickle
import numpy as np
import tensorflow as tf
def save_checkpoint(model, optimizer, current_step, epoch, r, output_path, **kwargs):
state = {
'model': model.weights,
'optimizer': optimizer,
'step': current_step,
'epoch': epoch,
'd... | 3,878 | 36.298077 | 85 | py |
TTS | TTS-master/TTS/tts/tf/utils/convert_torch_to_tf_utils.py | import numpy as np
import tensorflow as tf
# NOTE: linter has a problem with the current TF release
#pylint: disable=no-value-for-parameter
#pylint: disable=unexpected-keyword-arg
def tf_create_dummy_inputs():
""" Create dummy inputs for TF Tacotron2 model """
batch_size = 4
max_input_length = 32
max_... | 4,281 | 49.376471 | 173 | py |
TTS | TTS-master/TTS/tts/tf/utils/tflite.py | import tensorflow as tf
def convert_tacotron2_to_tflite(model,
output_path=None,
experimental_converter=True):
"""Convert Tensorflow Tacotron2 model to TFLite. Save a binary file if output_path is
provided, else return TFLite model."""
concr... | 1,205 | 36.6875 | 89 | py |
TTS | TTS-master/TTS/tts/tf/utils/io.py | import pickle
import datetime
import tensorflow as tf
def save_checkpoint(model, optimizer, current_step, epoch, r, output_path, **kwargs):
state = {
'model': model.weights,
'optimizer': optimizer,
'step': current_step,
'epoch': epoch,
'date': datetime.date.today().strftime... | 1,284 | 29.595238 | 85 | py |
TTS | TTS-master/TTS/utils/generic_utils.py | import datetime
import glob
import os
import shutil
import subprocess
import sys
from pathlib import Path
import torch
def get_git_branch():
try:
out = subprocess.check_output(["git", "branch"]).decode("utf8")
current = next(line for line in out.split("\n")
if line.startswi... | 6,393 | 34.921348 | 130 | py |
TTS | TTS-master/TTS/utils/synthesizer.py | import time
import numpy as np
import torch
import pysbd
from TTS.utils.audio import AudioProcessor
from TTS.utils.io import load_config
from TTS.tts.utils.generic_utils import setup_model
from TTS.tts.utils.speakers import load_speaker_mapping
from TTS.vocoder.utils.generic_utils import setup_generator, interpolate_... | 6,964 | 39.970588 | 139 | py |
TTS | TTS-master/TTS/utils/radam.py | # from https://github.com/LiyuanLucasLiu/RAdam
import math
import torch
from torch.optim.optimizer import Optimizer
class RAdam(Optimizer):
def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8, weight_decay=0, degenerated_to_sgd=True):
if lr < 0.0:
raise ValueError("Invalid learn... | 4,346 | 43.357143 | 175 | py |
TTS | TTS-master/TTS/utils/tensorboard_logger.py | import traceback
from tensorboardX import SummaryWriter
class TensorboardLogger(object):
def __init__(self, log_dir, model_name):
self.model_name = model_name
self.writer = SummaryWriter(log_dir)
self.train_stats = {}
self.eval_stats = {}
def tb_model_weights(self, model, step... | 3,417 | 40.682927 | 108 | py |
TTS | TTS-master/TTS/utils/training.py | import torch
import numpy as np
def setup_torch_training_env(cudnn_enable, cudnn_benchmark):
torch.backends.cudnn.enabled = cudnn_enable
torch.backends.cudnn.benchmark = cudnn_benchmark
torch.manual_seed(54321)
use_cuda = torch.cuda.is_available()
num_gpus = torch.cuda.device_count()
print(" >... | 3,943 | 32.709402 | 112 | py |
TTS | TTS-master/TTS/utils/audio.py | import librosa
import soundfile as sf
import numpy as np
import scipy.io.wavfile
import scipy.signal
# import pyworld as pw
from TTS.tts.utils.data import StandardScaler
#pylint: disable=too-many-public-methods
class AudioProcessor(object):
def __init__(self,
sample_rate=None,
re... | 14,654 | 37.976064 | 149 | py |
TTS | TTS-master/TTS/utils/distribute.py | # edited from https://github.com/fastai/imagenet-fast/blob/master/imagenet_nv/distributed.py
import math
import torch
import torch.distributed as dist
from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors
from torch.autograd import Variable
from torch.utils.data.sampler import Sampler
class Distr... | 3,871 | 32.094017 | 106 | py |
TTS | TTS-master/TTS/utils/console_logger.py | import datetime
from TTS.utils.io import AttrDict
tcolors = AttrDict({
'OKBLUE': '\033[94m',
'HEADER': '\033[95m',
'OKGREEN': '\033[92m',
'WARNING': '\033[93m',
'FAIL': '\033[91m',
'ENDC': '\033[0m',
'BOLD': '\033[1m',
'UNDERLINE': '\033[4m'
})
class ConsoleLogger():
def __init__... | 4,080 | 38.621359 | 143 | py |
TTS | TTS-master/TTS/utils/manage.py | import json
import gdown
from pathlib import Path
import os
from TTS.utils.io import load_config
from TTS.utils.generic_utils import get_user_data_dir
class ModelManager(object):
"""Manage TTS models defined in .models.json.
It provides an interface to list and download
models defines in '.model.json'
... | 3,982 | 37.298077 | 90 | py |
TTS | TTS-master/TTS/utils/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/utils/io.py | import os
import re
import json
import yaml
import pickle as pickle_tts
from shutil import copyfile
class RenamingUnpickler(pickle_tts.Unpickler):
"""Overload default pickler to solve module renaming problem"""
def find_class(self, module, name):
return super().find_class(module.replace('mozilla_voice... | 2,469 | 30.265823 | 83 | py |
TTS | TTS-master/TTS/vocoder/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/vocoder/models/parallel_wavegan_generator.py | import math
import numpy as np
import torch
from TTS.vocoder.layers.parallel_wavegan import ResidualBlock
from TTS.vocoder.layers.upsample import ConvUpsample
class ParallelWaveganGenerator(torch.nn.Module):
"""PWGAN generator as in https://arxiv.org/pdf/1910.11480.pdf.
It is similar to WaveNet with no causa... | 5,992 | 34.461538 | 121 | py |
TTS | TTS-master/TTS/vocoder/models/parallel_wavegan_discriminator.py | import math
import torch
from torch import nn
from TTS.vocoder.layers.parallel_wavegan import ResidualBlock
class ParallelWaveganDiscriminator(nn.Module):
"""PWGAN discriminator as in https://arxiv.org/abs/1910.11480.
It classifies each audio window real/fake and returns a sequence
of predictions.
... | 6,868 | 33.691919 | 91 | py |
TTS | TTS-master/TTS/vocoder/models/wavernn.py | import sys
import torch
import torch.nn as nn
import numpy as np
import torch.nn.functional as F
import time
# fix this
from TTS.utils.audio import AudioProcessor as ap
from TTS.vocoder.utils.distribution import (
sample_from_gaussian,
sample_from_discretized_mix_logistic,
)
def stream(string, variables):
... | 17,680 | 33.736739 | 121 | py |
TTS | TTS-master/TTS/vocoder/models/melgan_discriminator.py | import numpy as np
from torch import nn
from torch.nn.utils import weight_norm
class MelganDiscriminator(nn.Module):
def __init__(self,
in_channels=1,
out_channels=1,
kernel_sizes=(5, 3),
base_channels=16,
max_channels=1024,
... | 2,866 | 35.291139 | 75 | py |
TTS | TTS-master/TTS/vocoder/models/random_window_discriminator.py | import numpy as np
from torch import nn
class GBlock(nn.Module):
def __init__(self, in_channels, cond_channels, downsample_factor):
super(GBlock, self).__init__()
self.in_channels = in_channels
self.cond_channels = cond_channels
self.downsample_factor = downsample_factor
... | 8,554 | 36.853982 | 79 | py |
TTS | TTS-master/TTS/vocoder/models/melgan_multiscale_discriminator.py | from torch import nn
from TTS.vocoder.models.melgan_discriminator import MelganDiscriminator
class MelganMultiscaleDiscriminator(nn.Module):
def __init__(self,
in_channels=1,
out_channels=1,
num_scales=3,
kernel_sizes=(5, 3),
ba... | 1,474 | 34.119048 | 141 | py |
TTS | TTS-master/TTS/vocoder/models/multiband_melgan_generator.py | import torch
from TTS.vocoder.models.melgan_generator import MelganGenerator
from TTS.vocoder.layers.pqmf import PQMF
class MultibandMelganGenerator(MelganGenerator):
def __init__(self,
in_channels=80,
out_channels=4,
proj_kernel=7,
base_channel... | 1,461 | 35.55 | 70 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.