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/vocoder/models/wavegrad.py | import numpy as np
import torch
from torch import nn
from torch.nn.utils import weight_norm
from ..layers.wavegrad import DBlock, FiLM, UBlock, Conv1d
class Wavegrad(nn.Module):
# pylint: disable=dangerous-default-value
def __init__(self,
in_channels=80,
out_channels=1,
... | 7,448 | 36.812183 | 121 | py |
TTS | TTS-master/TTS/vocoder/models/fullband_melgan_generator.py | import torch
from TTS.vocoder.models.melgan_generator import MelganGenerator
class FullbandMelganGenerator(MelganGenerator):
def __init__(self,
in_channels=80,
out_channels=1,
proj_kernel=7,
base_channels=512,
upsample_factors=(... | 1,108 | 34.774194 | 70 | py |
TTS | TTS-master/TTS/vocoder/models/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/vocoder/models/melgan_generator.py | import torch
from torch import nn
from torch.nn.utils import weight_norm
from TTS.vocoder.layers.melgan import ResidualStack
class MelganGenerator(nn.Module):
def __init__(self,
in_channels=80,
out_channels=1,
proj_kernel=7,
base_channels=512,
... | 3,691 | 33.830189 | 121 | py |
TTS | TTS-master/TTS/vocoder/datasets/wavegrad_dataset.py | import os
import glob
import torch
import random
import numpy as np
from torch.utils.data import Dataset
from multiprocessing import Manager
class WaveGradDataset(Dataset):
"""
WaveGrad Dataset searchs for all the wav files under root path
and converts them to acoustic features on the fly and returns
... | 4,572 | 33.643939 | 128 | py |
TTS | TTS-master/TTS/vocoder/datasets/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/vocoder/datasets/gan_dataset.py | import os
import glob
import torch
import random
import numpy as np
from torch.utils.data import Dataset
from multiprocessing import Manager
class GANDataset(Dataset):
"""
GAN Dataset searchs for all the wav files under root path
and converts them to acoustic features on the fly and returns
random seg... | 4,369 | 33.140625 | 123 | py |
TTS | TTS-master/TTS/vocoder/datasets/wavernn_dataset.py | import torch
import numpy as np
from torch.utils.data import Dataset
class WaveRNNDataset(Dataset):
"""
WaveRNN Dataset searchs for all the wav files under root path
and converts them to acoustic features on the fly.
"""
def __init__(self,
ap,
items,
... | 4,136 | 33.764706 | 89 | py |
TTS | TTS-master/TTS/vocoder/datasets/preprocess.py | import glob
import os
from pathlib import Path
from tqdm import tqdm
import numpy as np
def preprocess_wav_files(out_path, config, ap):
os.makedirs(os.path.join(out_path, "quant"), exist_ok=True)
os.makedirs(os.path.join(out_path, "mel"), exist_ok=True)
wav_files = find_wav_files(config.data_path)
fo... | 1,966 | 30.222222 | 82 | py |
TTS | TTS-master/TTS/vocoder/layers/losses.py | import torch
from torch import nn
from torch.nn import functional as F
class TorchSTFT(nn.Module):
def __init__(self, n_fft, hop_length, win_length, window='hann_window'):
""" Torch based STFT operation """
super(TorchSTFT, self).__init__()
self.n_fft = n_fft
self.hop_length = hop... | 11,390 | 35.392971 | 122 | py |
TTS | TTS-master/TTS/vocoder/layers/parallel_wavegan.py | import torch
from torch.nn import functional as F
class ResidualBlock(torch.nn.Module):
"""Residual block module in WaveNet."""
def __init__(self,
kernel_size=3,
res_channels=64,
gate_channels=128,
skip_channels=64,
aux_chann... | 3,035 | 33.5 | 71 | py |
TTS | TTS-master/TTS/vocoder/layers/pqmf.py | import numpy as np
import torch
import torch.nn.functional as F
from scipy import signal as sig
# adapted from
# https://github.com/kan-bayashi/ParallelWaveGAN/tree/master/parallel_wavegan
class PQMF(torch.nn.Module):
def __init__(self, N=4, taps=62, cutoff=0.15, beta=9.0):
super(PQMF, self).__init__()
... | 1,833 | 31.175439 | 102 | py |
TTS | TTS-master/TTS/vocoder/layers/melgan.py | from torch import nn
from torch.nn.utils import weight_norm
class ResidualStack(nn.Module):
def __init__(self, channels, num_res_blocks, kernel_size):
super(ResidualStack, self).__init__()
assert (kernel_size - 1) % 2 == 0, " [!] kernel_size has to be odd."
base_padding = (kernel_size - 1... | 1,707 | 36.130435 | 77 | py |
TTS | TTS-master/TTS/vocoder/layers/wavegrad.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.utils import weight_norm
class Conv1d(nn.Conv1d):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
nn.init.orthogonal_(self.weight)
nn.init.zeros_(self.bias)
class PositionalEncoding(nn... | 6,178 | 34.107955 | 106 | py |
TTS | TTS-master/TTS/vocoder/layers/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/vocoder/layers/upsample.py | import torch
from torch.nn import functional as F
class Stretch2d(torch.nn.Module):
def __init__(self, x_scale, y_scale, mode="nearest"):
super(Stretch2d, self).__init__()
self.x_scale = x_scale
self.y_scale = y_scale
self.mode = mode
def forward(self, x):
"""
... | 3,899 | 37.235294 | 105 | py |
TTS | TTS-master/TTS/vocoder/utils/generic_utils.py | import re
import torch
import importlib
import numpy as np
from matplotlib import pyplot as plt
from TTS.tts.utils.visual import plot_spectrogram
def interpolate_vocoder_input(scale_factor, spec):
"""Interpolate spectrogram by the scale factor.
It is mainly used to match the sampling rates of
the tts and... | 8,372 | 37.585253 | 87 | py |
TTS | TTS-master/TTS/vocoder/utils/distribution.py | import numpy as np
import math
import torch
from torch.distributions.normal import Normal
import torch.nn.functional as F
def gaussian_loss(y_hat, y, log_std_min=-7.0):
assert y_hat.dim() == 3
assert y_hat.size(2) == 2
mean = y_hat[:, :, :1]
log_std = torch.clamp(y_hat[:, :, 1:], min=log_std_min)
... | 5,684 | 32.639053 | 99 | py |
TTS | TTS-master/TTS/vocoder/utils/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/vocoder/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, use_cuda=False, eval=False):
try:
state = torch.load(checkpoint_path, map_location=torch.device('cpu'))
except ModuleNotFoundError:
pickle_... | 3,117 | 36.119048 | 103 | py |
TTS | TTS-master/TTS/vocoder/tf/models/multiband_melgan_generator.py | import tensorflow as tf
from TTS.vocoder.tf.models.melgan_generator import MelganGenerator
from TTS.vocoder.tf.layers.pqmf import PQMF
#pylint: disable=too-many-ancestors
#pylint: disable=abstract-method
class MultibandMelganGenerator(MelganGenerator):
def __init__(self,
in_channels=80,
... | 2,290 | 36.557377 | 110 | py |
TTS | TTS-master/TTS/vocoder/tf/models/melgan_generator.py | import logging
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # FATAL
logging.getLogger('tensorflow').setLevel(logging.FATAL)
import tensorflow as tf
from TTS.vocoder.tf.layers.melgan import ResidualStack, ReflectionPad1d
#pylint: disable=too-many-ancestors
#pylint: disable=abstract-method
class MelganGenerato... | 4,858 | 36.666667 | 134 | py |
TTS | TTS-master/TTS/vocoder/tf/layers/pqmf.py | import numpy as np
import tensorflow as tf
from scipy import signal as sig
class PQMF(tf.keras.layers.Layer):
def __init__(self, N=4, taps=62, cutoff=0.15, beta=9.0):
super(PQMF, self).__init__()
# define filter coefficient
self.N = N
self.taps = taps
self.cutoff = cutoff
... | 2,396 | 34.776119 | 94 | py |
TTS | TTS-master/TTS/vocoder/tf/layers/melgan.py | import tensorflow as tf
class ReflectionPad1d(tf.keras.layers.Layer):
def __init__(self, padding):
super(ReflectionPad1d, self).__init__()
self.padding = padding
def call(self, x):
return tf.pad(x, [[0, 0], [self.padding, self.padding], [0, 0], [0, 0]], "REFLECT")
class ResidualStac... | 2,191 | 37.45614 | 91 | py |
TTS | TTS-master/TTS/vocoder/tf/utils/generic_utils.py | import re
import importlib
def to_camel(text):
text = text.capitalize()
return re.sub(r'(?!^)_([a-zA-Z])', lambda m: m.group(1).upper(), text)
def setup_generator(c):
print(" > Generator Model: {}".format(c.generator_model))
MyModel = importlib.import_module('TTS.vocoder.tf.models.' +
... | 1,274 | 34.416667 | 74 | py |
TTS | TTS-master/TTS/vocoder/tf/utils/convert_torch_to_tf_utils.py | import numpy as np
import tensorflow as tf
def compare_torch_tf(torch_tensor, tf_tensor):
""" Compute the average absolute difference b/w torch and tf tensors """
return abs(torch_tensor.detach().numpy() - tf_tensor.numpy()).mean()
def convert_tf_name(tf_name):
""" Convert certain patterns in TF layer n... | 1,997 | 42.434783 | 173 | py |
TTS | TTS-master/TTS/vocoder/tf/utils/tflite.py | import tensorflow as tf
def convert_melgan_to_tflite(model,
output_path=None,
experimental_converter=True):
"""Convert Tensorflow MelGAN model to TFLite. Save a binary file if output_path is
provided, else return TFLite model."""
concrete_function... | 1,169 | 35.5625 | 86 | py |
TTS | TTS-master/TTS/vocoder/tf/utils/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/TTS/vocoder/tf/utils/io.py | import datetime
import pickle
import tensorflow as tf
def save_checkpoint(model, current_step, epoch, output_path, **kwargs):
""" Save TF Vocoder model """
state = {
'model': model.weights,
'step': current_step,
'epoch': epoch,
'date': datetime.date.today().strftime("%B %d, %Y"... | 831 | 28.714286 | 74 | py |
TTS | TTS-master/TTS/server/server.py | #!flask/bin/python
import argparse
import os
import sys
import io
from pathlib import Path
from flask import Flask, render_template, request, send_file
from TTS.utils.synthesizer import Synthesizer
from TTS.utils.manage import ModelManager
from TTS.utils.io import load_config
def create_argparser():
def convert_... | 4,812 | 40.136752 | 159 | py |
TTS | TTS-master/TTS/server/__init__.py | 0 | 0 | 0 | py | |
TTS | TTS-master/tests/test_layers.py | import unittest
import torch as T
from TTS.tts.layers.tacotron import Prenet, CBHG, Decoder, Encoder
from TTS.tts.layers.losses import L1LossMasked, SSIMLoss
from TTS.tts.utils.generic_utils import sequence_mask
# pylint: disable=unused-variable
class PrenetTests(unittest.TestCase):
def test_in_out(self): #pyl... | 8,598 | 37.909502 | 82 | py |
TTS | TTS-master/tests/test_vocoder_melgan_generator.py | import numpy as np
import torch
from TTS.vocoder.models.melgan_generator import MelganGenerator
def test_melgan_generator():
model = MelganGenerator()
print(model)
dummy_input = torch.rand((4, 80, 64))
output = model(dummy_input)
assert np.all(output.shape == (4, 1, 64 * 256))
output = model.i... | 400 | 27.642857 | 63 | py |
TTS | TTS-master/tests/test_text_processing.py | import os
# pylint: disable=unused-wildcard-import
# pylint: disable=wildcard-import
# pylint: disable=unused-import
import unittest
from tests import get_tests_input_path
from TTS.tts.utils.text import *
from tests import get_tests_path
from TTS.utils.io import load_config
conf = load_config(os.path.join(get_tests_in... | 8,369 | 46.828571 | 355 | py |
TTS | TTS-master/tests/test_preprocessors.py | import unittest
import os
from tests import get_tests_input_path
from TTS.tts.datasets.preprocess import common_voice
class TestPreprocessors(unittest.TestCase):
def test_common_voice_preprocessor(self): #pylint: disable=no-self-use
root_path = get_tests_input_path()
meta_file = "common_voice.t... | 804 | 41.368421 | 109 | py |
TTS | TTS-master/tests/test_glow_tts.py | import copy
import os
import unittest
import torch
from tests import get_tests_input_path
from torch import optim
from TTS.tts.layers.losses import GlowTTSLoss
from TTS.tts.models.glow_tts import GlowTts
from TTS.utils.io import load_config
from TTS.utils.audio import AudioProcessor
#pylint: disable=unused-variable
... | 4,612 | 33.684211 | 95 | py |
TTS | TTS-master/tests/test_train_tts.py | 0 | 0 | 0 | py | |
TTS | TTS-master/tests/test_vocoder_rwd.py | import torch
import numpy as np
from TTS.vocoder.models.random_window_discriminator import RandomWindowDiscriminator
def test_rwd():
layer = RandomWindowDiscriminator(cond_channels=80,
window_sizes=(512, 1024, 2048, 4096,
8... | 816 | 36.136364 | 84 | py |
TTS | TTS-master/tests/test_text_cleaners.py | #!/usr/bin/env python3
from TTS.tts.utils.text.cleaners import english_cleaners, phoneme_cleaners
def test_time() -> None:
assert english_cleaners("It's 11:00") == "it's eleven a m"
assert english_cleaners("It's 9:01") == "it's nine oh one a m"
assert english_cleaners("It's 16:00") == "it's four p m"
... | 736 | 32.5 | 76 | py |
TTS | TTS-master/tests/test_demo_server.py | import os
import unittest
from tests import get_tests_input_path, get_tests_output_path
from TTS.utils.synthesizer import Synthesizer
from TTS.tts.utils.generic_utils import setup_model
from TTS.tts.utils.io import save_checkpoint
from TTS.tts.utils.text.symbols import make_symbols, phonemes, symbols
from TTS.utils.io... | 4,265 | 72.551724 | 243 | py |
TTS | TTS-master/tests/test_vocoder_tf_melgan_generator.py | import numpy as np
import tensorflow as tf
from TTS.vocoder.tf.models.melgan_generator import MelganGenerator
def test_melgan_generator():
hop_length = 256
model = MelganGenerator()
# pylint: disable=no-value-for-parameter
dummy_input = tf.random.uniform((4, 80, 64))
output = model(dummy_input, t... | 408 | 28.214286 | 72 | py |
TTS | TTS-master/tests/test_tacotron_model.py | import copy
import os
import unittest
import torch
from tests import get_tests_input_path
from torch import nn, optim
from TTS.tts.layers.losses import L1LossMasked
from TTS.tts.models.tacotron import Tacotron
from TTS.utils.io import load_config
from TTS.utils.audio import AudioProcessor
#pylint: disable=unused-var... | 15,960 | 43.336111 | 127 | py |
TTS | TTS-master/tests/test_vocoder_losses.py | import os
import torch
from tests import get_tests_input_path, get_tests_output_path, get_tests_path
from TTS.utils.audio import AudioProcessor
from TTS.utils.io import load_config
from TTS.vocoder.layers.losses import MultiScaleSTFTLoss, STFTLoss, TorchSTFT
TESTS_PATH = get_tests_path()
OUT_PATH = os.path.join(get... | 1,931 | 34.127273 | 90 | py |
TTS | TTS-master/tests/test_loader.py | import os
import shutil
import unittest
import numpy as np
import torch
from tests import get_tests_input_path, get_tests_output_path
from torch.utils.data import DataLoader
from TTS.tts.datasets import TTSDataset
from TTS.tts.datasets.preprocess import ljspeech
from TTS.utils.audio import AudioProcessor
from TTS.uti... | 8,580 | 39.476415 | 108 | py |
TTS | TTS-master/tests/test_encoder.py | import os
import unittest
import torch as T
from tests import get_tests_input_path
from TTS.speaker_encoder.losses import GE2ELoss, AngleProtoLoss
from TTS.speaker_encoder.model import SpeakerEncoder
from TTS.utils.io import load_config
file_path = get_tests_input_path()
c = load_config(os.path.join(file_path, "test... | 4,515 | 37.271186 | 114 | py |
TTS | TTS-master/tests/test_wavegrad_layers.py | import torch
from TTS.vocoder.layers.wavegrad import PositionalEncoding, FiLM, UBlock, DBlock
from TTS.vocoder.models.wavegrad import Wavegrad
def test_positional_encoding():
layer = PositionalEncoding(50)
inp = torch.rand(32, 50, 100)
nl = torch.rand(32)
o = layer(inp, nl)
assert o.shape[0] == ... | 2,362 | 24.408602 | 80 | py |
TTS | TTS-master/tests/test_vocoder_parallel_wavegan_discriminator.py | import numpy as np
import torch
from TTS.vocoder.models.parallel_wavegan_discriminator import ParallelWaveganDiscriminator, ResidualParallelWaveganDiscriminator
def test_pwgan_disciminator():
model = ParallelWaveganDiscriminator(
in_channels=1,
out_channels=1,
kernel_size=3,
num_l... | 1,237 | 28.47619 | 128 | py |
TTS | TTS-master/tests/test_tacotron2_tf_model.py | import os
import unittest
import numpy as np
import tensorflow as tf
import torch
from tests import get_tests_input_path
from TTS.tts.tf.models.tacotron2 import Tacotron2
from TTS.tts.tf.utils.tflite import (convert_tacotron2_to_tflite,
load_tflite_model)
from TTS.utils.io import l... | 5,947 | 42.101449 | 121 | py |
TTS | TTS-master/tests/test_stft_torch.py | 0 | 0 | 0 | py | |
TTS | TTS-master/tests/test_vocoder_pqmf.py | import os
import torch
import soundfile as sf
from librosa.core import load
from tests import get_tests_path, get_tests_input_path
from TTS.vocoder.layers.pqmf import PQMF
TESTS_PATH = get_tests_path()
WAV_FILE = os.path.join(get_tests_input_path(), "example_1.wav")
def test_pqmf():
w, sr = load(WAV_FILE)
... | 626 | 21.392857 | 64 | py |
TTS | TTS-master/tests/test_vocoder_gan_datasets.py | import os
import numpy as np
from tests import get_tests_path, get_tests_input_path, get_tests_output_path
from torch.utils.data import DataLoader
from TTS.utils.audio import AudioProcessor
from TTS.utils.io import load_config
from TTS.vocoder.datasets.gan_dataset import GANDataset
from TTS.vocoder.datasets.preproces... | 4,221 | 42.979167 | 140 | py |
TTS | TTS-master/tests/test_tacotron2_model.py | import copy
import os
import unittest
import torch
from tests import get_tests_input_path
from torch import nn, optim
from TTS.tts.layers.losses import MSELossMasked
from TTS.tts.models.tacotron2 import Tacotron2
from TTS.utils.io import load_config
from TTS.utils.audio import AudioProcessor
#pylint: disable=unused-... | 14,763 | 49.047458 | 299 | py |
TTS | TTS-master/tests/test_vocoder_melgan_discriminator.py | import numpy as np
import torch
from TTS.vocoder.models.melgan_discriminator import MelganDiscriminator
from TTS.vocoder.models.melgan_multiscale_discriminator import MelganMultiscaleDiscriminator
def test_melgan_discriminator():
model = MelganDiscriminator()
print(model)
dummy_input = torch.rand((4, 1, ... | 882 | 31.703704 | 92 | py |
TTS | TTS-master/tests/__init__.py | import os
def get_tests_path():
"""Returns the path to the test directory."""
return os.path.dirname(os.path.realpath(__file__))
def get_tests_input_path():
"""Returns the path to the test data directory."""
return os.path.join(get_tests_path(), "inputs")
def get_tests_output_path():
"""Return... | 422 | 23.882353 | 61 | py |
TTS | TTS-master/tests/test_speedy_speech_layers.py | import torch
from TTS.tts.layers.speedy_speech.encoder import Encoder
from TTS.tts.layers.speedy_speech.decoder import Decoder
from TTS.tts.layers.speedy_speech.duration_predictor import DurationPredictor
from TTS.tts.utils.generic_utils import sequence_mask
from TTS.tts.models.speedy_speech import SpeedySpeech
use_... | 5,880 | 34.005952 | 79 | py |
TTS | TTS-master/tests/test_vocoder_parallel_wavegan_generator.py | import numpy as np
import torch
from TTS.vocoder.models.parallel_wavegan_generator import ParallelWaveganGenerator
def test_pwgan_generator():
model = ParallelWaveganGenerator(
in_channels=1,
out_channels=1,
kernel_size=3,
num_res_blocks=30,
stacks=3,
res_channels=... | 767 | 26.428571 | 82 | py |
TTS | TTS-master/tests/test_wavegrad_train.py | import unittest
import numpy as np
import torch
from torch import optim
from TTS.vocoder.models.wavegrad import Wavegrad
#pylint: disable=unused-variable
torch.manual_seed(1)
use_cuda = torch.cuda.is_available()
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
class WavegradTrainTest(unittes... | 2,498 | 38.666667 | 82 | py |
TTS | TTS-master/tests/test_audio.py | import os
import unittest
from tests import get_tests_input_path, get_tests_output_path, get_tests_path
from TTS.utils.audio import AudioProcessor
from TTS.utils.io import load_config
TESTS_PATH = get_tests_path()
OUT_PATH = os.path.join(get_tests_output_path(), "audio_tests")
WAV_FILE = os.path.join(get_tests_input... | 7,469 | 41.20339 | 194 | py |
TTS | TTS-master/tests/test_vocoder_wavernn.py | import numpy as np
import torch
import random
from TTS.vocoder.models.wavernn import WaveRNN
def test_wavernn():
model = WaveRNN(
rnn_dims=512,
fc_dims=512,
mode=10,
mulaw=False,
pad=2,
use_aux_net=True,
use_upsample_net=True,
upsample_factors=[4, 8,... | 850 | 25.59375 | 67 | py |
TTS | TTS-master/tests/test_vocoder_wavernn_datasets.py | import os
import shutil
import numpy as np
from tests import get_tests_path, get_tests_input_path, get_tests_output_path
from torch.utils.data import DataLoader
from TTS.utils.audio import AudioProcessor
from TTS.utils.io import load_config
from TTS.vocoder.datasets.wavernn_dataset import WaveRNNDataset
from TTS.voco... | 3,538 | 37.053763 | 101 | py |
TTS | TTS-master/tests/symbols_tests.py | import unittest
from TTS.tts.utils.text import phonemes
class SymbolsTest(unittest.TestCase):
def test_uniqueness(self): #pylint: disable=no-self-use
assert sorted(phonemes) == sorted(list(set(phonemes))), " {} vs {} ".format(len(phonemes), len(set(phonemes)))
| 276 | 33.625 | 118 | py |
TTS | TTS-master/tests/test_vocoder_tf_pqmf.py | import os
import tensorflow as tf
import soundfile as sf
from librosa.core import load
from tests import get_tests_path, get_tests_input_path
from TTS.vocoder.tf.layers.pqmf import PQMF
TESTS_PATH = get_tests_path()
WAV_FILE = os.path.join(get_tests_input_path(), "example_1.wav")
def test_pqmf():
w, sr = load... | 659 | 21.758621 | 64 | py |
TTS | TTS-master/notebooks/dataset_analysis/analyze.py | # visualisation tools for mimic2
import matplotlib.pyplot as plt
from statistics import stdev, mode, mean, median
from statistics import StatisticsError
import argparse
import os
import csv
import seaborn as sns
import random
from text.cmudict import CMUDict
def get_audio_seconds(frames):
return (frames*12.5)/1000... | 6,250 | 27.939815 | 91 | py |
layer-norm | layer-norm-master/layers.py | """
Layer functions
"""
import theano
import theano.tensor as tensor
import numpy
# layer normalization
def ln(x, b, s):
_eps = 1e-5
output = (x - x.mean(1)[:,None]) / tensor.sqrt((x.var(1)[:,None] + _eps))
output = s[None, :] * output + b[None,:]
return output
# layers: 'name': ('parameter initializ... | 16,949 | 32.697813 | 124 | py |
Python-Annotator-for-VideoS | Python-Annotator-for-VideoS-master/pavs.py | from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton, QLineEdit, QComboBox, QFileDialog, QStyleFactory, QHBoxLayout, QLabel, QSizePolicy, QSlider, QStyle, QVBoxLayout, QWidget, QStatusBar, QTableWidget, QVBoxLayout, QTableWidgetItem, QHBoxLayout, QSplitter, QGroupBox, QFormLayout, QAction, QGridLayout, QS... | 16,987 | 37.874142 | 327 | py |
ssqueezepy | ssqueezepy-master/setup.py | # -*- coding: utf-8 -*-
#
# Copyright © 2020 John Muradeli
# Licensed under the terms of the MIT License
# (see ssqueezepy/__init__.py for details)
"""
ssqueezepy
==========
Synchrosqueezing, wavelet transforms, and time-frequency analysis in Python
ssqueezepy features time-frequency analysis written for performance... | 3,036 | 34.729412 | 81 | py |
ssqueezepy | ssqueezepy-master/examples/scales_selection.py | # -*- coding: utf-8 -*-
"""Shows methods to use for CWT scales selection; also see their docstrings."""
if __name__ != '__main__':
raise Exception("ran example file as non-main")
import numpy as np
from ssqueezepy import ssq_cwt, Wavelet
from ssqueezepy.visuals import imshow, plot
from ssqueezepy.utils import cwt_... | 2,939 | 37.181818 | 83 | py |
ssqueezepy | ssqueezepy-master/examples/benchmarks.py | # -*- coding: utf-8 -*-
if __name__ != '__main__':
raise Exception("ran example file as non-main")
import os
import numpy as np
import gc
import pandas as pd
import scipy.signal as sig
import librosa
from pywt import cwt as pcwt
from timeit import timeit as _timeit
from ssqueezepy import cwt, stft, ssq_cwt, ssq_s... | 6,211 | 32.219251 | 83 | py |
ssqueezepy | ssqueezepy-master/examples/se_ans0.py | # -*- coding: utf-8 -*-
"""Code for https://dsp.stackexchange.com/a/71399/50076
"""
if __name__ != '__main__':
raise Exception("ran example file as non-main")
import numpy as np
import matplotlib.pyplot as plt
from ssqueezepy import ssq_cwt, cwt
from ssqueezepy.visuals import plot, imshow
#%%# Signal generators #... | 2,775 | 31.27907 | 78 | py |
ssqueezepy | ssqueezepy-master/examples/cwt_higher_order.py | # -*- coding: utf-8 -*-
"""Show CWT with higher-order Generalized Morse Wavelets on parallel reflect-added
linear chirps, with and without noise, and show GMW waveforms.
"""
if __name__ != '__main__':
raise Exception("ran example file as non-main")
import numpy as np
from ssqueezepy import cwt, TestSignals
from ss... | 959 | 27.235294 | 82 | py |
ssqueezepy | ssqueezepy-master/examples/ridge_chirp.py | # -*- coding: utf-8 -*-
if __name__ != '__main__':
raise Exception("ran example file as non-main")
import numpy as np
from numpy.fft import rfft
from ssqueezepy import ssq_cwt, issq_cwt, cwt
from ssqueezepy.toolkit import lin_band, cos_f, mad_rms
from ssqueezepy.visuals import imshow, plot, scat
#%%#############... | 1,949 | 30.967213 | 78 | py |
ssqueezepy | ssqueezepy-master/examples/phase_ssqueeze.py | # -*- coding: utf-8 -*-
"""Experimental feature example."""
if __name__ != '__main__':
raise Exception("ran example file as non-main")
import numpy as np
from ssqueezepy import TestSignals, ssq_cwt, Wavelet
from ssqueezepy.visuals import imshow
from ssqueezepy.experimental import phase_ssqueeze
#%%
x = TestSignal... | 678 | 27.291667 | 74 | py |
ssqueezepy | ssqueezepy-master/examples/test_transforms.py | # -*- coding: utf-8 -*-
if __name__ != '__main__':
raise Exception("ran example file as non-main")
import numpy as np
import scipy.signal as sig
from ssqueezepy import Wavelet, TestSignals
from ssqueezepy.utils import window_resolution
tsigs = TestSignals(N=2048)
#%%# Viz signals #################################... | 2,620 | 29.476744 | 80 | py |
ssqueezepy | ssqueezepy-master/examples/extracting_ridges.py | # -*- coding: utf-8 -*-
"""Authors: David Bondesson, OverLordGoldDragon
Ridge extraction on signals with varying time-frequency characteristics.
"""
if __name__ != '__main__':
raise Exception("ran example file as non-main")
import numpy as np
import scipy.signal as sig
from ssqueezepy import ssq_cwt, ssq_stft, ex... | 4,536 | 35.296 | 81 | py |
ssqueezepy | ssqueezepy-master/tests/fft_test.py | # -*- coding: utf-8 -*-
"""Fast Fourier Transform, CPU parallelization, and GPU execution tests:
- multi-thread CPU & GPU outputs match that of single-thread CPU
- batched (multi-input) outputs match single for-looped
- `ssqueezepy.FFT` outputs match `scipy`'s
- unified synchrosqueezing pipelines outputs ma... | 24,286 | 35.195231 | 81 | py |
ssqueezepy | ssqueezepy-master/tests/misc_test.py | # -*- coding: utf-8 -*-
"""Utilities & others
"""
import pytest
from ssqueezepy.wavelets import Wavelet
from ssqueezepy.utils import cwt_scalebounds
# no visuals here but 1 runs as regular script instead of pytest, for debugging
VIZ = 0
def test_bounds():
wavelet = Wavelet(('morlet', {'mu': 6}))
for N in (4... | 613 | 21.740741 | 79 | py |
ssqueezepy | ssqueezepy-master/tests/conftest.py |
def pytest_configure(config):
import traceback
t = traceback.extract_stack()
if 'pytestworker.py' in t[0][0]:
import matplotlib
matplotlib.use('template') # suppress plots when Spyder unit-testing
| 227 | 27.5 | 77 | py |
ssqueezepy | ssqueezepy-master/tests/z_all_test.py | # -*- coding: utf-8 -*-
"""Lazy tests just to ensure nothing breaks.
`z_` to ensure test runs last per messing with module namespaces.
"""
#### Disable Numba JIT during testing, as pytest can't measure its coverage ##
# TODO find shorter way to do this
def njit(fn):
def decor(*args, **kw):
return fn(*args,... | 16,821 | 31.919765 | 82 | py |
ssqueezepy | ssqueezepy-master/tests/ridge_extraction_test.py | # -*- coding: utf-8 -*-
"""Coverage-mainly tests; see examples/extracting_ridges.py for more test cases.
"""
import os
import pytest
import numpy as np
import scipy.signal as sig
from ssqueezepy import ssq_cwt, ssq_stft, extract_ridges, cwt
from ssqueezepy.visuals import plot, imshow
# set to 1 to run tests as functio... | 3,910 | 34.554545 | 81 | py |
ssqueezepy | ssqueezepy-master/tests/adm_coef_test.py | # -*- coding: utf-8 -*-
"""Test accuracy and stability of computing `adm_cwt` and `adm_ssq`
via numeric integration.
Unstable integration will yield values close to zero, whereass admissibility
coefficients for majority of wavelet configurations will evaluate to a
'not very small' value (set to 1e-3 here).
"""
import ... | 1,855 | 24.081081 | 76 | py |
ssqueezepy | ssqueezepy-master/tests/reconstruction_test.py | # -*- coding: utf-8 -*-
import os
import pytest
import numpy as np
from ssqueezepy import ssq_cwt, issq_cwt, ssq_stft, issq_stft
from ssqueezepy import cwt, icwt, stft, istft
from ssqueezepy._stft import get_window
from ssqueezepy.toolkit import lin_band
try:
from librosa import stft as lstft
except Exception as e:... | 8,954 | 32.665414 | 81 | py |
ssqueezepy | ssqueezepy-master/tests/gmw_test.py | # -*- coding: utf-8 -*-
"""Generalized Morse Wavelets.
Tests:
- Implementations are `Wavelet`-compatible
- Consistency of `Wavelet`-compatible implems with that of full `morsewave`
- GMW L1 & L2 norms work as expected
"""
import os
import pytest
import numpy as np
from ssqueezepy.wavelets import Wavelet
fr... | 3,959 | 34.675676 | 79 | py |
ssqueezepy | ssqueezepy-master/tests/props_test.py | # -*- coding: utf-8 -*-
"""Test computation of various wavelet properties (time-frequency resolution,
center frequency, etc). Note that these don't grid-search but sweep one
parameter at a time while keeping others fixed.
Certain thresholds were set greater as they fail on Travis (but not on author's
machine).
"""
imp... | 12,157 | 38.093248 | 80 | py |
ssqueezepy | ssqueezepy-master/tests/__init__.py | 0 | 0 | 0 | py | |
ssqueezepy | ssqueezepy-master/tests/test_signals_test.py | # -*- coding: utf-8 -*-
"""Test ssqueezepy/_test_signals.py"""
import os
import pytest
import warnings
import numpy as np
import scipy.signal as sig
from ssqueezepy import Wavelet, TestSignals
from ssqueezepy.utils import window_resolution
VIZ = 0
os.environ['SSQ_GPU'] = '0' # in case concurrent tests set it to '1'
... | 3,282 | 26.358333 | 82 | py |
ssqueezepy | ssqueezepy-master/ssqueezepy/_cwt.py | # -*- coding: utf-8 -*-
import numpy as np
from .utils import fft, ifft, ifftshift, FFT_GLOBAL
from .utils import WARN, adm_cwt, adm_ssq, _process_fs_and_t
from .utils import padsignal, process_scales, logscale_transition_idx
from .utils import backend as S
from .utils.backend import Q
from .algos import replace_at_inf... | 23,966 | 39.691002 | 82 | py |
ssqueezepy | ssqueezepy-master/ssqueezepy/_test_signals.py | # -*- coding: utf-8 -*-
"""
Signals for testing effectiveness of time-frequency transforms against
variety of localization characteristics.
1. **sine**: pure sine or cosine at one frequency, `cos(2pi f t)`
a. sine
b. cosine
c. phase-shifted
d. trimmed (others complete exactly one cycle) (not implemente... | 38,844 | 38.557026 | 82 | py |
ssqueezepy | ssqueezepy-master/ssqueezepy/_gmw.py | # -*- coding: utf-8 -*-
"""Generalized Morse Wavelets.
For complete functionality, utility functions have been ported from jLab, and
largely validated to match jLab's behavior. jLab tests not ported.
"""
import numpy as np
from numpy.fft import ifft
from numba import jit
from scipy.special import (gamma as gamma_fn,... | 29,146 | 36.657623 | 83 | py |
ssqueezepy | ssqueezepy-master/ssqueezepy/ridge_extraction.py | # -*- coding: utf-8 -*-
"""Authors: David Bondesson, John Muradeli
Ridge extraction from time-frequency representations (STFT, CWT, synchrosqueezed).
"""
import numpy as np
from numba import jit, prange
from .utils import EPS32, EPS64
def extract_ridges(Tf, scales, penalty=2., n_ridges=1, bw=15, transform='cwt',
... | 10,013 | 41.978541 | 82 | py |
ssqueezepy | ssqueezepy-master/ssqueezepy/_ssq_cwt.py | # -*- coding: utf-8 -*-
import numpy as np
from .utils import EPS32, EPS64, pi, p2up, adm_ssq, process_scales
from .utils import trigdiff, _process_fs_and_t
from .utils import backend as S
from .algos import replace_under_abs, phase_cwt_cpu, phase_cwt_gpu
from .ssqueezing import ssqueeze, _check_ssqueezing_args
from .w... | 24,265 | 40.059222 | 82 | py |
ssqueezepy | ssqueezepy-master/ssqueezepy/wavelets.py | # -*- coding: utf-8 -*-
import numpy as np
import gc
from numba import jit
from types import FunctionType
from scipy import integrate
from .algos import find_maximum
from .configs import gdefaults, USE_GPU, IS_PARALLEL
from .utils import backend as S
from .utils.fft_utils import ifft, fftshift, ifftshift
from .utils.ba... | 38,840 | 38.154234 | 82 | py |
ssqueezepy | ssqueezepy-master/ssqueezepy/_stft.py | # -*- coding: utf-8 -*-
import numpy as np
import scipy.signal as sig
from .utils import WARN, padsignal, buffer, unbuffer, window_norm
from .utils import _process_fs_and_t
from .utils.fft_utils import fft, ifft, rfft, irfft, fftshift, ifftshift
from .utils.backend import torch, is_tensor
from .algos import zero_denorm... | 13,033 | 39.858934 | 82 | py |
ssqueezepy | ssqueezepy-master/ssqueezepy/toolkit.py | # -*- coding: utf-8 -*-
import numpy as np
from .visuals import imshow, plot
#### Synchrosqueezing ########################################################
def lin_band(Tx, slope, offset, bw=.025, **kw):
"""Visually estimate a linear band to invert over in time-frequency(/scale)
plane.
"""
na, N = Tx.... | 1,755 | 36.361702 | 82 | py |
ssqueezepy | ssqueezepy-master/ssqueezepy/visuals.py | # -*- coding: utf-8 -*-
"""Convenience visual methods"""
import numpy as np
from pathlib import Path
from .algos import find_closest, find_maximum
from .configs import gdefaults
from . import plt
#### Visualizations ##########################################################
def wavelet_tf(wavelet, N=2048, scale=None,... | 37,418 | 35.153623 | 82 | py |
ssqueezepy | ssqueezepy-master/ssqueezepy/experimental.py | # -*- coding: utf-8 -*-
import warnings
import numpy as np
from .wavelets import Wavelet, center_frequency
from .utils import backend as S, cwt_scalebounds
from .utils.common import EPS32, EPS64, p2up, trigdiff
from .ssqueezing import ssqueeze
from ._ssq_cwt import phase_cwt, phase_cwt_num
from ._ssq_stft import phase_... | 9,923 | 37.169231 | 82 | py |
ssqueezepy | ssqueezepy-master/ssqueezepy/__init__.py | # -*- coding: utf-8 -*-
"""
MIT License
===========
Some ssqueezepy source files under other terms (see NOTICE.txt).
Copyright (c) 2020 John Muradeli
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Softw... | 2,523 | 28.011494 | 79 | py |
ssqueezepy | ssqueezepy-master/ssqueezepy/_ssq_stft.py | # -*- coding: utf-8 -*-
import numpy as np
from ._stft import stft, get_window, _check_NOLA
from ._ssq_cwt import _invert_components, _process_component_inversion_args
from .utils.cwt_utils import _process_fs_and_t, infer_scaletype
from .utils.common import WARN, EPS32, EPS64
from .utils import backend as S
from .utils... | 8,660 | 34.207317 | 82 | py |
ssqueezepy | ssqueezepy-master/ssqueezepy/configs.py | # -*- coding: utf-8 -*-
"""
Contains `GDEFAULTS`, global defaults dictionary, set in `ssqueezepy.configs.ini`.
The .ini is parsed into a dict, then values are retrieved internally by functions
via `gdefaults()`, which sets default values if keyword arguments weren't set
to original functions (or were set to `None`).
... | 4,853 | 31.145695 | 82 | py |
ssqueezepy | ssqueezepy-master/ssqueezepy/ssqueezing.py | # -*- coding: utf-8 -*-
import numpy as np
from types import FunctionType
from .algos import indexed_sum_onfly, ssqueeze_fast
from .utils import p2up, process_scales, infer_scaletype, _process_fs_and_t
from .utils import NOTE, pi, logscale_transition_idx, assert_is_one_of
from .utils.backend import Q
from .utils.common... | 15,556 | 41.159892 | 82 | py |
ssqueezepy | ssqueezepy-master/ssqueezepy/algos.py | # -*- coding: utf-8 -*-
"""CPU- & GPU-accelerated routines, and few neat algorithms.
"""
import numpy as np
from numba import jit, prange
from functools import reduce
from .utils.backend import asnumpy, cp, torch
from .utils.gpu_utils import _run_on_gpu, _get_kernel_params
from .utils import backend as S
from .configs ... | 46,480 | 34.78214 | 82 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.