id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
8,285 | import numpy as np
import pandas as pd
import torch
import gensim
from gensim.models import Word2Vec
from tqdm import tqdm
import fire
import sys
import os
from utils.build_vocab import Vocabulary
def create_embedding(vocab_file: str,
embed_size: int,
output: str,
... | null |
8,286 | import sys
import os
import librosa
import numpy as np
import torch
import audio_to_text.captioning.models
import audio_to_text.captioning.models.encoder
import audio_to_text.captioning.models.decoder
import audio_to_text.captioning.utils.train_util as train_util
def load_model(config, checkpoint):
ckpt = torch.lo... | null |
8,287 | import sys
import os
import librosa
import numpy as np
import torch
import audio_to_text.captioning.models
import audio_to_text.captioning.models.encoder
import audio_to_text.captioning.models.decoder
import audio_to_text.captioning.utils.train_util as train_util
def decode_caption(word_ids, vocabulary):
candidate... | null |
8,288 | import math
import random
from collections import deque
from functools import partial
from inspect import isfunction
from pathlib import Path
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from tqdm import tqdm
from einops import rearrange
from modules.fastspeech.fs2 import FastSpe... | null |
8,289 | import math
import random
from collections import deque
from functools import partial
from inspect import isfunction
from pathlib import Path
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from tqdm import tqdm
from einops import rearrange
from modules.fastspeech.fs2 import FastSpe... | null |
8,290 | import math
import random
from collections import deque
from functools import partial
from inspect import isfunction
from pathlib import Path
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from tqdm import tqdm
from einops import rearrange
from modules.fastspeech.fs2 import FastSpe... | null |
8,291 | import math
import random
from collections import deque
from functools import partial
from inspect import isfunction
from pathlib import Path
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from tqdm import tqdm
from einops import rearrange
from modules.fastspeech.fs2 import FastSpe... | linear schedule |
8,292 | import math
import random
from collections import deque
from functools import partial
from inspect import isfunction
from pathlib import Path
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from tqdm import tqdm
from einops import rearrange
from modules.fastspeech.fs2 import FastSpe... | cosine schedule as proposed in https://openreview.net/forum?id=-NEXDKk8gZ |
8,293 | import math
import random
from functools import partial
from inspect import isfunction
from pathlib import Path
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from tqdm import tqdm
from einops import rearrange
from modules.fastspeech.fs2 import FastSpeech2
from modules.diffsinger_m... | null |
8,294 | import math
import random
from functools import partial
from inspect import isfunction
from pathlib import Path
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from tqdm import tqdm
from einops import rearrange
from modules.fastspeech.fs2 import FastSpeech2
from modules.diffsinger_m... | null |
8,295 | import math
import random
from functools import partial
from inspect import isfunction
from pathlib import Path
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from tqdm import tqdm
from einops import rearrange
from modules.fastspeech.fs2 import FastSpeech2
from modules.diffsinger_m... | null |
8,296 | import math
import random
from functools import partial
from inspect import isfunction
from pathlib import Path
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from tqdm import tqdm
from einops import rearrange
from modules.fastspeech.fs2 import FastSpeech2
from modules.diffsinger_m... | null |
8,297 | import math
import random
from functools import partial
from inspect import isfunction
from pathlib import Path
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from tqdm import tqdm
from einops import rearrange
from modules.fastspeech.fs2 import FastSpeech2
from modules.diffsinger_m... | null |
8,298 | import math
import random
from functools import partial
from inspect import isfunction
from pathlib import Path
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from tqdm import tqdm
from einops import rearrange
from modules.fastspeech.fs2 import FastSpeech2
from modules.diffsinger_m... | cosine schedule as proposed in https://openreview.net/forum?id=-NEXDKk8gZ |
8,299 | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from math import sqrt
from .diffusion import Mish
from utils.hparams import hparams
def Conv1d(*args, **kwargs):
layer = nn.Conv1d(*args, **kwargs)
nn.init.kaiming_normal_(layer.weight)
return layer | null |
8,300 | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from math import sqrt
from .diffusion import Mish
from utils.hparams import hparams
def silu(x):
return x * torch.sigmoid(x) | null |
8,301 | from modules.fastspeech.tts_modules import FastspeechDecoder
import torch
from torch.nn import functional as F
import torch.nn as nn
import math
from utils.hparams import hparams
from .diffusion import Mish
def Conv1d(*args, **kwargs):
layer = nn.Conv1d(*args, **kwargs)
nn.init.kaiming_normal_(layer.weight)
... | null |
8,302 | from copy import deepcopy
import torch
import dgl
import stanza
import networkx as nx
The provided code snippet includes necessary dependencies for implementing the `plot_dgl_sentence_graph` function. Write a Python function `def plot_dgl_sentence_graph(dgl_graph, labels)` to solve the following problem:
labels = {id... | labels = {idx: word for idx,word in enumerate(sentence.split(" ")) } |
8,303 | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
from dgl.nn.pytorch import GatedGraphConv
def sequence_mask(lengths, maxlen, dtype=torch.bool):
if maxlen is None:
maxlen = lengths.max()
mask = ~(torch.ones((len(lengths), maxlen)).to(lengths.device).cumsum(dim=1).t() > leng... | null |
8,304 | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
from dgl.nn.pytorch import GatedGraphConv
The provided code snippet includes necessary dependencies for implementing the `group_hidden_by_segs` function. Write a Python function `def group_hidden_by_segs(h, seg_ids, max_len)` to solve the fo... | :param h: [B, T, H] :param seg_ids: [B, T] :return: h_ph: [B, T_ph, H] |
8,305 | import torch
import torch.nn.functional as F
def build_word_mask(x2word, y2word):
return (x2word[:, :, None] == y2word[:, None, :]).long() | null |
8,306 | import torch
import torch.nn.functional as F
def mel2ph_to_mel2word(mel2ph, ph2word):
mel2word = (ph2word - 1).gather(1, (mel2ph - 1).clamp(min=0)) + 1
mel2word = mel2word * (mel2ph > 0).long()
return mel2word | null |
8,307 | import torch
import torch.nn.functional as F
def clip_mel2token_to_multiple(mel2token, frames_multiple):
max_frames = mel2token.shape[1] // frames_multiple * frames_multiple
mel2token = mel2token[:, :max_frames]
return mel2token | null |
8,308 | import torch
import torch.nn.functional as F
def expand_states(h, mel2token):
h = F.pad(h, [0, 0, 1, 0])
mel2token_ = mel2token[..., None].repeat([1, 1, h.shape[-1]])
h = torch.gather(h, 1, mel2token_) # [B, T, H]
return h | null |
8,309 | import torch
from torch import nn
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_act
return acts | null |
8,310 | import torch
def squeeze(x, x_mask=None, n_sqz=2):
b, c, t = x.size()
t = (t // n_sqz) * n_sqz
x = x[:, :, :t]
x_sqz = x.view(b, c, t // n_sqz, n_sqz)
x_sqz = x_sqz.permute(0, 3, 1, 2).contiguous().view(b, c * n_sqz, t // n_sqz)
if x_mask is not None:
x_mask = x_mask[:, :, n_sqz - 1::... | null |
8,311 | import torch
def unsqueeze(x, x_mask=None, n_sqz=2):
b, c, t = x.size()
x_unsqz = x.view(b, n_sqz, c // n_sqz, t)
x_unsqz = x_unsqz.permute(0, 2, 3, 1).contiguous().view(b, c // n_sqz, t * n_sqz)
if x_mask is not None:
x_mask = x_mask.unsqueeze(-1).repeat(1, 1, 1, n_sqz).view(b, 1, t * n_sqz)... | null |
8,312 | import torch
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
from math import exp
def create_window(window_size, channel):
_1D_window = gaussian(window_size, 1.5).unsqueeze(1)
_2D_window = _1D_window.mm(_1D_window.t()).float().unsqueeze(0).unsqueeze(0)
window = Variabl... | null |
8,313 | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from modules.commons.common_layers import Embedding
from modules.fastspeech.tts_modules import LayerNorm
def init_weights_func(m):
classname = m.__class__.__name__
if classname.find("Conv1d") != -1:
torch.nn.init.xavier_unif... | null |
8,314 | import math
import torch
from torch import nn
from torch.nn import Parameter
import torch.onnx.operators
import torch.nn.functional as F
import utils
def Embedding(num_embeddings, embedding_dim, padding_idx=None):
m = nn.Embedding(num_embeddings, embedding_dim, padding_idx=padding_idx)
nn.init.normal_(m.weight... | null |
8,315 | import math
import torch
from torch import nn
from torch.nn import Parameter
import torch.onnx.operators
import torch.nn.functional as F
import utils
def LayerNorm(normalized_shape, eps=1e-5, elementwise_affine=True, export=False):
if not export and torch.cuda.is_available():
try:
from apex.nor... | null |
8,316 | import math
import torch
from torch import nn
from torch.nn import Parameter
import torch.onnx.operators
import torch.nn.functional as F
import utils
def Linear(in_features, out_features, bias=True):
m = nn.Linear(in_features, out_features, bias)
nn.init.xavier_uniform_(m.weight)
if bias:
nn.init.c... | null |
8,317 | import math
import torch
from torch import nn
from torch.nn import functional as F
from utils.hparams import hparams
from modules.commons.common_layers import Embedding
from utils.tts_utils import group_hidden_by_segs, expand_word2ph
import transformers
def convert_pad_shape(pad_shape):
l = pad_shape[::-1]
pad_... | null |
8,318 | import math
import torch
from torch import nn
from torch.nn import functional as F
from utils.hparams import hparams
from modules.commons.common_layers import Embedding
from utils.tts_utils import group_hidden_by_segs, expand_word2ph
import transformers
def sequence_mask(length, max_length=None):
if max_length is ... | null |
8,319 | import logging
import math
import torch
import torch.nn as nn
from torch.nn import functional as F
from modules.commons.espnet_positional_embedding import RelPositionalEncoding
from modules.commons.common_layers import SinusoidalPositionalEmbedding, Linear, EncSALayer, DecSALayer, BatchNorm1dTBC
from utils.hparams impo... | null |
8,320 | from modules.commons.common_layers import *
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_act
re... | null |
8,321 | import scipy
from torch.nn import functional as F
import torch
from torch import nn
import numpy as np
from modules.commons.common_layers import Permute
from modules.fastspeech.tts_modules import FFTBlocks
from modules.GenerSpeech.model.wavenet import fused_add_tanh_sigmoid_multiply, WN
def squeeze(x, x_mask=None, n_s... | null |
8,322 | import scipy
from torch.nn import functional as F
import torch
from torch import nn
import numpy as np
from modules.commons.common_layers import Permute
from modules.fastspeech.tts_modules import FFTBlocks
from modules.GenerSpeech.model.wavenet import fused_add_tanh_sigmoid_multiply, WN
def unsqueeze(x, x_mask=None, n... | null |
8,323 | from torch import nn
import copy
import torch
from utils.hparams import hparams
from modules.GenerSpeech.model.wavenet import WN
import math
from modules.fastspeech.tts_modules import LayerNorm
import torch.nn.functional as F
from utils.tts_utils import group_hidden_by_segs, sequence_mask
from scipy.cluster.vq import k... | null |
8,324 | from torch import nn
import copy
import torch
from utils.hparams import hparams
from modules.GenerSpeech.model.wavenet import WN
import math
from modules.fastspeech.tts_modules import LayerNorm
import torch.nn.functional as F
from utils.tts_utils import group_hidden_by_segs, sequence_mask
from scipy.cluster.vq import k... | null |
8,325 | import torch
import torch.nn.functional as F
import torch.nn as nn
from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d
from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm
from modules.parallel_wavegan.layers import UpsampleNetwork, ConvInUpsampleNetwork
from modules.parallel_wavegan.mo... | null |
8,326 | import torch
import torch.nn.functional as F
import torch.nn as nn
from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d
from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm
from modules.parallel_wavegan.layers import UpsampleNetwork, ConvInUpsampleNetwork
from modules.parallel_wavegan.mo... | null |
8,327 | import torch
import torch.nn.functional as F
import torch.nn as nn
from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d
from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm
from modules.parallel_wavegan.layers import UpsampleNetwork, ConvInUpsampleNetwork
from modules.parallel_wavegan.mo... | null |
8,328 | import torch
import torch.nn.functional as F
import torch.nn as nn
from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d
from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm
from modules.parallel_wavegan.layers import UpsampleNetwork, ConvInUpsampleNetwork
from modules.parallel_wavegan.mo... | null |
8,329 | import torch
import torch.nn.functional as F
import torch.nn as nn
from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d
from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm
from modules.parallel_wavegan.layers import UpsampleNetwork, ConvInUpsampleNetwork
from modules.parallel_wavegan.mo... | null |
8,330 | import torch
import torch.nn.functional as F
import torch.nn as nn
from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d
from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm
from modules.parallel_wavegan.layers import UpsampleNetwork, ConvInUpsampleNetwork
from modules.parallel_wavegan.mo... | null |
8,331 | import torch
import torch.nn.functional as F
import torch.nn as nn
from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d
from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm
from modules.parallel_wavegan.layers import UpsampleNetwork, ConvInUpsampleNetwork
from modules.parallel_wavegan.mo... | null |
8,332 | import numpy as np
import torch
import torch.utils.data
from librosa.filters import mel as librosa_mel_fn
from scipy.io.wavfile import read
def load_wav(full_path):
sampling_rate, data = read(full_path)
return data, sampling_rate | null |
8,333 | import numpy as np
import torch
import torch.utils.data
from librosa.filters import mel as librosa_mel_fn
from scipy.io.wavfile import read
def dynamic_range_compression(x, C=1, clip_val=1e-5):
return np.log(np.clip(x, a_min=clip_val, a_max=None) * C) | null |
8,334 | import numpy as np
import torch
import torch.utils.data
from librosa.filters import mel as librosa_mel_fn
from scipy.io.wavfile import read
def dynamic_range_decompression(x, C=1):
return np.exp(x) / C | null |
8,335 | import numpy as np
import torch
import torch.utils.data
from librosa.filters import mel as librosa_mel_fn
from scipy.io.wavfile import read
def dynamic_range_decompression_torch(x, C=1):
return torch.exp(x) / C
def spectral_de_normalize_torch(magnitudes):
output = dynamic_range_decompression_torch(magnitudes)
... | null |
8,336 | import numpy as np
import torch
import torch.utils.data
from librosa.filters import mel as librosa_mel_fn
from scipy.io.wavfile import read
def spectral_normalize_torch(magnitudes):
output = dynamic_range_compression_torch(magnitudes)
return output
mel_basis = {}
hann_window = {}
def mel_spectrogram(y, hparams... | null |
8,337 | import torch
import torch.nn.functional as F
The provided code snippet includes necessary dependencies for implementing the `stft` function. Write a Python function `def stft(x, fft_size, hop_size, win_length, window)` to solve the following problem:
Perform STFT and convert to magnitude spectrogram. Args: x (Tensor):... | Perform STFT and convert to magnitude spectrogram. Args: x (Tensor): Input signal tensor (B, T). fft_size (int): FFT size. hop_size (int): Hop size. win_length (int): Window length. window (str): Window function type. Returns: Tensor: Magnitude spectrogram (B, #frames, fft_size // 2 + 1). |
8,338 | import numpy as np
import torch
import torch.nn.functional as F
from scipy.signal import kaiser
The provided code snippet includes necessary dependencies for implementing the `design_prototype_filter` function. Write a Python function `def design_prototype_filter(taps=62, cutoff_ratio=0.15, beta=9.0)` to solve the fol... | Design prototype filter for PQMF. This method is based on `A Kaiser window approach for the design of prototype filters of cosine modulated filterbanks`_. Args: taps (int): The number of filter taps. cutoff_ratio (float): Cut-off frequency ratio. beta (float): Beta coefficient for kaiser window. Returns: ndarray: Implu... |
8,339 | import fnmatch
import logging
import os
import sys
import h5py
import numpy as np
The provided code snippet includes necessary dependencies for implementing the `find_files` function. Write a Python function `def find_files(root_dir, query="*.wav", include_root_dir=True)` to solve the following problem:
Find files rec... | Find files recursively. Args: root_dir (str): Root root_dir to find. query (str): Query to find. include_root_dir (bool): If False, root_dir name is not included. Returns: list: List of found filenames. |
8,340 | import fnmatch
import logging
import os
import sys
import h5py
import numpy as np
The provided code snippet includes necessary dependencies for implementing the `read_hdf5` function. Write a Python function `def read_hdf5(hdf5_name, hdf5_path)` to solve the following problem:
Read hdf5 dataset. Args: hdf5_name (str): ... | Read hdf5 dataset. Args: hdf5_name (str): Filename of hdf5 file. hdf5_path (str): Dataset name in hdf5 file. Return: any: Dataset values. |
8,341 | import fnmatch
import logging
import os
import sys
import h5py
import numpy as np
The provided code snippet includes necessary dependencies for implementing the `write_hdf5` function. Write a Python function `def write_hdf5(hdf5_name, hdf5_path, write_data, is_overwrite=True)` to solve the following problem:
Write dat... | Write dataset to hdf5. Args: hdf5_name (str): Hdf5 dataset filename. hdf5_path (str): Dataset path in hdf5. write_data (ndarray): Data to write. is_overwrite (bool): Whether to overwrite dataset. |
8,342 |
def cpop_pinyin2ph_func():
# In the README file of opencpop dataset, they defined a "pinyin to phoneme mapping table"
pinyin2phs = {'AP': 'AP', 'SP': 'SP'}
with open('NeuralSeq/inference/svs/opencpop/cpop_pinyin2ph.txt') as rf:
for line in rf.readlines():
elements = [x.strip() for x in... | null |
8,343 | import importlib
VOCODERS = {}
def register_vocoder(cls):
VOCODERS[cls.__name__.lower()] = cls
VOCODERS[cls.__name__] = cls
return cls | null |
8,344 | import importlib
VOCODERS = {}
def get_vocoder_cls(hparams):
if hparams['vocoder'] in VOCODERS:
return VOCODERS[hparams['vocoder']]
else:
vocoder_cls = hparams['vocoder']
pkg = ".".join(vocoder_cls.split(".")[:-1])
cls_name = vocoder_cls.split(".")[-1]
vocoder_cls = geta... | null |
8,345 | import librosa
from utils.hparams import hparams
import numpy as np
hparams = {}
def denoise(wav, v=0.1):
spec = librosa.stft(y=wav, n_fft=hparams['fft_size'], hop_length=hparams['hop_size'],
win_length=hparams['win_size'], pad_mode='constant')
spec_m = np.abs(spec)
spec_m = np.cli... | null |
8,346 | import glob
import json
import os
import re
import librosa
import torch
import utils
from modules.hifigan.hifigan import HifiGanGenerator
from utils.hparams import hparams, set_hparams
from vocoders.base_vocoder import register_vocoder
from vocoders.pwg import PWG
from vocoders.vocoder_utils import denoise
class HifiG... | null |
8,347 | import glob
import re
import librosa
import torch
import yaml
from sklearn.preprocessing import StandardScaler
from torch import nn
from modules.parallel_wavegan.models import ParallelWaveGANGenerator
from modules.parallel_wavegan.utils import read_hdf5
from utils.hparams import hparams
from utils.pitch_utils import f0... | null |
8,348 | import importlib
from utils.hparams import set_hparams, hparams
hparams = {}
def run_task():
assert hparams['task_cls'] != ''
pkg = ".".join(hparams["task_cls"].split(".")[:-1])
cls_name = hparams["task_cls"].split(".")[-1]
task_cls = getattr(importlib.import_module(pkg), cls_name)
task_cls.start(... | null |
8,349 | import importlib
from data_gen.tts.base_binarizer import BaseBinarizer
from data_gen.tts.base_preprocess import BasePreprocessor
from data_gen.tts.txt_processors.base_text_processor import get_txt_processor_cls
from utils.hparams import hparams
hparams = {}
def parse_dataset_configs():
max_tokens = hparams['max_t... | null |
8,350 | import importlib
from data_gen.tts.base_binarizer import BaseBinarizer
from data_gen.tts.base_preprocess import BasePreprocessor
from data_gen.tts.txt_processors.base_text_processor import get_txt_processor_cls
from utils.hparams import hparams
hparams = {}
def parse_mel_losses():
mel_losses = hparams['mel_losses... | null |
8,351 | import importlib
from data_gen.tts.base_binarizer import BaseBinarizer
from data_gen.tts.base_preprocess import BasePreprocessor
from data_gen.tts.txt_processors.base_text_processor import get_txt_processor_cls
from utils.hparams import hparams
class BasePreprocessor:
def __init__(self):
self.preprocess_ar... | null |
8,352 | import importlib
from data_gen.tts.base_binarizer import BaseBinarizer
from data_gen.tts.base_preprocess import BasePreprocessor
from data_gen.tts.txt_processors.base_text_processor import get_txt_processor_cls
from utils.hparams import hparams
class BaseBinarizer:
def __init__(self, processed_data_dir=None):
... | null |
8,353 | REGISTERED_WAV_PROCESSORS = {}
def register_wav_processors(name):
def _f(cls):
REGISTERED_WAV_PROCESSORS[name] = cls
return cls
return _f | null |
8,354 | REGISTERED_WAV_PROCESSORS = {}
def get_wav_processor_cls(name):
return REGISTERED_WAV_PROCESSORS.get(name, None) | null |
8,355 | import warnings
import parselmouth
import os
import torch
from skimage.transform import resize
from utils.text_encoder import TokenTextEncoder
from utils.pitch_utils import f0_to_coarse
import struct
import webrtcvad
from scipy.ndimage.morphology import binary_dilation
import librosa
import numpy as np
from utils impor... | null |
8,356 | import warnings
import parselmouth
import os
import torch
from skimage.transform import resize
from utils.text_encoder import TokenTextEncoder
from utils.pitch_utils import f0_to_coarse
import struct
import webrtcvad
from scipy.ndimage.morphology import binary_dilation
import librosa
import numpy as np
from utils impor... | :param wav_data: [T] :param mel: [T, 80] :param hparams: :return: |
8,357 | import warnings
import parselmouth
import os
import torch
from skimage.transform import resize
from utils.text_encoder import TokenTextEncoder
from utils.pitch_utils import f0_to_coarse
import struct
import webrtcvad
from scipy.ndimage.morphology import binary_dilation
import librosa
import numpy as np
from utils impor... | null |
8,358 | import warnings
import parselmouth
import os
import torch
from skimage.transform import resize
from utils.text_encoder import TokenTextEncoder
from utils.pitch_utils import f0_to_coarse
import struct
import webrtcvad
from scipy.ndimage.morphology import binary_dilation
import librosa
import numpy as np
from utils impor... | null |
8,359 | import warnings
import parselmouth
import os
import torch
from skimage.transform import resize
from utils.text_encoder import TokenTextEncoder
from utils.pitch_utils import f0_to_coarse
import struct
import webrtcvad
from scipy.ndimage.morphology import binary_dilation
import librosa
import numpy as np
from utils impor... | null |
8,360 | import warnings
import parselmouth
import os
import torch
from skimage.transform import resize
from utils.text_encoder import TokenTextEncoder
from utils.pitch_utils import f0_to_coarse
import struct
import webrtcvad
from scipy.ndimage.morphology import binary_dilation
import librosa
import numpy as np
from utils impor... | null |
8,361 | from data_gen.tts.emotion.params_data import *
from data_gen.tts.emotion.model import EmotionEncoder
from data_gen.tts.emotion.audio import preprocess_wav
from matplotlib import cm
from data_gen.tts.emotion import audio
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import torch
_model = ... | Loads the model in memory. If this function is not explicitely called, it will be run on the first call to embed_frames() with the default weights file. :param weights_fpath: the path to saved model weights. :param device: either a torch device or the name of a torch device (e.g. "cpu", "cuda"). The model will be loade... |
8,362 | from data_gen.tts.emotion.params_data import *
from data_gen.tts.emotion.model import EmotionEncoder
from data_gen.tts.emotion.audio import preprocess_wav
from matplotlib import cm
from data_gen.tts.emotion import audio
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import torch
_model = ... | null |
8,363 | from data_gen.tts.emotion.params_data import *
from data_gen.tts.emotion.model import EmotionEncoder
from data_gen.tts.emotion.audio import preprocess_wav
from matplotlib import cm
from data_gen.tts.emotion import audio
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import torch
def embed... | Computes an embedding for a single utterance. # TODO: handle multiple wavs to benefit from batching on GPU :param wav: a preprocessed (see audio.py) utterance waveform as a numpy array of float32 :param using_partials: if True, then the utterance is split in partial utterances of <partial_utterance_n_frames> frames and... |
8,364 | from data_gen.tts.emotion.params_data import *
from data_gen.tts.emotion.model import EmotionEncoder
from data_gen.tts.emotion.audio import preprocess_wav
from matplotlib import cm
from data_gen.tts.emotion import audio
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import torch
def embe... | null |
8,365 | from data_gen.tts.emotion.params_data import *
from data_gen.tts.emotion.model import EmotionEncoder
from data_gen.tts.emotion.audio import preprocess_wav
from matplotlib import cm
from data_gen.tts.emotion import audio
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import torch
def plot... | null |
8,366 | from scipy.ndimage.morphology import binary_dilation
from data_gen.tts.emotion.params_data import *
from pathlib import Path
from typing import Optional, Union
import numpy as np
import webrtcvad
import librosa
import struct
def trim_long_silences(wav):
"""
Ensures that segments without voice in the waveform re... | Applies the preprocessing operations used in training the Speaker Encoder to a waveform either on disk or in memory. The waveform will be resampled to match the data hyperparameters. :param fpath_or_wav: either a filepath to an audio file (many extensions are supported, not just .wav), either the waveform as a numpy ar... |
8,367 | from data_gen.tts.data_gen_utils import is_sil_phoneme
REGISTERED_TEXT_PROCESSORS = {}
def register_txt_processors(name):
def _f(cls):
REGISTERED_TEXT_PROCESSORS[name] = cls
return cls
return _f | null |
8,368 | from data_gen.tts.data_gen_utils import is_sil_phoneme
REGISTERED_TEXT_PROCESSORS = {}
def get_txt_processor_cls(name):
return REGISTERED_TEXT_PROCESSORS.get(name, None) | null |
8,369 | import matplotlib
from torch.nn import DataParallel
from torch.nn.parallel import DistributedDataParallel
import glob
import itertools
import subprocess
import threading
import traceback
from pytorch_lightning.callbacks import GradientAccumulationScheduler
from pytorch_lightning.callbacks import ModelCheckpoint
from fu... | Decorator to make any fx with this use the lazy property :param fn: :return: |
8,370 | import matplotlib
from torch.nn import DataParallel
from torch.nn.parallel import DistributedDataParallel
import glob
import itertools
import subprocess
import threading
import traceback
from pytorch_lightning.callbacks import GradientAccumulationScheduler
from pytorch_lightning.callbacks import ModelCheckpoint
from fu... | r"""Applies each `module` in :attr:`modules` in parallel on arguments contained in :attr:`inputs` (positional) and :attr:`kwargs_tup` (keyword) on each of :attr:`devices`. Args: modules (Module): modules to be parallelized inputs (tensor): inputs to the modules devices (list of int or torch.device): CUDA devices :attr:... |
8,371 | import matplotlib
from torch.nn import DataParallel
from torch.nn.parallel import DistributedDataParallel
import glob
import itertools
import subprocess
import threading
import traceback
from pytorch_lightning.callbacks import GradientAccumulationScheduler
from pytorch_lightning.callbacks import ModelCheckpoint
from fu... | r""" Recursively find all tensors contained in the specified object. |
8,372 | import sys, os, argparse, codecs, string, re
CHINESE_DIGIS = u'零一二三四五六七八九'
BIG_CHINESE_DIGIS_SIMPLIFIED = u'零壹贰叁肆伍陆柒捌玖'
BIG_CHINESE_DIGIS_TRADITIONAL = u'零壹貳參肆伍陸柒捌玖'
SMALLER_BIG_CHINESE_UNITS_SIMPLIFIED = u'十百千万'
SMALLER_BIG_CHINESE_UNITS_TRADITIONAL = u'拾佰仟萬'
LARGER_CHINESE_NUMERING_UNITS_SIMPLIFIED = u'亿兆京垓秭穰沟涧正载'
LA... | null |
8,373 | import sys, os, argparse, codecs, string, re
CHINESE_DIGIS = u'零一二三四五六七八九'
BIG_CHINESE_DIGIS_SIMPLIFIED = u'零壹贰叁肆伍陆柒捌玖'
BIG_CHINESE_DIGIS_TRADITIONAL = u'零壹貳參肆伍陸柒捌玖'
SMALLER_BIG_CHINESE_UNITS_SIMPLIFIED = u'十百千万'
SMALLER_BIG_CHINESE_UNITS_TRADITIONAL = u'拾佰仟萬'
LARGER_CHINESE_NUMERING_UNITS_SIMPLIFIED = u'亿兆京垓秭穰沟涧正载'
LA... | null |
8,374 | import sys, os, argparse, codecs, string, re
CHINESE_DIGIS = u'零一二三四五六七八九'
BIG_CHINESE_DIGIS_SIMPLIFIED = u'零壹贰叁肆伍陆柒捌玖'
BIG_CHINESE_DIGIS_TRADITIONAL = u'零壹貳參肆伍陸柒捌玖'
SMALLER_BIG_CHINESE_UNITS_SIMPLIFIED = u'十百千万'
SMALLER_BIG_CHINESE_UNITS_TRADITIONAL = u'拾佰仟萬'
LARGER_CHINESE_NUMERING_UNITS_SIMPLIFIED = u'亿兆京垓秭穰沟涧正载'
LA... | null |
8,375 | import glob
import logging
import os
import re
import torch
def get_last_checkpoint(work_dir, steps=None):
checkpoint = None
last_ckpt_path = None
ckpt_paths = get_all_ckpts(work_dir, steps)
if len(ckpt_paths) > 0:
last_ckpt_path = ckpt_paths[0]
checkpoint = torch.load(last_ckpt_path, ma... | null |
8,376 | from numpy import array, zeros, full, argmin, inf, ndim
from scipy.spatial.distance import cdist
from math import isinf
def _traceback(D):
i, j = array(D.shape) - 2
p, q = [i], [j]
while (i > 0) or (j > 0):
tb = argmin((D[i, j], D[i, j + 1], D[i + 1, j]))
if tb == 0:
i -= 1
... | Computes Dynamic Time Warping (DTW) of two sequences. :param array x: N1*M array :param array y: N2*M array :param func dist: distance used as cost measure :param int warp: how many shifts are computed. :param int w: window size limiting the maximal distance between indices of matched entries |i,j|. :param float s: wei... |
8,377 | from numpy import array, zeros, full, argmin, inf, ndim
from scipy.spatial.distance import cdist
from math import isinf
def _traceback(D):
i, j = array(D.shape) - 2
p, q = [i], [j]
while (i > 0) or (j > 0):
tb = argmin((D[i, j], D[i, j + 1], D[i + 1, j]))
if tb == 0:
i -= 1
... | Computes Dynamic Time Warping (DTW) of two sequences in a faster way. Instead of iterating through each element and calculating each distance, this uses the cdist function from scipy (https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.cdist.html) :param array x: N1*M array :param array y: N2*M ... |
8,378 | import re
import six
from six.moves import range
The provided code snippet includes necessary dependencies for implementing the `strip_ids` function. Write a Python function `def strip_ids(ids, ids_to_strip)` to solve the following problem:
Strip ids_to_strip from the end ids.
Here is the function:
def strip_ids(ids... | Strip ids_to_strip from the end ids. |
8,379 | import subprocess
import matplotlib
import os
import librosa
import librosa.filters
import numpy as np
from scipy import signal
from scipy.io import wavfile
def save_wav(wav, path, sr, norm=False):
if norm:
wav = wav / np.abs(wav).max()
wav *= 32767
# proposed by @dsmiller
wavfile.write(path, s... | null |
8,380 | import subprocess
import matplotlib
import os
import librosa
import librosa.filters
import numpy as np
from scipy import signal
from scipy.io import wavfile
def get_hop_size(hparams):
def _stft(y, hparams):
return librosa.stft(y=y, n_fft=hparams['fft_size'], hop_length=get_hop_size(hparams),
... | null |
8,381 | import subprocess
import matplotlib
import os
import librosa
import librosa.filters
import numpy as np
from scipy import signal
from scipy.io import wavfile
def get_hop_size(hparams):
hop_size = hparams['hop_size']
if hop_size is None:
assert hparams['frame_shift_ms'] is not None
hop_size = int(... | null |
8,382 | import subprocess
import matplotlib
import os
import librosa
import librosa.filters
import numpy as np
from scipy import signal
from scipy.io import wavfile
def denormalize(D, hparams):
return (D * -hparams['min_level_db']) + hparams['min_level_db'] | null |
8,383 | import subprocess
import matplotlib
import os
import librosa
import librosa.filters
import numpy as np
from scipy import signal
from scipy.io import wavfile
def rnnoise(filename, out_fn=None, verbose=False, out_sample_rate=22050):
assert os.path.exists('./rnnoise/examples/rnnoise_demo'), INSTALL_STR
if out_fn ... | null |
8,384 | import librosa
import numpy as np
from pycwt import wavelet
from scipy.interpolate import interp1d
def load_wav(wav_file, sr):
wav, _ = librosa.load(wav_file, sr=sr, mono=True)
return wav | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.