repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
so-vits-svc | resample.py | .py | import argparse
import concurrent.futures
import os
from concurrent.futures import ProcessPoolExecutor
from multiprocessing import cpu_count
import librosa
import numpy as np
from rich.progress import track
from scipy.io import wavfile
def load_wav(wav_path):
return librosa.load(wav_path, sr=None)
def trim_wav... | 99 | 3,332 |
so-vits-svc | data_utils.py | .py | import os
import random
import numpy as np
import torch
import torch.utils.data
import utils
from modules.mel_processing import spectrogram_torch
from utils import load_filepaths_and_text, load_wav_to_torch
# import h5py
"""Multi speaker version"""
class TextAudioSpeakerLoader(torch.utils.data.Dataset):
"""
... | 186 | 7,039 |
so-vits-svc | vdecoder/nsf_hifigan/utils.py | .py | import glob
import os
import matplotlib
import matplotlib.pylab as plt
import torch
from torch.nn.utils import weight_norm
matplotlib.use("Agg")
def plot_spectrogram(spectrogram):
fig, ax = plt.subplots(figsize=(10, 2))
im = ax.imshow(spectrogram, aspect="auto", origin="lower",
interpolat... | 71 | 1,883 |
so-vits-svc | vdecoder/nsf_hifigan/nvSTFT.py | .py | import os
import librosa
import numpy as np
import soundfile as sf
import torch
import torch.nn.functional as F
import torch.utils.data
from librosa.filters import mel as librosa_mel_fn
os.environ["LRU_CACHE_CAPACITY"] = "3"
def load_wav_to_torch(full_path, target_sr=None, return_empty_on_exception=False):
sampl... | 133 | 5,357 |
so-vits-svc | vdecoder/nsf_hifigan/models.py | .py | import json
import os
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import AvgPool1d, Conv1d, Conv2d, ConvTranspose1d
from torch.nn.utils import remove_weight_norm, spectral_norm, weight_norm
from .env import AttrDict
from .utils import get_padding, init_weights
... | 442 | 16,432 |
so-vits-svc | vdecoder/nsf_hifigan/env.py | .py | import os
import shutil
class AttrDict(dict):
def __init__(self, *args, **kwargs):
super(AttrDict, self).__init__(*args, **kwargs)
self.__dict__ = self
def build_env(config, config_name, path):
t_path = os.path.join(path, config_name)
if config != t_path:
os.makedirs(path, exist_... | 16 | 394 |
so-vits-svc | vdecoder/hifiganwithsnake/utils.py | .py | import glob
import os
# matplotlib.use("Agg")
import matplotlib.pylab as plt
import torch
from torch.nn.utils import weight_norm
def plot_spectrogram(spectrogram):
fig, ax = plt.subplots(figsize=(10, 2))
im = ax.imshow(spectrogram, aspect="auto", origin="lower",
interpolation='none')
p... | 69 | 1,866 |
so-vits-svc | vdecoder/hifiganwithsnake/nvSTFT.py | .py | import os
import librosa
import numpy as np
import soundfile as sf
import torch
import torch.utils.data
from librosa.filters import mel as librosa_mel_fn
os.environ["LRU_CACHE_CAPACITY"] = "3"
def load_wav_to_torch(full_path, target_sr=None, return_empty_on_exception=False):
sampling_rate = None
try:
... | 110 | 4,420 |
so-vits-svc | vdecoder/hifiganwithsnake/models.py | .py | import json
import os
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import AvgPool1d, Conv1d, Conv2d, ConvTranspose1d
from torch.nn.utils import remove_weight_norm, spectral_norm, weight_norm
from vdecoder.hifiganwithsnake.alias.act import SnakeAlias
from .env im... | 577 | 22,768 |
so-vits-svc | vdecoder/hifiganwithsnake/alias/act.py | .py | # Adapted from https://github.com/junjun3518/alias-free-torch under the Apache License 2.0
# LICENSE is in incl_licenses directory.
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import pow, sin
from torch.nn import Parameter
from .resample import DownSample1d, UpSample1d
class Acti... | 130 | 4,470 |
so-vits-svc | vdecoder/hifiganwithsnake/alias/filter.py | .py | # Adapted from https://github.com/junjun3518/alias-free-torch under the Apache License 2.0
# LICENSE is in incl_licenses directory.
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
if 'sinc' in dir(torch):
sinc = torch.sinc
else:
# This code is adopted from adefossez's julius.... | 110 | 4,177 |
so-vits-svc | vdecoder/hifiganwithsnake/alias/resample.py | .py | # Adapted from https://github.com/junjun3518/alias-free-torch under the Apache License 2.0
# LICENSE is in incl_licenses directory.
import torch.nn as nn
from torch.nn import functional as F
from .filter import LowPassFilter1d, kaiser_sinc_filter1d
class UpSample1d(nn.Module):
def __init__(self, ratio=2, kern... | 72 | 3,226 |
so-vits-svc | vdecoder/hifigan/models.py | .py | import json
import os
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import AvgPool1d, Conv1d, Conv2d, ConvTranspose1d
from torch.nn.utils import remove_weight_norm, spectral_norm, weight_norm
from .env import AttrDict
from .utils import get_padding, init_weights
... | 558 | 21,795 |
so-vits-svc | diffusion/uni_pc.py | .py | import math
import torch
class NoiseScheduleVP:
def __init__(
self,
schedule='discrete',
betas=None,
alphas_cumprod=None,
continuous_beta_0=0.1,
continuous_beta_1=20.,
dtype=torch.float32,
):
"""Create a wrapper c... | 733 | 32,119 |
so-vits-svc | diffusion/dpm_solver_pytorch.py | .py | import torch
class NoiseScheduleVP:
def __init__(
self,
schedule='discrete',
betas=None,
alphas_cumprod=None,
continuous_beta_0=0.1,
continuous_beta_1=20.,
dtype=torch.float32,
):
"""Create a wrapper class for the ... | 1,307 | 68,247 |
so-vits-svc | diffusion/diffusion_onnx.py | .py | import math
from collections import deque
from functools import partial
from inspect import isfunction
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from torch.nn import Conv1d, Mish
from tqdm import tqdm
def exists(x):
return x is not None
def default(val, d):
if exi... | 615 | 24,620 |
so-vits-svc | diffusion/data_loaders.py | .py | import os
import random
import librosa
import numpy as np
import torch
from torch.utils.data import Dataset
from tqdm import tqdm
from utils import repeat_expand_2d
def traverse_dir(
root_dir,
extensions,
amount=None,
str_include=None,
str_exclude=None,
is_pure=False,... | 288 | 10,916 |
so-vits-svc | diffusion/diffusion.py | .py | from collections import deque
from functools import partial
from inspect import isfunction
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from tqdm import tqdm
def exists(x):
return x is not None
def default(val, d):
if exists(val):
return val
return d() if... | 397 | 17,014 |
so-vits-svc | diffusion/solver.py | .py | import time
import librosa
import numpy as np
import torch
from torch import autocast
from torch.cuda.amp import GradScaler
from diffusion.logger import utils
from diffusion.logger.saver import Saver
def test(args, model, vocoder, loader_test, saver):
print(' [*] testing...')
model.eval()
# losses
... | 201 | 7,270 |
so-vits-svc | diffusion/unit2mel.py | .py | import os
import numpy as np
import torch
import torch.nn as nn
import yaml
from .diffusion import GaussianDiffusion
from .vocoder import Vocoder
from .wavenet import WaveNet
class DotDict(dict):
def __getattr__(*args):
val = dict.get(*args)
return DotDict(val) if type(val) is ... | 168 | 6,452 |
so-vits-svc | diffusion/wavenet.py | .py | import math
from math import sqrt
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import Mish
class Conv1d(torch.nn.Conv1d):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
nn.init.kaiming_normal_(self.weight)
class SinusoidalPosEmb(nn.Mod... | 109 | 3,794 |
so-vits-svc | diffusion/infer_gt_mel.py | .py | import torch
import torch.nn.functional as F
from diffusion.unit2mel import load_model_vocoder
class DiffGtMel:
def __init__(self, project_path=None, device=None):
self.project_path = project_path
if device is not None:
self.device = device
else:
self.device = 'cud... | 75 | 3,062 |
so-vits-svc | diffusion/vocoder.py | .py | import torch
from torchaudio.transforms import Resample
from vdecoder.nsf_hifigan.models import load_config, load_model
from vdecoder.nsf_hifigan.nvSTFT import STFT
class Vocoder:
def __init__(self, vocoder_type, vocoder_ckpt, device = None):
if device is None:
device = 'cuda' if torch.cuda.i... | 95 | 3,370 |
so-vits-svc | diffusion/onnx_export.py | .py | import os
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import yaml
from diffusion_onnx import GaussianDiffusion
class DotDict(dict):
def __getattr__(*args):
val = dict.get(*args)
return DotDict(val) if type(val) is dict else val
_... | 236 | 9,091 |
so-vits-svc | diffusion/logger/utils.py | .py | import json
import os
import torch
import yaml
def traverse_dir(
root_dir,
extensions,
amount=None,
str_include=None,
str_exclude=None,
is_pure=False,
is_sort=False,
is_ext=True):
file_list = []
cnt = 0
for root, _, files in os.walk(root_di... | 128 | 3,738 |
so-vits-svc | diffusion/logger/saver.py | .py | '''
author: wayn391@mastertones
'''
import datetime
import os
import time
import matplotlib.pyplot as plt
import torch
import yaml
from torch.utils.tensorboard import SummaryWriter
class Saver(object):
def __init__(
self,
args,
initial_global_step=-1):
self.expdir =... | 146 | 4,091 |
so-vits-svc | pretrain/meta.py | .py | def download_dict():
return {
"vec768l12": {
"url": "https://ibm.ent.box.com/shared/static/z1wgl1stco8ffooyatzdwsqn2psd9lrr",
"output": "./pretrain/checkpoint_best_legacy_500.pt"
},
"vec256l9": {
"url": "https://ibm.ent.box.com/shared/static/z1wgl1stco8ffo... | 40 | 1,671 |
so-vits-svc | onnxexport/model_onnx_speaker_mix.py | .py | import torch
from torch import nn
from torch.nn import functional as F
import modules.attentions as attentions
import modules.commons as commons
import modules.modules as modules
import utils
from utils import f0_to_coarse
class ResidualCouplingBlock(nn.Module):
def __init__(self,
channels,
... | 367 | 13,830 |
so-vits-svc | onnxexport/model_onnx.py | .py | import torch
from torch import nn
from torch.nn import Conv1d, Conv2d
from torch.nn import functional as F
from torch.nn.utils import spectral_norm, weight_norm
import modules.attentions as attentions
import modules.commons as commons
import modules.modules as modules
import utils
from modules.commons import get_paddi... | 334 | 12,211 |
so-vits-svc | cluster/kmeans.py | .py | from time import time
import numpy as np
import pynvml
import torch
from torch.nn.functional import normalize
# device=torch.device("cuda:0")
def _kpp(data: torch.Tensor, k: int, sample_size: int = -1):
""" Picks k points in the data based on the kmeans++ method.
Parameters
----------
data : torch.T... | 205 | 7,842 |
so-vits-svc | cluster/__init__.py | .py | import torch
from sklearn.cluster import KMeans
def get_cluster_model(ckpt_path):
checkpoint = torch.load(ckpt_path)
kmeans_dict = {}
for spk, ckpt in checkpoint.items():
km = KMeans(ckpt["n_features_in_"])
km.__dict__["n_features_in_"] = ckpt["n_features_in_"]
km.__dict__["_n_thre... | 30 | 883 |
so-vits-svc | cluster/train_cluster.py | .py | import argparse
import logging
import os
import time
from pathlib import Path
import numpy as np
import torch
import tqdm
from kmeans import KMeansGPU
from sklearn.cluster import KMeans, MiniBatchKMeans
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def train_cluster(in_dir, n_clusters,... | 86 | 3,057 |
so-vits-svc | vencoder/WhisperPPGLarge.py | .py | import torch
from vencoder.encoder import SpeechEncoder
from vencoder.whisper.audio import log_mel_spectrogram, pad_or_trim
from vencoder.whisper.model import ModelDimensions, Whisper
class WhisperPPGLarge(SpeechEncoder):
def __init__(self, vec_path="pretrain/large-v2.pt", device=None):
super().__init__(... | 32 | 1,236 |
so-vits-svc | vencoder/DPHubert.py | .py | import torch
from vencoder.dphubert.model import wav2vec2_model
from vencoder.encoder import SpeechEncoder
class DPHubert(SpeechEncoder):
def __init__(self, vec_path="pretrain/DPHuBERT-sp0.75.pth", device=None):
super().__init__()
print("load model(s) from {}".format(vec_path))
if device ... | 30 | 1,041 |
so-vits-svc | vencoder/ContentVec256L9_Onnx.py | .py | import onnxruntime
import torch
from vencoder.encoder import SpeechEncoder
class ContentVec256L9_Onnx(SpeechEncoder):
def __init__(self, vec_path="pretrain/vec-256-layer-9.onnx", device=None):
super().__init__()
print("load model(s) from {}".format(vec_path))
self.hidden_dim = 256
... | 32 | 1,242 |
so-vits-svc | vencoder/HubertSoft_Onnx.py | .py | import onnxruntime
import torch
from vencoder.encoder import SpeechEncoder
class HubertSoft_Onnx(SpeechEncoder):
def __init__(self, vec_path="pretrain/hubert-soft.onnx", device=None):
super().__init__()
print("load model(s) from {}".format(vec_path))
self.hidden_dim = 256
if devic... | 34 | 1,176 |
so-vits-svc | vencoder/CNHubertLarge.py | .py | import torch
from fairseq import checkpoint_utils
from vencoder.encoder import SpeechEncoder
class CNHubertLarge(SpeechEncoder):
def __init__(self, vec_path="pretrain/chinese-hubert-large-fairseq-ckpt.pt", device=None):
super().__init__()
print("load model(s) from {}".format(vec_path))
se... | 36 | 1,245 |
so-vits-svc | vencoder/encoder.py | .py | class SpeechEncoder(object):
def __init__(self, vec_path="pretrain/checkpoint_best_legacy_500.pt", device=None):
self.model = None # This is Model
self.hidden_dim = 768
pass
def encoder(self, wav):
"""
input: wav:[signal_length]
output: embedding:[batchsize,hid... | 14 | 364 |
so-vits-svc | vencoder/WhisperPPG.py | .py | import torch
from vencoder.encoder import SpeechEncoder
from vencoder.whisper.audio import log_mel_spectrogram, pad_or_trim
from vencoder.whisper.model import ModelDimensions, Whisper
class WhisperPPG(SpeechEncoder):
def __init__(self, vec_path="pretrain/medium.pt", device=None):
super().__init__()
... | 32 | 1,198 |
so-vits-svc | vencoder/ContentVec768L12.py | .py | import torch
from fairseq import checkpoint_utils
from vencoder.encoder import SpeechEncoder
class ContentVec768L12(SpeechEncoder):
def __init__(self, vec_path="pretrain/checkpoint_best_legacy_500.pt", device=None):
super().__init__()
print("load model(s) from {}".format(vec_path))
self.h... | 38 | 1,284 |
so-vits-svc | vencoder/ContentVec768L9_Onnx.py | .py | import onnxruntime
import torch
from vencoder.encoder import SpeechEncoder
class ContentVec768L9_Onnx(SpeechEncoder):
def __init__(self,vec_path = "pretrain/vec-768-layer-9.onnx",device=None):
super().__init__()
print("load model(s) from {}".format(vec_path))
self.hidden_dim = 768
... | 34 | 1,185 |
so-vits-svc | vencoder/HubertSoft.py | .py | import torch
from vencoder.encoder import SpeechEncoder
from vencoder.hubert import hubert_model
class HubertSoft(SpeechEncoder):
def __init__(self, vec_path="pretrain/hubert-soft-0d54a1f4.pt", device=None):
super().__init__()
print("load model(s) from {}".format(vec_path))
hubert_soft = ... | 29 | 977 |
so-vits-svc | vencoder/ContentVec256L12_Onnx.py | .py | import onnxruntime
import torch
from vencoder.encoder import SpeechEncoder
class ContentVec256L12_Onnx(SpeechEncoder):
def __init__(self, vec_path="pretrain/vec-256-layer-12.onnx", device=None):
super().__init__()
print("load model(s) from {}".format(vec_path))
self.hidden_dim = 256
... | 34 | 1,175 |
so-vits-svc | vencoder/WavLMBasePlus.py | .py | import torch
from vencoder.encoder import SpeechEncoder
from vencoder.wavlm.WavLM import WavLM, WavLMConfig
class WavLMBasePlus(SpeechEncoder):
def __init__(self, vec_path="pretrain/WavLM-Base+.pt", device=None):
super().__init__()
print("load model(s) from {}".format(vec_path))
checkpoin... | 33 | 1,215 |
so-vits-svc | vencoder/ContentVec768L12_Onnx.py | .py | import onnxruntime
import torch
from vencoder.encoder import SpeechEncoder
class ContentVec768L12_Onnx(SpeechEncoder):
def __init__(self, vec_path="pretrain/vec-768-layer-12.onnx", device=None):
super().__init__()
print("load model(s) from {}".format(vec_path))
self.hidden_dim = 768
... | 34 | 1,187 |
so-vits-svc | vencoder/ContentVec256L9.py | .py | import torch
from fairseq import checkpoint_utils
from vencoder.encoder import SpeechEncoder
class ContentVec256L9(SpeechEncoder):
def __init__(self, vec_path="pretrain/checkpoint_best_legacy_500.pt", device=None):
super().__init__()
print("load model(s) from {}".format(vec_path))
models,... | 39 | 1,330 |
so-vits-svc | vencoder/wavlm/modules.py | .py | # --------------------------------------------------------
# WavLM: Large-Scale Self-Supervised Pre-training for Full Stack Speech Processing (https://arxiv.org/abs/2110.13900.pdf)
# Github source: https://github.com/microsoft/unilm/tree/master/wavlm
# Copyright (c) 2021 Microsoft
# Licensed under The MIT License [se... | 829 | 31,947 |
so-vits-svc | vencoder/wavlm/WavLM.py | .py | # --------------------------------------------------------
# WavLM: Large-Scale Self-Supervised Pre-training for Full Stack Speech Processing (https://arxiv.org/abs/2110.13900.pdf)
# Github source: https://github.com/microsoft/unilm/tree/master/wavlm
# Copyright (c) 2021 Microsoft
# Licensed under The MIT License [se... | 742 | 27,546 |
so-vits-svc | vencoder/hubert/hubert_model_onnx.py | .py | import copy
import random
from typing import Optional, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as t_func
from torch.nn.modules.utils import consume_prefix_in_state_dict_if_present
class Hubert(nn.Module):
def __init__(self, num_label_embeddings: int = 100, mask: bool = True):
... | 218 | 7,160 |
so-vits-svc | vencoder/hubert/hubert_model.py | .py | import copy
import random
from typing import Optional, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as t_func
from torch.nn.modules.utils import consume_prefix_in_state_dict_if_present
class Hubert(nn.Module):
def __init__(self, num_label_embeddings: int = 100, mask: bool = True):
... | 223 | 7,329 |
so-vits-svc | vencoder/dphubert/pruning_utils.py | .py | """Utility functions for pruning."""
from typing import Union
import torch
import torch.nn as nn
def prune_linear_layer(layer: nn.Linear, index: torch.LongTensor, dim: str):
"Prune linear layer in place."
# NOTE: weight: (out_features, in_features), bias: (out_features,)
if dim == "input":
dim =... | 52 | 1,869 |
so-vits-svc | vencoder/dphubert/hardconcrete.py | .py | """Implementation of the hard Concrete distribution.
Originally from:
https://github.com/asappresearch/flop/blob/master/flop/hardconcrete.py
"""
import math
import torch
import torch.nn as nn
class HardConcrete(nn.Module):
"""A HarcConcrete module.
Use this module to create a mask of size N, which you can... | 123 | 4,060 |
so-vits-svc | vencoder/dphubert/model.py | .py | """Speech SSL models supporting pruning.
Originally from:
https://github.com/pytorch/audio/blob/main/torchaudio/models/wav2vec2/model.py
"""
import math
from typing import List, Optional, Tuple
import torch
import torch.nn.functional as F
from torch import Tensor
from torch.nn import Module
from . import component... | 967 | 38,745 |
so-vits-svc | vencoder/dphubert/components.py | .py | """Building blocks for speech SSL models supporting pruning.
Originally from:
https://github.com/pytorch/audio/blob/main/torchaudio/models/wav2vec2/components.py
"""
import math
from collections import defaultdict
from typing import List, Optional, Tuple
import torch
from torch import Tensor, nn
from torch.nn impor... | 1,411 | 58,641 |
so-vits-svc | vencoder/dphubert/utils/import_huggingface_wavlm.py | .py | """Import Hugging Face transformers's wav2vec2.0 pretrained weights to torchaudios's format.
Originally from:
https://github.com/pytorch/audio/blob/main/torchaudio/models/wav2vec2/utils/import_huggingface.py
"""
import logging
from typing import Any, Dict
from torch.nn import Module
from ..model import Wav2Vec2Mod... | 130 | 5,564 |
so-vits-svc | vencoder/whisper/utils.py | .py | import json
import os
import sys
import zlib
from typing import Callable, TextIO
system_encoding = sys.getdefaultencoding()
if system_encoding != "utf-8":
def make_safe(string):
# replaces any character not representable using the system default encoding with an '?',
# avoiding UnicodeEncodeError ... | 164 | 5,226 |
so-vits-svc | vencoder/whisper/model.py | .py | from dataclasses import dataclass
from typing import Dict, Iterable, Optional
import numpy as np
import torch
import torch.nn.functional as F
from torch import Tensor, nn
from .decoding import decode as decode_function
from .decoding import detect_language as detect_language_function
@dataclass
class ModelDimension... | 269 | 9,661 |
so-vits-svc | vencoder/whisper/decoding.py | .py | from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Sequence, Tuple, Union
import numpy as np
import torch
import torch.nn.functional as F
from torch import Tensor
from torch.distributions import Categorical
from .audio import CHUNK_LENGTH
from .tokenizer import ... | 713 | 30,156 |
so-vits-svc | vencoder/whisper/audio.py | .py | from functools import lru_cache
from typing import Union
import ffmpeg
import numpy as np
import torch
import torch.nn.functional as F
from librosa.filters import mel as librosa_mel_fn
from .utils import exact_div
# hard-coded audio hyperparameters
SAMPLE_RATE = 16000
N_FFT = 400
N_MELS = 80
HOP_LENGTH = 160
CHUNK_L... | 124 | 4,062 |
so-vits-svc | vencoder/whisper/tokenizer.py | .py | import os
from dataclasses import dataclass
from functools import lru_cache
from typing import List, Optional, Tuple, Union
import numpy as np
import torch
from transformers import GPT2TokenizerFast
LANGUAGES = {
"en": "english",
"zh": "chinese",
"de": "german",
"es": "spanish",
"ru": "russian",
... | 332 | 9,836 |
so-vits-svc | inference/slicer.py | .py | import librosa
import torch
import torchaudio
class Slicer:
def __init__(self,
sr: int,
threshold: float = -40.,
min_length: int = 5000,
min_interval: int = 300,
hop_size: int = 20,
max_sil_kept: int = 5000):
... | 143 | 6,704 |
so-vits-svc | inference/infer_tool_grad.py | .py | import io
import logging
import os
import librosa
import numpy as np
import parselmouth
import soundfile
import torch
import torchaudio
import utils
from inference import slicer
from models import SynthesizerTrn
logging.getLogger('numba').setLevel(logging.WARNING)
logging.getLogger('matplotlib').setLevel(logging.WAR... | 157 | 5,574 |
so-vits-svc | inference/infer_tool.py | .py | import gc
import hashlib
import io
import json
import logging
import os
import pickle
import time
from pathlib import Path
import librosa
import numpy as np
# import onnxruntime
import soundfile
import torch
import torchaudio
import cluster
import utils
from diffusion.unit2mel import load_model_vocoder
from inferenc... | 547 | 25,169 |
so-vits-svc | modules/commons.py | .py | import math
import torch
from torch.nn import functional as F
def slice_pitch_segments(x, ids_str, segment_size=4):
ret = torch.zeros_like(x[:, :segment_size])
for i in range(x.size(0)):
idx_str = ids_str[i]
idx_end = idx_str + segment_size
ret[i] = x[i, idx_str:idx_end]
return ret
def rand_slice_... | 184 | 5,696 |
so-vits-svc | modules/DSConv.py | .py | import torch.nn as nn
from torch.nn.utils import remove_weight_norm, weight_norm
class Depthwise_Separable_Conv1D(nn.Module):
def __init__(
self,
in_channels,
out_channels,
kernel_size,
stride = 1,
padding = 0,
dilation = 1,
bias = True,
padd... | 76 | 3,010 |
so-vits-svc | modules/losses.py | .py | import torch
def feature_loss(fmap_r, fmap_g):
loss = 0
for dr, dg in zip(fmap_r, fmap_g):
for rl, gl in zip(dr, dg):
rl = rl.float().detach()
gl = gl.float()
loss += torch.mean(torch.abs(rl - gl))
return loss * 2
def discriminator_loss(disc_real_outputs, disc_generated_outputs):
los... | 59 | 1,276 |
so-vits-svc | modules/attentions.py | .py | import math
import torch
from torch import nn
from torch.nn import functional as F
import modules.commons as commons
from modules.DSConv import weight_norm_modules
from modules.modules import LayerNorm
class FFT(nn.Module):
def __init__(self, hidden_channels, filter_channels, n_heads, n_layers=1, kernel_size=1, p... | 364 | 14,178 |
so-vits-svc | modules/mel_processing.py | .py | import torch
import torch.utils.data
from librosa.filters import mel as librosa_mel_fn
MAX_WAV_VALUE = 32768.0
def dynamic_range_compression_torch(x, C=1, clip_val=1e-5):
"""
PARAMS
------
C: compression factor
"""
return torch.log(torch.clamp(x, min=clip_val) * C)
def dynamic_range_decompr... | 84 | 2,685 |
so-vits-svc | modules/modules.py | .py | import torch
from torch import nn
from torch.nn import functional as F
import modules.attentions as attentions
import modules.commons as commons
from modules.commons import get_padding, init_weights
from modules.DSConv import (
Depthwise_Separable_Conv1D,
remove_weight_norm_modules,
weight_norm_modules,
)
... | 357 | 12,197 |
so-vits-svc | modules/enhancer.py | .py | import numpy as np
import torch
import torch.nn.functional as F
from torchaudio.transforms import Resample
from vdecoder.nsf_hifigan.models import load_model
from vdecoder.nsf_hifigan.nvSTFT import STFT
class Enhancer:
def __init__(self, enhancer_type, enhancer_ckpt, device=None):
if device is None:
... | 107 | 4,356 |
so-vits-svc | modules/F0Predictor/FCPEF0Predictor.py | .py | from typing import Union
import numpy as np
import torch
import torch.nn.functional as F
from modules.F0Predictor.F0Predictor import F0Predictor
from .fcpe.model import FCPEInfer
class FCPEF0Predictor(F0Predictor):
def __init__(self, hop_length=512, f0_min=50, f0_max=1100, dtype=torch.float32, device=None, sam... | 109 | 4,113 |
so-vits-svc | modules/F0Predictor/HarvestF0Predictor.py | .py | import numpy as np
import pyworld
from modules.F0Predictor.F0Predictor import F0Predictor
class HarvestF0Predictor(F0Predictor):
def __init__(self,hop_length=512,f0_min=50,f0_max=1100,sampling_rate=44100):
self.hop_length = hop_length
self.f0_min = f0_min
self.f0_max = f0_max
self... | 70 | 2,524 |
so-vits-svc | modules/F0Predictor/crepe.py | .py | from typing import Optional, Union
try:
from typing import Literal
except Exception:
from typing_extensions import Literal
import numpy as np
import torch
import torchcrepe
from torch import nn
from torch.nn import functional as F
#from:https://github.com/fishaudio/fish-diffusion
def repeat_expand(
conte... | 341 | 11,377 |
so-vits-svc | modules/F0Predictor/DioF0Predictor.py | .py | import numpy as np
import pyworld
from modules.F0Predictor.F0Predictor import F0Predictor
class DioF0Predictor(F0Predictor):
def __init__(self,hop_length=512,f0_min=50,f0_max=1100,sampling_rate=44100):
self.hop_length = hop_length
self.f0_min = f0_min
self.f0_max = f0_max
self.sam... | 75 | 2,665 |
so-vits-svc | modules/F0Predictor/F0Predictor.py | .py | class F0Predictor(object):
def compute_f0(self,wav,p_len):
'''
input: wav:[signal_length]
p_len:int
output: f0:[signal_length//hop_length]
'''
pass
def compute_f0_uv(self,wav,p_len):
'''
input: wav:[signal_length]
p_len:int
... | 16 | 421 |
so-vits-svc | modules/F0Predictor/PMF0Predictor.py | .py | import numpy as np
import parselmouth
from modules.F0Predictor.F0Predictor import F0Predictor
class PMF0Predictor(F0Predictor):
def __init__(self,hop_length=512,f0_min=50,f0_max=1100,sampling_rate=44100):
self.hop_length = hop_length
self.f0_min = f0_min
self.f0_max = f0_max
self.... | 73 | 2,717 |
so-vits-svc | modules/F0Predictor/CrepeF0Predictor.py | .py | import torch
from modules.F0Predictor.crepe import CrepePitchExtractor
from modules.F0Predictor.F0Predictor import F0Predictor
class CrepeF0Predictor(F0Predictor):
def __init__(self,hop_length=512,f0_min=50,f0_max=1100,device=None,sampling_rate=44100,threshold=0.05,model="full"):
self.F0Creper = CrepePit... | 34 | 1,392 |
so-vits-svc | modules/F0Predictor/RMVPEF0Predictor.py | .py | from typing import Union
import numpy as np
import torch
import torch.nn.functional as F
from modules.F0Predictor.F0Predictor import F0Predictor
from .rmvpe import RMVPE
class RMVPEF0Predictor(F0Predictor):
def __init__(self,hop_length=512,f0_min=50,f0_max=1100, dtype=torch.float32, device=None,sampling_rate=4... | 107 | 3,953 |
so-vits-svc | modules/F0Predictor/rmvpe/inference.py | .py | import torch
import torch.nn.functional as F
from torchaudio.transforms import Resample
from .constants import * # noqa: F403
from .model import E2E0
from .spec import MelSpectrogram
from .utils import to_local_average_cents, to_viterbi_cents
class RMVPE:
def __init__(self, model_path, device=None, dtype = torc... | 58 | 2,478 |
so-vits-svc | modules/F0Predictor/rmvpe/utils.py | .py | import sys
from functools import reduce
import librosa
import numpy as np
import torch
from torch.nn.modules.module import _addindent
from .constants import * # noqa: F403
def cycle(iterable):
while True:
for item in iterable:
yield item
def summary(model, file=sys.stdout):
def repr(m... | 107 | 3,716 |
so-vits-svc | modules/F0Predictor/rmvpe/model.py | .py | from torch import nn
from .constants import * # noqa: F403
from .deepunet import DeepUnet, DeepUnet0
from .seq import BiGRU
from .spec import MelSpectrogram
class E2E(nn.Module):
def __init__(self, hop_length, n_blocks, n_gru, kernel_size, en_de_layers=5, inter_layers=4, in_channels=1,
en_out_c... | 68 | 2,538 |
so-vits-svc | modules/F0Predictor/rmvpe/__init__.py | .py | from .constants import * # noqa: F403
from .inference import RMVPE # noqa: F401
from .model import E2E, E2E0 # noqa: F401
from .spec import MelSpectrogram # noqa: F401
from .utils import ( # noqa: F401
cycle,
summary,
to_local_average_cents,
to_viterbi_cents,
)
| 11 | 283 |
so-vits-svc | modules/F0Predictor/rmvpe/constants.py | .py | SAMPLE_RATE = 16000
N_CLASS = 360
N_MELS = 128
MEL_FMIN = 30
MEL_FMAX = SAMPLE_RATE // 2
WINDOW_LENGTH = 1024
CONST = 1997.3794084376191
| 10 | 139 |
so-vits-svc | modules/F0Predictor/rmvpe/spec.py | .py | import numpy as np
import torch
import torch.nn.functional as F
from librosa.filters import mel
class MelSpectrogram(torch.nn.Module):
def __init__(
self,
n_mel_channels,
sampling_rate,
win_length,
hop_length,
n_fft=None,
mel_fmin=0,
mel_fmax=None,
... | 67 | 2,329 |
so-vits-svc | modules/F0Predictor/rmvpe/seq.py | .py | import torch.nn as nn
class BiGRU(nn.Module):
def __init__(self, input_features, hidden_features, num_layers):
super(BiGRU, self).__init__()
self.gru = nn.GRU(input_features, hidden_features, num_layers=num_layers, batch_first=True, bidirectional=True)
def forward(self, x):
return sel... | 21 | 648 |
so-vits-svc | modules/F0Predictor/rmvpe/deepunet.py | .py | import torch
import torch.nn as nn
from .constants import N_MELS
class ConvBlockRes(nn.Module):
def __init__(self, in_channels, out_channels, momentum=0.01):
super(ConvBlockRes, self).__init__()
self.conv = nn.Sequential(
nn.Conv2d(in_channels=in_channels,
out_ch... | 191 | 7,429 |
so-vits-svc | modules/F0Predictor/fcpe/nvSTFT.py | .py | import os
import librosa
import numpy as np
import soundfile as sf
import torch
import torch.nn.functional as F
import torch.utils.data
from librosa.filters import mel as librosa_mel_fn
os.environ["LRU_CACHE_CAPACITY"] = "3"
def load_wav_to_torch(full_path, target_sr=None, return_empty_on_exception=False):
sampl... | 134 | 5,443 |
so-vits-svc | modules/F0Predictor/fcpe/model.py | .py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.utils import weight_norm
from torchaudio.transforms import Resample
from .nvSTFT import STFT
from .pcmer import PCmer
def l2_regularization(model, l2_alpha):
l2_loss = []
for module in model.modules():
... | 263 | 10,524 |
so-vits-svc | modules/F0Predictor/fcpe/pcmer.py | .py | import math
from functools import partial
import torch
import torch.nn.functional as F
from einops import rearrange, repeat
from local_attention import LocalAttention
from torch import nn
#import fast_transformers.causal_product.causal_product_cuda
def softmax_kernel(data, *, projection_matrix, is_query, normalize_d... | 369 | 13,862 |
so-vits-svc | edgetts/tts_voices.py | .py | #List of Supported Voices for edge_TTS
SUPPORTED_VOICES = {
'zh-CN-XiaoxiaoNeural': 'zh-CN',
'zh-CN-XiaoyiNeural': 'zh-CN',
'zh-CN-YunjianNeural': 'zh-CN',
'zh-CN-YunxiNeural': 'zh-CN',
'zh-CN-YunxiaNeural': 'zh-CN',
'zh-CN-YunyangNeural': 'zh-CN',
'zh-HK-HiuGaaiNeural': 'zh-HK',
'zh-HK-... | 306 | 10,773 |
so-vits-svc | edgetts/tts.py | .py | import asyncio
import random
import sys
import edge_tts
from edge_tts import VoicesManager
from langdetect import DetectorFactory, detect
DetectorFactory.seed = 0
TEXT = sys.argv[1]
LANG = detect(TEXT) if sys.argv[2] == "Auto" else sys.argv[2]
RATE = sys.argv[3]
VOLUME = sys.argv[4]
GENDER = sys.argv[5] if len(sys.a... | 48 | 1,524 |
ArchiveBox | pdm_build.py | .py | from __future__ import annotations
import re
import subprocess
from pathlib import Path
from pdm.backend.hooks import Context
def _current_commit(root: Path) -> str | None:
try:
result = subprocess.run(
["git", "-C", str(root), "rev-parse", "HEAD"],
check=True,
captur... | 34 | 944 |
ArchiveBox | bin/benchmark_db_backends.py | .py | #!/usr/bin/env python3
"""Benchmark ArchiveBox hot-path index queries at large row counts.
Run from inside an initialized (empty) collection directory, with the same
ARCHIVEBOX_DATABASE_* env vars the collection was initialized with:
cd /path/to/collection
uv run --project /path/to/ArchiveBox python /path/to/... | 203 | 8,246 |
ArchiveBox | bin/generate_ui_screenshot_gallery.py | .py | #!/usr/bin/env python3
import hashlib
import html
import json
import os
import struct
import sys
from pathlib import Path
from urllib.parse import urlparse
SOURCE_BASE_URL = "https://github.com/ArchiveBox/ArchiveBox/blob/dev/"
CAPTURE_PROFILES = {
"desktop": (1600, 1000),
"tablet": (1024, 1366),
"mobile":... | 264 | 10,823 |
ArchiveBox | archivebox/manage.py | .py | #!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
# if you're a developer working on archivebox, still prefer the archivebox
# versions of ./manage.py commands whenever possible. When that's not possible
# (e.g. makemigrations), you can comment out this check temporarily
allowed_co... | 32 | 1,556 |
ArchiveBox | archivebox/__main__.py | .py | #!/usr/bin/env python3
"""This is the entrypoint for python -m archivebox ..."""
__package__ = "archivebox"
import archivebox # noqa # make sure monkey patches are applied before anything else
import sys
from .cli import main
ASCII_LOGO_MINI = r"""
_ _ _ ____
/ \ _ __ ___| |__ ... | 21 | 571 |
ArchiveBox | archivebox/__init__.py | .py | #!/usr/bin/env python3
# Welcome to the ArchiveBox source code! Thanks for checking it out!
#
# "We are swimming upstream against a great torrent of disorganization.
# In this, our main obligation is to establish arbitrary enclaves of order and system.
# It is the greatest possible victory to be, to continue to be, an... | 151 | 10,833 |
ArchiveBox | archivebox/uuid_compat.py | .py | """UUID7 compatibility layer."""
import sys
import uuid
from importlib import import_module
from django.db import models
if sys.version_info >= (3, 14):
_UUID7_GENERATOR = getattr(uuid, "uuid7")
else:
_UUID7_GENERATOR = getattr(import_module("uuid_extensions"), "uuid7")
class CompactUUID(uuid.UUID):
de... | 49 | 1,228 |
ArchiveBox | archivebox/progressmonitor/apps.py | .py | __package__ = "archivebox.progressmonitor"
from django.apps import AppConfig
class ProgressMonitorConfig(AppConfig):
name = "archivebox.progressmonitor"
label = "progressmonitor"
| 9 | 190 |
ArchiveBox | archivebox/progressmonitor/views.py | .py | __package__ = "archivebox.progressmonitor"
from functools import lru_cache
from pathlib import Path
from typing import Literal
from abx_dl.events import PROCESS_EXIT_SKIPPED
from django.conf import settings
from django.db import DatabaseError
from django.db.models import CharField, Count, Q, Sum
from django.db.models... | 971 | 50,046 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.