index
int64
0
50.7k
project_path
stringclasses
279 values
completion_path
stringlengths
57
199
signature_postion
stringlengths
3
11
class_position
stringlengths
3
11
function_name
stringlengths
1
62
class_name
stringlengths
0
55
body_position
stringlengths
3
11
body_position_with_comments
stringlengths
3
11
masked_class
stringlengths
14
8.32k
masked_class_with_comment
stringlengths
14
8.32k
func_body
stringlengths
9
6.72k
func_body_with_comment
stringlengths
9
6.72k
len_func_body
int64
1
643
len_input
int64
10
2.02k
len_output
int64
4
1.9k
total
int64
20
2.05k
file_code
stringlengths
14
442k
file_code_with_comment
stringlengths
14
442k
25,126
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika/src/llm/ollama_client.py
19,20
8,26
inference
Ollama
20,26
20,26
class Ollama: def __init__(self): try: self.client = ollama.Client(Config().get_ollama_api_endpoint()) self.models = self.client.list()["models"] log.info("Ollama available") except: self.client = None log.warning("Ollama not available") ...
class Ollama: def __init__(self): try: self.client = ollama.Client(Config().get_ollama_api_endpoint()) self.models = self.client.list()["models"] log.info("Ollama available") except: self.client = None log.warning("Ollama not available") ...
response = self.client.generate( model=model_id, prompt=prompt.strip(), options={"temperature": 0} ) return response['response']
response = self.client.generate( model=model_id, prompt=prompt.strip(), options={"temperature": 0} ) return response['response']
10
145
53
198
import ollama from src.logger import Logger from src.config import Config log = Logger() class Ollama: def __init__(self): try: self.client = ollama.Client(Config().get_ollama_api_endpoint()) self.models = self.client.list()["models"] log.info("Ollama available") ...
import ollama from src.logger import Logger from src.config import Config log = Logger() class Ollama: def __init__(self): try: self.client = ollama.Client(Config().get_ollama_api_endpoint()) self.models = self.client.list()["models"] log.info("Ollama available") ...
25,127
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika/src/llm/openai_client.py
13,14
6,25
inference
OpenAi
14,25
14,25
class OpenAi: def __init__(self): config = Config() api_key = config.get_openai_api_key() base_url = config.get_openai_api_base_url() self.client = OpenAI(api_key=api_key, base_url=base_url) def inference(self, model_id: str, prompt: str) -> str: FILL_FUNC_BODY
class OpenAi: def __init__(self): config = Config() api_key = config.get_openai_api_key() base_url = config.get_openai_api_base_url() self.client = OpenAI(api_key=api_key, base_url=base_url) def inference(self, model_id: str, prompt: str) -> str: FILL_FUNC_BODY
chat_completion = self.client.chat.completions.create( messages=[ { "role": "user", "content": prompt.strip(), } ], model=model_id, temperature=0 ) return chat_completion.choic...
chat_completion = self.client.chat.completions.create( messages=[ { "role": "user", "content": prompt.strip(), } ], model=model_id, temperature=0 ) return chat_completion.choic...
16
113
93
206
from openai import OpenAI from src.config import Config class OpenAi: def __init__(self): config = Config() api_key = config.get_openai_api_key() base_url = config.get_openai_api_base_url() self.client = OpenAI(api_key=api_key, base_url=base_url) def inference(self, model_id:...
from openai import OpenAI from src.config import Config class OpenAi: def __init__(self): config = Config() api_key = config.get_openai_api_key() base_url = config.get_openai_api_base_url() self.client = OpenAI(api_key=api_key, base_url=base_url) def inference(self, model_id:...
25,128
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika/src/logger.py
40,41
1,79
route_logger
47,79
41,79
from functools import wraps from fastlogging import LogInit from flask import request from src.config import Config class Logger: def __init__(self, filename="devika_agent.log"): config = Config() logs_dir = config.get_logs_dir() self.logger = LogInit(pathName=logs_dir + "/" + filename, ...
from functools import wraps from fastlogging import LogInit from flask import request from src.config import Config class Logger: def __init__(self, filename="devika_agent.log"): config = Config() logs_dir = config.get_logs_dir() self.logger = LogInit(pathName=logs_dir + "/" + filename, ...
log_enabled = Config().get_logging_rest_api() def decorator(func): @wraps(func) def wrapper(*args, **kwargs): # Log entry point if log_enabled: logger.info(f"{request.path} {request.method}") # Call the actual route function res...
""" Decorator factory that creates a decorator to log route entry and exit points. The decorator uses the provided logger to log the information. :param logger: The logger instance to use for logging. """ log_enabled = Config().get_logging_rest_api() def decorator(func): @wraps(f...
89
381
330
711
from functools import wraps from fastlogging import LogInit from flask import request from src.config import Config class Logger: def __init__(self, filename="devika_agent.log"): config = Config() logs_dir = config.get_logs_dir() self.logger = LogInit(pathName=logs_dir + "/" + filename, ...
from functools import wraps from fastlogging import LogInit from flask import request from src.config import Config class Logger: def __init__(self, filename="devika_agent.log"): config = Config() logs_dir = config.get_logs_dir() self.logger = LogInit(pathName=logs_dir + "/" + filename, ...
25,129
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika/src/logger.py
15,16
9,40
read_log_file
Logger
16,19
16,19
class Logger: def __init__(self, filename="devika_agent.log"): config = Config() logs_dir = config.get_logs_dir() self.logger = LogInit(pathName=logs_dir + "/" + filename, console=True, colors=True, encoding="utf-8") def read_log_file(self) -> str: FILL_FUNC_BODY def info(self, messa...
class Logger: def __init__(self, filename="devika_agent.log"): config = Config() logs_dir = config.get_logs_dir() self.logger = LogInit(pathName=logs_dir + "/" + filename, console=True, colors=True, encoding="utf-8") def read_log_file(self) -> str: FILL_FUNC_BODY def info(self, messa...
with open(self.logger.pathName, "r") as file: return file.read()
with open(self.logger.pathName, "r") as file: return file.read()
7
259
29
288
from functools import wraps from fastlogging import LogInit from flask import request from src.config import Config class Logger: def __init__(self, filename="devika_agent.log"): config = Config() logs_dir = config.get_logs_dir() self.logger = LogInit(pathName=logs_dir + "/" + filename, ...
from functools import wraps from fastlogging import LogInit from flask import request from src.config import Config class Logger: def __init__(self, filename="devika_agent.log"): config = Config() logs_dir = config.get_logs_dir() self.logger = LogInit(pathName=logs_dir + "/" + filename, ...
25,130
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika/src/memory/knowledge_base.py
22,23
15,34
add_knowledge
KnowledgeBase
23,28
23,28
class KnowledgeBase: def __init__(self): config = Config() sqlite_path = config.get_sqlite_db() self.engine = create_engine(f"sqlite:///{sqlite_path}") SQLModel.metadata.create_all(self.engine) def add_knowledge(self, tag: str, contents: str): FILL_FUNC_BODY def get_knowledge...
class KnowledgeBase: def __init__(self): config = Config() sqlite_path = config.get_sqlite_db() self.engine = create_engine(f"sqlite:///{sqlite_path}") SQLModel.metadata.create_all(self.engine) def add_knowledge(self, tag: str, contents: str): FILL_FUNC_BODY def get_knowledge...
knowledge = Knowledge(tag=tag, contents=contents) with Session(self.engine) as session: session.add(knowledge) session.commit()
knowledge = Knowledge(tag=tag, contents=contents) with Session(self.engine) as session: session.add(knowledge) session.commit()
10
168
48
216
from typing import Optional from sqlmodel import Field, Session, SQLModel, create_engine from src.config import Config """ TODO: The tag check should be a BM25 search, it's just a simple equality check now. """ class Knowledge(SQLModel, table=True): id: Optional[int] = Field(default=None, primary_key=True) t...
from typing import Optional from sqlmodel import Field, Session, SQLModel, create_engine from src.config import Config """ TODO: The tag check should be a BM25 search, it's just a simple equality check now. """ class Knowledge(SQLModel, table=True): id: Optional[int] = Field(default=None, primary_key=True) t...
25,131
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika/src/project.py
40,41
17,147
delete_project
ProjectManager
41,47
41,47
class ProjectManager: def __init__(self): config = Config() sqlite_path = config.get_sqlite_db() self.project_path = config.get_projects_dir() self.engine = create_engine(f"sqlite:///{sqlite_path}") SQLModel.metadata.create_all(self.engine) def new_message(self): ...
class ProjectManager: def __init__(self): config = Config() sqlite_path = config.get_sqlite_db() self.project_path = config.get_projects_dir() self.engine = create_engine(f"sqlite:///{sqlite_path}") SQLModel.metadata.create_all(self.engine) def new_message(self): ...
with Session(self.engine) as session: project_state = session.query(Projects).filter(Projects.project == project).first() if project_state: session.delete(project_state) session.commit()
with Session(self.engine) as session: project_state = session.query(Projects).filter(Projects.project == project).first() if project_state: session.delete(project_state) session.commit()
13
1,480
66
1,546
import os import json import zipfile from datetime import datetime from typing import Optional from src.socket_instance import emit_agent from sqlmodel import Field, Session, SQLModel, create_engine from src.config import Config class Projects(SQLModel, table=True): id: Optional[int] = Field(default=None, primary...
import os import json import zipfile from datetime import datetime from typing import Optional from src.socket_instance import emit_agent from sqlmodel import Field, Session, SQLModel, create_engine from src.config import Config class Projects(SQLModel, table=True): id: Optional[int] = Field(default=None, primary...
25,132
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika/src/services/git.py
13,14
3,21
get_commits
Git
14,16
14,16
class Git: def __init__(self, path): self.repo = GitPython.Repo(path) def clone(self, url, path): return GitPython.Repo.clone_from(url, path) def get_branches(self): return self.repo.branches def get_commits(self, branch): FILL_FUNC_BODY def get_commit(self, commit): ...
class Git: def __init__(self, path): self.repo = GitPython.Repo(path) def clone(self, url, path): return GitPython.Repo.clone_from(url, path) def get_branches(self): return self.repo.branches def get_commits(self, branch): FILL_FUNC_BODY def get_commit(self, commit): ...
return self.repo.iter_commits(branch)
return self.repo.iter_commits(branch)
2
157
17
174
import git as GitPython class Git: def __init__(self, path): self.repo = GitPython.Repo(path) def clone(self, url, path): return GitPython.Repo.clone_from(url, path) def get_branches(self): return self.repo.branches def get_commits(self, branch): FILL_FUNC_BODY def get_com...
import git as GitPython class Git: def __init__(self, path): self.repo = GitPython.Repo(path) def clone(self, url, path): return GitPython.Repo.clone_from(url, path) def get_branches(self): return self.repo.branches def get_commits(self, branch): FILL_FUNC_BODY def get_com...
25,133
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika/src/services/github.py
9,10
5,16
get_repositories
GitHub
10,16
10,16
class GitHub: def __init__(self, token: str) -> None: self.token = token def get_repositories(self) -> List[str]: FILL_FUNC_BODY
class GitHub: def __init__(self, token: str) -> None: self.token = token def get_repositories(self) -> List[str]: FILL_FUNC_BODY
headers = {"Authorization": f"token {self.token}"} response = requests.get( "https://api.github.com/user/repos", headers=headers ) response.raise_for_status() return [repo["full_name"] for repo in response.json()]
headers = {"Authorization": f"token {self.token}"} response = requests.get( "https://api.github.com/user/repos", headers=headers ) response.raise_for_status() return [repo["full_name"] for repo in response.json()]
18
56
80
136
import requests from typing import List class GitHub: def __init__(self, token: str) -> None: self.token = token def get_repositories(self) -> List[str]: FILL_FUNC_BODY
import requests from typing import List class GitHub: def __init__(self, token: str) -> None: self.token = token def get_repositories(self) -> List[str]: FILL_FUNC_BODY
25,134
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika/src/services/utils.py
32,33
1,91
validate_responses
33,91
33,91
# create wrapper function that will has retry logic of 5 times import sys import time from functools import wraps import json from src.socket_instance import emit_agent def retry_wrapper(func): def wrapper(*args, **kwargs): max_tries = 5 tries = 0 while tries < max_tries: resul...
# create wrapper function that will has retry logic of 5 times import sys import time from functools import wraps import json from src.socket_instance import emit_agent def retry_wrapper(func): def wrapper(*args, **kwargs): max_tries = 5 tries = 0 while tries < max_tries: resul...
@wraps(func) def wrapper(*args, **kwargs): args = list(args) response = args[1] response = response.strip() try: response = json.loads(response) print("first", type(response)) args[1] = response return func(*args, **kwargs) ...
@wraps(func) def wrapper(*args, **kwargs): args = list(args) response = args[1] response = response.strip() try: response = json.loads(response) print("first", type(response)) args[1] = response return func(*args, **kwargs) ...
134
259
509
768
# create wrapper function that will has retry logic of 5 times import sys import time from functools import wraps import json from src.socket_instance import emit_agent def retry_wrapper(func): def wrapper(*args, **kwargs): max_tries = 5 tries = 0 while tries < max_tries: resul...
# create wrapper function that will has retry logic of 5 times import sys import time from functools import wraps import json from src.socket_instance import emit_agent def retry_wrapper(func): def wrapper(*args, **kwargs): max_tries = 5 tries = 0 while tries < max_tries: resul...
25,135
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika
/home/hieuvd/dung_repo/raw/stars_01/stitionai_devika/devika/src/socket_instance.py
9,10
1,18
emit_agent
10,18
10,18
# socketio_instance.py from flask_socketio import SocketIO from src.logger import Logger socketio = SocketIO(cors_allowed_origins="*", async_mode="gevent") logger = Logger() def emit_agent(channel, content, log=True): FILL_FUNC_BODY
# socketio_instance.py from flask_socketio import SocketIO from src.logger import Logger socketio = SocketIO(cors_allowed_origins="*", async_mode="gevent") logger = Logger() def emit_agent(channel, content, log=True): FILL_FUNC_BODY
try: socketio.emit(channel, content) if log: logger.info(f"SOCKET {channel} MESSAGE: {content}") return True except Exception as e: logger.error(f"SOCKET {channel} ERROR: {str(e)}") return False
try: socketio.emit(channel, content) if log: logger.info(f"SOCKET {channel} MESSAGE: {content}") return True except Exception as e: logger.error(f"SOCKET {channel} ERROR: {str(e)}") return False
21
87
87
174
# socketio_instance.py from flask_socketio import SocketIO from src.logger import Logger socketio = SocketIO(cors_allowed_origins="*", async_mode="gevent") logger = Logger() def emit_agent(channel, content, log=True): FILL_FUNC_BODY
# socketio_instance.py from flask_socketio import SocketIO from src.logger import Logger socketio = SocketIO(cors_allowed_origins="*", async_mode="gevent") logger = Logger() def emit_agent(channel, content, log=True): FILL_FUNC_BODY
25,137
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/data_utils.py
94,95
18,131
random_slice
TextAudioSpeakerLoader
95,121
95,121
class TextAudioSpeakerLoader(torch.utils.data.Dataset): """ 1) loads audio, speaker_id, text pairs 2) normalizes text and converts them to sequences of integers 3) computes spectrograms from audio files. """ def __init__(self, audiopaths, hparams, all_in_mem: bool = False, vol_aug: ...
class TextAudioSpeakerLoader(torch.utils.data.Dataset): """ 1) loads audio, speaker_id, text pairs 2) normalizes text and converts them to sequences of integers 3) computes spectrograms from audio files. """ def __init__(self, audiopaths, hparams, all_in_mem: bool = False, vol_aug: ...
# if spec.shape[1] < 30: # print("skip too short audio:", filename) # return None if random.choice([True, False]) and self.vol_aug and volume is not None: max_amp = float(torch.max(torch.abs(audio_norm))) + 1e-5 max_shift = min(1, np.log10(1/max_amp)) ...
# if spec.shape[1] < 30: # print("skip too short audio:", filename) # return None if random.choice([True, False]) and self.vol_aug and volume is not None: max_amp = float(torch.max(torch.abs(audio_norm))) + 1e-5 max_shift = min(1, np.log10(1/max_amp)) ...
108
1,256
420
1,676
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): """ ...
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): """ ...
25,138
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/diffusion/infer_gt_mel.py
58,60
7,75
infer
DiffGtMel
60,75
60,75
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 = 'cuda' if torch.cuda.is_available() else 'cpu' self.model = None self.vocoder = None ...
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 = 'cuda' if torch.cuda.is_available() else 'cpu' self.model = None self.vocoder = None ...
start_frame = int(silence_front * self.vocoder.vocoder_sample_rate / self.vocoder.vocoder_hop_size) if use_silence: audio = audio[:, start_frame * self.vocoder.vocoder_hop_size:] f0 = f0[:, start_frame:, :] hubert = hubert[:, start_frame:, :] volume = volu...
start_frame = int(silence_front * self.vocoder.vocoder_sample_rate / self.vocoder.vocoder_hop_size) if use_silence: audio = audio[:, start_frame * self.vocoder.vocoder_hop_size:] f0 = f0[:, start_frame:, :] hubert = hubert[:, start_frame:, :] volume = volu...
64
734
279
1,013
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...
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...
25,139
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/diffusion/logger/saver.py
47,48
15,146
log_info
Saver
49,70
48,70
class Saver(object): def __init__( self, args, initial_global_step=-1): self.expdir = args.env.expdir self.sample_rate = args.data.sampling_rate # cold start self.global_step = initial_global_step self.init_time = time.time() ...
class Saver(object): def __init__( self, args, initial_global_step=-1): self.expdir = args.env.expdir self.sample_rate = args.data.sampling_rate # cold start self.global_step = initial_global_step self.init_time = time.time() ...
if isinstance(msg, dict): msg_list = [] for k, v in msg.items(): tmp_str = '' if isinstance(v, int): tmp_str = '{}: {:,}'.format(k, v) else: tmp_str = '{}: {}'.format(k, v) msg_list.a...
'''log method''' if isinstance(msg, dict): msg_list = [] for k, v in msg.items(): tmp_str = '' if isinstance(v, int): tmp_str = '{}: {:,}'.format(k, v) else: tmp_str = '{}: {}'.format(k, v) ...
47
1,092
201
1,293
''' 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 =...
''' 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 =...
25,141
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/diffusion/wavenet.py
46,47
31,64
forward
ResidualBlock
47,64
47,64
class ResidualBlock(nn.Module): def __init__(self, encoder_hidden, residual_channels, dilation): super().__init__() self.residual_channels = residual_channels self.dilated_conv = nn.Conv1d( residual_channels, 2 * residual_channels, kernel_size=3, ...
class ResidualBlock(nn.Module): def __init__(self, encoder_hidden, residual_channels, dilation): super().__init__() self.residual_channels = residual_channels self.dilated_conv = nn.Conv1d( residual_channels, 2 * residual_channels, kernel_size=3, ...
diffusion_step = self.diffusion_projection(diffusion_step).unsqueeze(-1) conditioner = self.conditioner_projection(conditioner) y = x + diffusion_step y = self.dilated_conv(y) + conditioner # Using torch.split instead of torch.chunk to avoid using onnx::Slice gate, filt...
diffusion_step = self.diffusion_projection(diffusion_step).unsqueeze(-1) conditioner = self.conditioner_projection(conditioner) y = x + diffusion_step y = self.dilated_conv(y) + conditioner # Using torch.split instead of torch.chunk to avoid using onnx::Slice gate, filt...
65
232
260
492
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...
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...
25,142
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/diffusion/wavenet.py
21,22
16,31
forward
SinusoidalPosEmb
22,31
22,31
class SinusoidalPosEmb(nn.Module): def __init__(self, dim): super().__init__() self.dim = dim def forward(self, x): FILL_FUNC_BODY
class SinusoidalPosEmb(nn.Module): def __init__(self, dim): super().__init__() self.dim = dim def forward(self, x): FILL_FUNC_BODY
device = x.device half_dim = self.dim // 2 emb = math.log(10000) / (half_dim - 1) emb = torch.exp(torch.arange(half_dim, device=device) * -emb) emb = x[:, None] * emb[None, :] emb = torch.cat((emb.sin(), emb.cos()), dim=-1) return emb
device = x.device half_dim = self.dim // 2 emb = math.log(10000) / (half_dim - 1) emb = torch.exp(torch.arange(half_dim, device=device) * -emb) emb = x[:, None] * emb[None, :] emb = torch.cat((emb.sin(), emb.cos()), dim=-1) return emb
35
58
122
180
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...
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...
25,143
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/diffusion/wavenet.py
86,87
64,109
forward
WaveNet
93,109
87,109
class WaveNet(nn.Module): def __init__(self, in_dims=128, n_layers=20, n_chans=384, n_hidden=256): super().__init__() self.input_projection = Conv1d(in_dims, n_chans, 1) self.diffusion_embedding = SinusoidalPosEmb(n_chans) self.mlp = nn.Sequential( nn.Linear(n_chans, n_ch...
class WaveNet(nn.Module): def __init__(self, in_dims=128, n_layers=20, n_chans=384, n_hidden=256): super().__init__() self.input_projection = Conv1d(in_dims, n_chans, 1) self.diffusion_embedding = SinusoidalPosEmb(n_chans) self.mlp = nn.Sequential( nn.Linear(n_chans, n_ch...
x = spec.squeeze(1) x = self.input_projection(x) # [B, residual_channel, T] x = F.relu(x) diffusion_step = self.diffusion_embedding(diffusion_step) diffusion_step = self.mlp(diffusion_step) skip = [] for layer in self.residual_layers: x, skip_connect...
""" :param spec: [B, 1, M, T] :param diffusion_step: [B, 1] :param cond: [B, M, T] :return: """ x = spec.squeeze(1) x = self.input_projection(x) # [B, residual_channel, T] x = F.relu(x) diffusion_step = self.diffusion_embedding(diffusion_...
57
390
239
629
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...
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...
25,144
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/edgetts/tts.py
21,22
1,48
_main
22,38
22,38
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...
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...
voices = await VoicesManager.create() if GENDER is not None: # From "zh-cn" to "zh-CN" etc. if LANG == "zh-cn" or LANG == "zh-tw": LOCALE = LANG[:-2] + LANG[-2:].upper() voice = voices.find(Gender=GENDER, Locale=LOCALE) else: voice = voices.find(Gender...
voices = await VoicesManager.create() if GENDER is not None: # From "zh-cn" to "zh-CN" etc. if LANG == "zh-cn" or LANG == "zh-tw": LOCALE = LANG[:-2] + LANG[-2:].upper() voice = voices.find(Gender=GENDER, Locale=LOCALE) else: voice = voices.find(Gender...
65
323
242
565
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...
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...
25,146
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/inference/slicer.py
26,27
6,120
_apply_slice
Slicer
27,33
27,33
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): if not min_length >= min_interval >= hop_si...
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): if not min_length >= min_interval >= hop_si...
if len(waveform.shape) > 1: return waveform[:, begin * self.hop_size: min(waveform.shape[1], end * self.hop_size)] else: return waveform[begin * self.hop_size: min(waveform.shape[0], end * self.hop_size)] # @timeit
if len(waveform.shape) > 1: return waveform[:, begin * self.hop_size: min(waveform.shape[1], end * self.hop_size)] else: return waveform[begin * self.hop_size: min(waveform.shape[0], end * self.hop_size)] # @timeit
24
1,748
93
1,841
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): ...
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): ...
25,148
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/DSConv.py
65,66
1,77
weight_norm_modules
66,72
66,72
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...
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...
if isinstance(module,Depthwise_Separable_Conv1D) or isinstance(module,Depthwise_Separable_TransposeConv1D): module.weight_norm() return module else: return weight_norm(module,name,dim)
if isinstance(module,Depthwise_Separable_Conv1D) or isinstance(module,Depthwise_Separable_TransposeConv1D): module.weight_norm() return module else: return weight_norm(module,name,dim)
10
971
74
1,045
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...
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...
25,149
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/DSConv.py
30,31
5,34
remove_weight_norm
Depthwise_Separable_Conv1D
31,34
31,34
class Depthwise_Separable_Conv1D(nn.Module): def __init__( self, in_channels, out_channels, kernel_size, stride = 1, padding = 0, dilation = 1, bias = True, padding_mode = 'zeros', # TODO: refine this type device=None, dtype=No...
class Depthwise_Separable_Conv1D(nn.Module): def __init__( self, in_channels, out_channels, kernel_size, stride = 1, padding = 0, dilation = 1, bias = True, padding_mode = 'zeros', # TODO: refine this type device=None, dtype=No...
self.depth_conv = remove_weight_norm(self.depth_conv, name = 'weight') self.point_conv = remove_weight_norm(self.point_conv, name = 'weight')
self.depth_conv = remove_weight_norm(self.depth_conv, name = 'weight') self.point_conv = remove_weight_norm(self.point_conv, name = 'weight')
12
370
54
424
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...
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...
25,150
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/DSConv.py
56,57
34,65
weight_norm
Depthwise_Separable_TransposeConv1D
57,60
57,60
class Depthwise_Separable_TransposeConv1D(nn.Module): def __init__( self, in_channels, out_channels, kernel_size, stride = 1, padding = 0, output_padding = 0, bias = True, dilation = 1, padding_mode = 'zeros', # TODO: refine this type...
class Depthwise_Separable_TransposeConv1D(nn.Module): def __init__( self, in_channels, out_channels, kernel_size, stride = 1, padding = 0, output_padding = 0, bias = True, dilation = 1, padding_mode = 'zeros', # TODO: refine this type...
self.depth_conv = weight_norm(self.depth_conv, name = 'weight') self.point_conv = weight_norm(self.point_conv, name = 'weight')
self.depth_conv = weight_norm(self.depth_conv, name = 'weight') self.point_conv = weight_norm(self.point_conv, name = 'weight')
12
384
50
434
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...
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...
25,151
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/PMF0Predictor.py
40,41
7,73
compute_f0
PMF0Predictor
41,57
41,57
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.sampling_rate = sampling_rate self.name = "pm" def interpolate_f0(self,f0): ...
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.sampling_rate = sampling_rate self.name = "pm" def interpolate_f0(self,f0): ...
x = wav if p_len is None: p_len = x.shape[0]//self.hop_length else: assert abs(p_len-x.shape[0]//self.hop_length) < 4, "pad length error" time_step = self.hop_length / self.sampling_rate * 1000 f0 = parselmouth.Sound(x, self.sampling_rate).to_pitch_ac( ...
x = wav if p_len is None: p_len = x.shape[0]//self.hop_length else: assert abs(p_len-x.shape[0]//self.hop_length) < 4, "pad length error" time_step = self.hop_length / self.sampling_rate * 1000 f0 = parselmouth.Sound(x, self.sampling_rate).to_pitch_ac( ...
62
785
302
1,087
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....
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....
25,152
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/fcpe/nvSTFT.py
13,14
1,134
load_wav_to_torch
14,45
14,45
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): FILL_FUNC...
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): FILL_FUNC...
sampling_rate = None try: data, sampling_rate = sf.read(full_path, always_2d=True)# than soundfile. except Exception as ex: print(f"'{full_path}' failed to load.\nException:") print(ex) if return_empty_on_exception: return [], sampling_rate or target_sr or 48000 ...
sampling_rate = None try: data, sampling_rate = sf.read(full_path, always_2d=True)# than soundfile. except Exception as ex: print(f"'{full_path}' failed to load.\nException:") print(ex) if return_empty_on_exception: return [], sampling_rate or target_sr or 48000 ...
176
1,487
556
2,043
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): FILL_FUNC...
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): FILL_FUNC...
25,153
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/fcpe/nvSTFT.py
71,72
57,133
get_mel
STFT
72,128
72,128
class STFT(): def __init__(self, sr=22050, n_mels=80, n_fft=1024, win_size=1024, hop_length=256, fmin=20, fmax=11025, clip_val=1e-5): self.target_sr = sr self.n_mels = n_mels self.n_fft = n_fft self.win_size = win_size self.hop_length = hop_length ...
class STFT(): def __init__(self, sr=22050, n_mels=80, n_fft=1024, win_size=1024, hop_length=256, fmin=20, fmax=11025, clip_val=1e-5): self.target_sr = sr self.n_mels = n_mels self.n_fft = n_fft self.win_size = win_size self.hop_length = hop_length ...
sampling_rate = self.target_sr n_mels = self.n_mels n_fft = self.n_fft win_size = self.win_size hop_length = self.hop_length fmin = self.fmin fmax = self.fmax clip_val = self.clip_val factor = 2 ** (keyshift / 12) ...
sampling_rate = self.target_sr n_mels = self.n_mels n_fft = self.n_fft win_size = self.win_size hop_length = self.hop_length fmin = self.fmin fmax = self.fmax clip_val = self.clip_val factor = 2 ** (keyshift / 12) ...
212
308
942
1,250
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...
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...
25,154
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/rmvpe/deepunet.py
35,36
7,42
forward
ConvBlockRes
36,42
36,42
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_channels=out_channels, kernel_size=(3, 3), ...
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_channels=out_channels, kernel_size=(3, 3), ...
if self.is_shortcut: return self.conv(x) + self.shortcut(x) else: return self.conv(x) + x
if self.is_shortcut: return self.conv(x) + self.shortcut(x) else: return self.conv(x) + x
11
357
50
407
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...
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...
25,155
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/rmvpe/deepunet.py
142,143
132,148
forward
Decoder
143,148
143,148
class Decoder(nn.Module): def __init__(self, in_channels, n_decoders, stride, n_blocks, momentum=0.01): super(Decoder, self).__init__() self.layers = nn.ModuleList() self.n_decoders = n_decoders for i in range(self.n_decoders): out_channels = in_channels // 2 ...
class Decoder(nn.Module): def __init__(self, in_channels, n_decoders, stride, n_blocks, momentum=0.01): super(Decoder, self).__init__() self.layers = nn.ModuleList() self.n_decoders = n_decoders for i in range(self.n_decoders): out_channels = in_channels // 2 ...
for i in range(self.n_decoders): x = self.layers[i](x, concat_tensors[-1-i]) return x
for i in range(self.n_decoders): x = self.layers[i](x, concat_tensors[-1-i]) return x
10
181
49
230
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...
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...
25,156
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/rmvpe/deepunet.py
170,171
162,178
forward
DeepUnet
171,178
171,178
class DeepUnet(nn.Module): def __init__(self, kernel_size, n_blocks, en_de_layers=5, inter_layers=4, in_channels=1, en_out_channels=16): super(DeepUnet, self).__init__() self.encoder = Encoder(in_channels, N_MELS, en_de_layers, kernel_size, n_blocks, en_out_channels) self.intermediate = Inte...
class DeepUnet(nn.Module): def __init__(self, kernel_size, n_blocks, en_de_layers=5, inter_layers=4, in_channels=1, en_out_channels=16): super(DeepUnet, self).__init__() self.encoder = Encoder(in_channels, N_MELS, en_de_layers, kernel_size, n_blocks, en_out_channels) self.intermediate = Inte...
x, concat_tensors = self.encoder(x) x = self.intermediate(x) concat_tensors = self.tf(concat_tensors) x = self.decoder(x, concat_tensors) return x
x, concat_tensors = self.encoder(x) x = self.intermediate(x) concat_tensors = self.tf(concat_tensors) x = self.decoder(x, concat_tensors) return x
16
227
80
307
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...
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...
25,157
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/rmvpe/deepunet.py
186,187
178,191
forward
DeepUnet0
187,191
187,191
class DeepUnet0(nn.Module): def __init__(self, kernel_size, n_blocks, en_de_layers=5, inter_layers=4, in_channels=1, en_out_channels=16): super(DeepUnet0, self).__init__() self.encoder = Encoder(in_channels, N_MELS, en_de_layers, kernel_size, n_blocks, en_out_channels) self.intermediate = In...
class DeepUnet0(nn.Module): def __init__(self, kernel_size, n_blocks, en_de_layers=5, inter_layers=4, in_channels=1, en_out_channels=16): super(DeepUnet0, self).__init__() self.encoder = Encoder(in_channels, N_MELS, en_de_layers, kernel_size, n_blocks, en_out_channels) self.intermediate = In...
x, concat_tensors = self.encoder(x) x = self.intermediate(x) x = self.decoder(x, concat_tensors) return x
x, concat_tensors = self.encoder(x) x = self.intermediate(x) x = self.decoder(x, concat_tensors) return x
13
229
55
284
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...
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...
25,158
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/rmvpe/deepunet.py
108,109
92,117
forward
Encoder
109,117
109,117
class Encoder(nn.Module): def __init__(self, in_channels, in_size, n_encoders, kernel_size, n_blocks, out_channels=16, momentum=0.01): super(Encoder, self).__init__() self.n_encoders = n_encoders self.bn = nn.BatchNorm2d(in_channels, momentum=momentum) self.layers = nn.ModuleList() ...
class Encoder(nn.Module): def __init__(self, in_channels, in_size, n_encoders, kernel_size, n_blocks, out_channels=16, momentum=0.01): super(Encoder, self).__init__() self.n_encoders = n_encoders self.bn = nn.BatchNorm2d(in_channels, momentum=momentum) self.layers = nn.ModuleList() ...
concat_tensors = [] x = self.bn(x) for i in range(self.n_encoders): _, x = self.layers[i](x) concat_tensors.append(_) return x, concat_tensors
concat_tensors = [] x = self.bn(x) for i in range(self.n_encoders): _, x = self.layers[i](x) concat_tensors.append(_) return x, concat_tensors
18
273
81
354
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...
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...
25,159
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/rmvpe/deepunet.py
126,127
117,132
forward
Intermediate
127,132
127,132
class Intermediate(nn.Module): def __init__(self, in_channels, out_channels, n_inters, n_blocks, momentum=0.01): super(Intermediate, self).__init__() self.n_inters = n_inters self.layers = nn.ModuleList() self.layers.append(ResEncoderBlock(in_channels, out_channels, None, n_blocks, m...
class Intermediate(nn.Module): def __init__(self, in_channels, out_channels, n_inters, n_blocks, momentum=0.01): super(Intermediate, self).__init__() self.n_inters = n_inters self.layers = nn.ModuleList() self.layers.append(ResEncoderBlock(in_channels, out_channels, None, n_blocks, m...
for i in range(self.n_inters): x = self.layers[i](x) return x
for i in range(self.n_inters): x = self.layers[i](x) return x
9
179
37
216
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...
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...
25,160
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/rmvpe/deepunet.py
84,85
63,92
forward
ResDecoderBlock
85,92
85,92
class ResDecoderBlock(nn.Module): def __init__(self, in_channels, out_channels, stride, n_blocks=1, momentum=0.01): super(ResDecoderBlock, self).__init__() out_padding = (0, 1) if stride == (1, 2) else (1, 1) self.n_blocks = n_blocks self.conv1 = nn.Sequential( nn.ConvTra...
class ResDecoderBlock(nn.Module): def __init__(self, in_channels, out_channels, stride, n_blocks=1, momentum=0.01): super(ResDecoderBlock, self).__init__() out_padding = (0, 1) if stride == (1, 2) else (1, 1) self.n_blocks = n_blocks self.conv1 = nn.Sequential( nn.ConvTra...
x = self.conv1(x) x = torch.cat((x, concat_tensor), dim=1) for i in range(self.n_blocks): x = self.conv2[i](x) return x
x = self.conv1(x) x = torch.cat((x, concat_tensor), dim=1) for i in range(self.n_blocks): x = self.conv2[i](x) return x
17
332
70
402
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...
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...
25,161
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/rmvpe/deepunet.py
54,55
42,63
forward
ResEncoderBlock
55,63
55,63
class ResEncoderBlock(nn.Module): def __init__(self, in_channels, out_channels, kernel_size, n_blocks=1, momentum=0.01): super(ResEncoderBlock, self).__init__() self.n_blocks = n_blocks self.conv = nn.ModuleList() self.conv.append(ConvBlockRes(in_channels, out_channels, momentum)) ...
class ResEncoderBlock(nn.Module): def __init__(self, in_channels, out_channels, kernel_size, n_blocks=1, momentum=0.01): super(ResEncoderBlock, self).__init__() self.n_blocks = n_blocks self.conv = nn.ModuleList() self.conv.append(ConvBlockRes(in_channels, out_channels, momentum)) ...
for i in range(self.n_blocks): x = self.conv[i](x) if self.kernel_size is not None: return x, self.pool(x) else: return x
for i in range(self.n_blocks): x = self.conv[i](x) if self.kernel_size is not None: return x, self.pool(x) else: return x
18
214
66
280
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...
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...
25,162
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/rmvpe/deepunet.py
155,156
148,162
forward
TimbreFilter
156,162
156,162
class TimbreFilter(nn.Module): def __init__(self, latent_rep_channels): super(TimbreFilter, self).__init__() self.layers = nn.ModuleList() for latent_rep in latent_rep_channels: self.layers.append(ConvBlockRes(latent_rep[0], latent_rep[0])) def forward(self, x_tensors): FILL...
class TimbreFilter(nn.Module): def __init__(self, latent_rep_channels): super(TimbreFilter, self).__init__() self.layers = nn.ModuleList() for latent_rep in latent_rep_channels: self.layers.append(ConvBlockRes(latent_rep[0], latent_rep[0])) def forward(self, x_tensors): FILL...
out_tensors = [] for i, layer in enumerate(self.layers): out_tensors.append(layer(x_tensors[i])) return out_tensors
out_tensors = [] for i, layer in enumerate(self.layers): out_tensors.append(layer(x_tensors[i])) return out_tensors
11
115
59
174
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...
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...
25,163
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/rmvpe/inference.py
28,29
11,58
mel2hidden
RMVPE
29,35
29,35
class RMVPE: def __init__(self, model_path, device=None, dtype = torch.float32, hop_length=160): self.resample_kernel = {} if device is None: self.device = 'cuda' if torch.cuda.is_available() else 'cpu' else: self.device = device model = E2E0(4, 1, (2, 2)) ...
class RMVPE: def __init__(self, model_path, device=None, dtype = torch.float32, hop_length=160): self.resample_kernel = {} if device is None: self.device = 'cuda' if torch.cuda.is_available() else 'cpu' else: self.device = device model = E2E0(4, 1, (2, 2)) ...
with torch.no_grad(): n_frames = mel.shape[-1] mel = F.pad(mel, (0, 32 * ((n_frames - 1) // 32 + 1) - n_frames), mode='constant') hidden = self.model(mel) return hidden[:, :n_frames]
with torch.no_grad(): n_frames = mel.shape[-1] mel = F.pad(mel, (0, 32 * ((n_frames - 1) // 32 + 1) - n_frames), mode='constant') hidden = self.model(mel) return hidden[:, :n_frames]
27
742
92
834
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...
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...
25,164
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/rmvpe/model.py
30,31
9,43
forward
E2E
31,43
31,43
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_channels=16): super(E2E, self).__init__() self.mel = MelSpectrogram(N_MELS, SAMPLE_RATE, WINDOW_LENGTH, hop_length, None, MEL_FMIN, MEL_FMAX) # n...
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_channels=16): super(E2E, self).__init__() self.mel = MelSpectrogram(N_MELS, SAMPLE_RATE, WINDOW_LENGTH, hop_length, None, MEL_FMIN, MEL_FMAX) # n...
mel = self.mel(x.reshape(-1, x.shape[-1])).transpose(-1, -2).unsqueeze(1) x = self.cnn(self.unet(mel)).transpose(1, 2).flatten(-2) # x = self.fc(x) hidden_vec = 0 if len(self.fc) == 4: for i in range(len(self.fc)): x = self.fc[i](x) if ...
mel = self.mel(x.reshape(-1, x.shape[-1])).transpose(-1, -2).unsqueeze(1) x = self.cnn(self.unet(mel)).transpose(1, 2).flatten(-2) # x = self.fc(x) hidden_vec = 0 if len(self.fc) == 4: for i in range(len(self.fc)): x = self.fc[i](x) if ...
37
418
158
576
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...
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...
25,165
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/rmvpe/model.py
63,64
43,68
forward
E2E0
64,68
64,68
class E2E0(nn.Module): def __init__(self, n_blocks, n_gru, kernel_size, en_de_layers=5, inter_layers=4, in_channels=1, en_out_channels=16): super(E2E0, self).__init__() self.unet = DeepUnet0(kernel_size, n_blocks, en_de_layers, inter_layers, in_channels, en_out_channels) sel...
class E2E0(nn.Module): def __init__(self, n_blocks, n_gru, kernel_size, en_de_layers=5, inter_layers=4, in_channels=1, en_out_channels=16): super(E2E0, self).__init__() self.unet = DeepUnet0(kernel_size, n_blocks, en_de_layers, inter_layers, in_channels, en_out_channels) sel...
mel = mel.transpose(-1, -2).unsqueeze(1) x = self.cnn(self.unet(mel)).transpose(1, 2).flatten(-2) x = self.fc(x) return x
mel = mel.transpose(-1, -2).unsqueeze(1) x = self.cnn(self.unet(mel)).transpose(1, 2).flatten(-2) x = self.fc(x) return x
13
357
68
425
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...
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...
25,166
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/rmvpe/seq.py
9,10
4,13
forward
BiGRU
10,13
10,13
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): FILL_FUNC_BODY
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): FILL_FUNC_BODY
return self.gru(x)[0]
return self.gru(x)[0]
2
105
17
122
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): FILL_FUNC_BODYclas...
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): FILL_FUNC_BODYclas...
25,167
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/rmvpe/seq.py
18,19
13,21
forward
BiLSTM
19,21
19,21
class BiLSTM(nn.Module): def __init__(self, input_features, hidden_features, num_layers): super(BiLSTM, self).__init__() self.lstm = nn.LSTM(input_features, hidden_features, num_layers=num_layers, batch_first=True, bidirectional=True) def forward(self, x): FILL_FUNC_BODY
class BiLSTM(nn.Module): def __init__(self, input_features, hidden_features, num_layers): super(BiLSTM, self).__init__() self.lstm = nn.LSTM(input_features, hidden_features, num_layers=num_layers, batch_first=True, bidirectional=True) def forward(self, x): FILL_FUNC_BODY
return self.lstm(x)[0]
return self.lstm(x)[0]
2
106
16
122
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...
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...
25,168
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/rmvpe/spec.py
38,39
7,68
forward
MelSpectrogram
39,68
39,68
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, clamp = 1e-5 ): super().__init__() n_fft = win_length if n_fft is None ...
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, clamp = 1e-5 ): super().__init__() n_fft = win_length if n_fft is None ...
factor = 2 ** (keyshift / 12) n_fft_new = int(np.round(self.n_fft * factor)) win_length_new = int(np.round(self.win_length * factor)) hop_length_new = int(np.round(self.hop_length * speed)) keyshift_key = str(keyshift)+'_'+str(audio.device) if keyshift_key...
factor = 2 ** (keyshift / 12) n_fft_new = int(np.round(self.n_fft * factor)) win_length_new = int(np.round(self.win_length * factor)) hop_length_new = int(np.round(self.hop_length * speed)) keyshift_key = str(keyshift)+'_'+str(audio.device) if keyshift_key...
92
366
460
826
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, ...
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, ...
25,169
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/F0Predictor/rmvpe/utils.py
18,19
1,108
summary
19,64
19,64
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): FILL_FUNC_BODY...
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): FILL_FUNC_BODY...
def repr(model): # We treat the extra repr like the sub-module, one item per line extra_lines = [] extra_repr = model.extra_repr() # empty string will be split into list [''] if extra_repr: extra_lines = extra_repr.split('\n') child_lines = [] tota...
def repr(model): # We treat the extra repr like the sub-module, one item per line extra_lines = [] extra_repr = model.extra_repr() # empty string will be split into list [''] if extra_repr: extra_lines = extra_repr.split('\n') child_lines = [] tota...
166
765
520
1,285
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): FILL_FUNC_BODY...
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): FILL_FUNC_BODY...
25,171
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/losses.py
4,5
1,59
feature_loss
5,15
5,15
import torch def feature_loss(fmap_r, fmap_g): FILL_FUNC_BODYdef discriminator_loss(disc_real_outputs, disc_generated_outputs): loss = 0 r_losses = [] g_losses = [] for dr, dg in zip(disc_real_outputs, disc_generated_outputs): dr = dr.float() dg = dg.float() r_loss = torch.mean((1-dr)**2) g_lo...
import torch def feature_loss(fmap_r, fmap_g): FILL_FUNC_BODYdef discriminator_loss(disc_real_outputs, disc_generated_outputs): loss = 0 r_losses = [] g_losses = [] for dr, dg in zip(disc_real_outputs, disc_generated_outputs): dr = dr.float() dg = dg.float() r_loss = torch.mean((1-dr)**2) g_lo...
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
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
30
529
100
629
import torch def feature_loss(fmap_r, fmap_g): FILL_FUNC_BODYdef discriminator_loss(disc_real_outputs, disc_generated_outputs): loss = 0 r_losses = [] g_losses = [] for dr, dg in zip(disc_real_outputs, disc_generated_outputs): dr = dr.float() dg = dg.float() r_loss = torch.mean((1-dr)**2) g_lo...
import torch def feature_loss(fmap_r, fmap_g): FILL_FUNC_BODYdef discriminator_loss(disc_real_outputs, disc_generated_outputs): loss = 0 r_losses = [] g_losses = [] for dr, dg in zip(disc_real_outputs, disc_generated_outputs): dr = dr.float() dg = dg.float() r_loss = torch.mean((1-dr)**2) g_lo...
25,172
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/mel_processing.py
40,41
1,84
spectrogram_torch
41,67
41,67
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...
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...
if torch.min(y) < -1.: print('min value is ', torch.min(y)) if torch.max(y) > 1.: print('max value is ', torch.max(y)) global hann_window dtype_device = str(y.dtype) + '_' + str(y.device) wnsize_dtype_device = str(win_size) + '_' + dtype_device if wnsize_dtype_device not in hann...
if torch.min(y) < -1.: print('min value is ', torch.min(y)) if torch.max(y) > 1.: print('max value is ', torch.max(y)) global hann_window dtype_device = str(y.dtype) + '_' + str(y.device) wnsize_dtype_device = str(win_size) + '_' + dtype_device if wnsize_dtype_device not in hann...
84
677
446
1,123
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...
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...
25,174
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/modules.py
63,64
38,73
forward
ConvReluNorm
64,73
64,73
class ConvReluNorm(nn.Module): def __init__(self, in_channels, hidden_channels, out_channels, kernel_size, n_layers, p_dropout): super().__init__() self.in_channels = in_channels self.hidden_channels = hidden_channels self.out_channels = out_channels self.kernel_size = kernel_size self.n_layer...
class ConvReluNorm(nn.Module): def __init__(self, in_channels, hidden_channels, out_channels, kernel_size, n_layers, p_dropout): super().__init__() self.in_channels = in_channels self.hidden_channels = hidden_channels self.out_channels = out_channels self.kernel_size = kernel_size self.n_layer...
x_org = x for i in range(self.n_layers): x = self.conv_layers[i](x * x_mask) x = self.norm_layers[i](x) x = self.relu_drop(x) x = x_org + self.proj(x) return x * x_mask
x_org = x for i in range(self.n_layers): x = self.conv_layers[i](x * x_mask) x = self.norm_layers[i](x) x = self.relu_drop(x) x = x_org + self.proj(x) return x * x_mask
27
420
98
518
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, ) ...
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, ) ...
25,175
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/modules.py
249,250
242,260
forward
ElementwiseAffine
250,260
250,260
class ElementwiseAffine(nn.Module): def __init__(self, channels): super().__init__() self.channels = channels self.m = nn.Parameter(torch.zeros(channels,1)) self.logs = nn.Parameter(torch.zeros(channels,1)) def forward(self, x, x_mask, reverse=False, **kwargs): FILL_FUNC_BODY
class ElementwiseAffine(nn.Module): def __init__(self, channels): super().__init__() self.channels = channels self.m = nn.Parameter(torch.zeros(channels,1)) self.logs = nn.Parameter(torch.zeros(channels,1)) def forward(self, x, x_mask, reverse=False, **kwargs): FILL_FUNC_BODY
if not reverse: y = self.m + torch.exp(self.logs) * x y = y * x_mask logdet = torch.sum(self.logs * x_mask, [1,2]) return y, logdet else: x = (x - self.m) * torch.exp(-self.logs) * x_mask return x
if not reverse: y = self.m + torch.exp(self.logs) * x y = y * x_mask logdet = torch.sum(self.logs * x_mask, [1,2]) return y, logdet else: x = (x - self.m) * torch.exp(-self.logs) * x_mask return x
36
114
112
226
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, ) ...
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, ) ...
25,176
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/modules.py
233,234
232,242
forward
Flip
234,242
234,242
class Flip(nn.Module): def forward(self, x, *args, reverse=False, **kwargs): FILL_FUNC_BODY
class Flip(nn.Module): def forward(self, x, *args, reverse=False, **kwargs): FILL_FUNC_BODY
x = torch.flip(x, [1]) if not reverse: logdet = torch.zeros(x.size(0)).to(dtype=x.dtype, device=x.device) return x, logdet else: return x
x = torch.flip(x, [1]) if not reverse: logdet = torch.zeros(x.size(0)).to(dtype=x.dtype, device=x.device) return x, logdet else: return x
17
38
79
117
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, ) ...
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, ) ...
25,177
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/modules.py
32,33
23,38
forward
LayerNorm
33,38
33,38
class LayerNorm(nn.Module): def __init__(self, channels, eps=1e-5): super().__init__() self.channels = channels self.eps = eps self.gamma = nn.Parameter(torch.ones(channels)) self.beta = nn.Parameter(torch.zeros(channels)) def forward(self, x): FILL_FUNC_BODY
class LayerNorm(nn.Module): def __init__(self, channels, eps=1e-5): super().__init__() self.channels = channels self.eps = eps self.gamma = nn.Parameter(torch.ones(channels)) self.beta = nn.Parameter(torch.zeros(channels)) def forward(self, x): FILL_FUNC_BODY
x = x.transpose(1, -1) x = F.layer_norm(x, (self.channels,), self.gamma, self.beta, self.eps) return x.transpose(1, -1)
x = x.transpose(1, -1) x = F.layer_norm(x, (self.channels,), self.gamma, self.beta, self.eps) return x.transpose(1, -1)
14
112
66
178
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, ) ...
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, ) ...
25,178
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/modules.py
222,223
221,232
forward
Log
223,232
223,232
class Log(nn.Module): def forward(self, x, x_mask, reverse=False, **kwargs): FILL_FUNC_BODY
class Log(nn.Module): def forward(self, x, x_mask, reverse=False, **kwargs): FILL_FUNC_BODY
if not reverse: y = torch.log(torch.clamp_min(x, 1e-5)) * x_mask logdet = torch.sum(-y, [1, 2]) return y, logdet else: x = torch.exp(x) * x_mask return x
if not reverse: y = torch.log(torch.clamp_min(x, 1e-5)) * x_mask logdet = torch.sum(-y, [1, 2]) return y, logdet else: x = torch.exp(x) * x_mask return x
25
38
95
133
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, ) ...
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, ) ...
25,179
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/modules.py
172,173
149,194
forward
ResBlock1
173,187
173,187
class ResBlock1(torch.nn.Module): def __init__(self, channels, kernel_size=3, dilation=(1, 3, 5)): super(ResBlock1, self).__init__() self.convs1 = nn.ModuleList([ weight_norm_modules(Conv1dModel(channels, channels, kernel_size, 1, dilation=dilation[0], padd...
class ResBlock1(torch.nn.Module): def __init__(self, channels, kernel_size=3, dilation=(1, 3, 5)): super(ResBlock1, self).__init__() self.convs1 = nn.ModuleList([ weight_norm_modules(Conv1dModel(channels, channels, kernel_size, 1, dilation=dilation[0], padd...
for c1, c2 in zip(self.convs1, self.convs2): xt = F.leaky_relu(x, LRELU_SLOPE) if x_mask is not None: xt = xt * x_mask xt = c1(xt) xt = F.leaky_relu(xt, LRELU_SLOPE) if x_mask is not None: xt = xt * x_mask xt...
for c1, c2 in zip(self.convs1, self.convs2): xt = F.leaky_relu(x, LRELU_SLOPE) if x_mask is not None: xt = xt * x_mask xt = c1(xt) xt = F.leaky_relu(xt, LRELU_SLOPE) if x_mask is not None: xt = xt * x_mask xt...
57
504
179
683
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, ) ...
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, ) ...
25,180
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/modules.py
205,206
194,221
forward
ResBlock2
206,216
206,216
class ResBlock2(torch.nn.Module): def __init__(self, channels, kernel_size=3, dilation=(1, 3)): super(ResBlock2, self).__init__() self.convs = nn.ModuleList([ weight_norm_modules(Conv1dModel(channels, channels, kernel_size, 1, dilation=dilation[0], padding=...
class ResBlock2(torch.nn.Module): def __init__(self, channels, kernel_size=3, dilation=(1, 3)): super(ResBlock2, self).__init__() self.convs = nn.ModuleList([ weight_norm_modules(Conv1dModel(channels, channels, kernel_size, 1, dilation=dilation[0], padding=...
for c in self.convs: xt = F.leaky_relu(x, LRELU_SLOPE) if x_mask is not None: xt = xt * x_mask xt = c(xt) x = xt + x if x_mask is not None: x = x * x_mask return x
for c in self.convs: xt = F.leaky_relu(x, LRELU_SLOPE) if x_mask is not None: xt = xt * x_mask xt = c(xt) x = xt + x if x_mask is not None: x = x * x_mask return x
38
249
106
355
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, ) ...
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, ) ...
25,181
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/modules.py
288,289
260,309
forward
ResidualCouplingLayer
289,309
289,309
class ResidualCouplingLayer(nn.Module): def __init__(self, channels, hidden_channels, kernel_size, dilation_rate, n_layers, p_dropout=0, gin_channels=0, mean_only=False, wn_sharing_parameter=None ): assert channels % 2 == 0, "channels should be divisible...
class ResidualCouplingLayer(nn.Module): def __init__(self, channels, hidden_channels, kernel_size, dilation_rate, n_layers, p_dropout=0, gin_channels=0, mean_only=False, wn_sharing_parameter=None ): assert channels % 2 == 0, "channels should be divisible...
x0, x1 = torch.split(x, [self.half_channels]*2, 1) h = self.pre(x0) * x_mask h = self.enc(h, x_mask, g=g) stats = self.post(h) * x_mask if not self.mean_only: m, logs = torch.split(stats, [self.half_channels]*2, 1) else: m = stats logs = torch.zeros_like(m) if not reverse:...
x0, x1 = torch.split(x, [self.half_channels]*2, 1) h = self.pre(x0) * x_mask h = self.enc(h, x_mask, g=g) stats = self.post(h) * x_mask if not self.mean_only: m, logs = torch.split(stats, [self.half_channels]*2, 1) else: m = stats logs = torch.zeros_like(m) if not reverse:...
78
393
279
672
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, ) ...
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, ) ...
25,182
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/modules.py
337,338
309,357
forward
TransformerCouplingLayer
338,357
338,357
class TransformerCouplingLayer(nn.Module): def __init__(self, channels, hidden_channels, kernel_size, n_layers, n_heads, p_dropout=0, filter_channels=0, mean_only=False, wn_sharing_parameter=None, gin_channels = 0 ): assert channels % 2 == 0, "chan...
class TransformerCouplingLayer(nn.Module): def __init__(self, channels, hidden_channels, kernel_size, n_layers, n_heads, p_dropout=0, filter_channels=0, mean_only=False, wn_sharing_parameter=None, gin_channels = 0 ): assert channels % 2 == 0, "chan...
x0, x1 = torch.split(x, [self.half_channels]*2, 1) h = self.pre(x0) * x_mask h = self.enc(h, x_mask, g=g) stats = self.post(h) * x_mask if not self.mean_only: m, logs = torch.split(stats, [self.half_channels]*2, 1) else: m = stats logs = torch.zeros_like(m) if not reverse:...
x0, x1 = torch.split(x, [self.half_channels]*2, 1) h = self.pre(x0) * x_mask h = self.enc(h, x_mask, g=g) stats = self.post(h) * x_mask if not self.mean_only: m, logs = torch.split(stats, [self.half_channels]*2, 1) else: m = stats logs = torch.zeros_like(m) if not reverse:...
78
398
277
675
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, ) ...
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, ) ...
25,183
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/modules/modules.py
110,111
73,149
forward
WN
111,140
111,140
class WN(torch.nn.Module): def __init__(self, hidden_channels, kernel_size, dilation_rate, n_layers, gin_channels=0, p_dropout=0): super(WN, self).__init__() assert(kernel_size % 2 == 1) self.hidden_channels =hidden_channels self.kernel_size = kernel_size, self.dilation_rate = dilation_rate se...
class WN(torch.nn.Module): def __init__(self, hidden_channels, kernel_size, dilation_rate, n_layers, gin_channels=0, p_dropout=0): super(WN, self).__init__() assert(kernel_size % 2 == 1) self.hidden_channels =hidden_channels self.kernel_size = kernel_size, self.dilation_rate = dilation_rate se...
output = torch.zeros_like(x) n_channels_tensor = torch.IntTensor([self.hidden_channels]) if g is not None: g = self.cond_layer(g) for i in range(self.n_layers): x_in = self.in_layers[i](x) if g is not None: cond_offset = i * 2 * self.hidden_channels g_l = g[:,cond_off...
output = torch.zeros_like(x) n_channels_tensor = torch.IntTensor([self.hidden_channels]) if g is not None: g = self.cond_layer(g) for i in range(self.n_layers): x_in = self.in_layers[i](x) if g is not None: cond_offset = i * 2 * self.hidden_channels g_l = g[:,cond_off...
83
649
372
1,021
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, ) ...
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, ) ...
25,184
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/onnxexport/model_onnx.py
135,136
120,157
forward
DiscriminatorP
136,157
136,157
class DiscriminatorP(torch.nn.Module): def __init__(self, period, kernel_size=5, stride=3, use_spectral_norm=False): super(DiscriminatorP, self).__init__() self.period = period self.use_spectral_norm = use_spectral_norm norm_f = weight_norm if use_spectral_norm is False else spectral...
class DiscriminatorP(torch.nn.Module): def __init__(self, period, kernel_size=5, stride=3, use_spectral_norm=False): super(DiscriminatorP, self).__init__() self.period = period self.use_spectral_norm = use_spectral_norm norm_f = weight_norm if use_spectral_norm is False else spectral...
fmap = [] # 1d to 2d b, c, t = x.shape if t % self.period != 0: # pad first n_pad = self.period - (t % self.period) x = F.pad(x, (0, n_pad), "reflect") t = t + n_pad x = x.view(b, c, t // self.period, self.period) for l in self.convs...
fmap = [] # 1d to 2d b, c, t = x.shape if t % self.period != 0: # pad first n_pad = self.period - (t % self.period) x = F.pad(x, (0, n_pad), "reflect") t = t + n_pad x = x.view(b, c, t // self.period, self.period) for l in self.convs...
71
446
235
681
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...
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...
25,185
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/onnxexport/model_onnx.py
171,172
157,185
forward
DiscriminatorS
172,185
172,185
class DiscriminatorS(torch.nn.Module): def __init__(self, use_spectral_norm=False): super(DiscriminatorS, self).__init__() norm_f = weight_norm if use_spectral_norm is False else spectral_norm self.convs = nn.ModuleList([ norm_f(Conv1d(1, 16, 15, 1, padding=7)), norm_...
class DiscriminatorS(torch.nn.Module): def __init__(self, use_spectral_norm=False): super(DiscriminatorS, self).__init__() norm_f = weight_norm if use_spectral_norm is False else spectral_norm self.convs = nn.ModuleList([ norm_f(Conv1d(1, 16, 15, 1, padding=7)), norm_...
fmap = [] for l in self.convs: x = l(x) x = F.leaky_relu(x, modules.LRELU_SLOPE) fmap.append(x) x = self.conv_post(x) fmap.append(x) x = torch.flatten(x, 1, -1) return x, fmap
fmap = [] for l in self.convs: x = l(x) x = F.leaky_relu(x, modules.LRELU_SLOPE) fmap.append(x) x = self.conv_post(x) fmap.append(x) x = torch.flatten(x, 1, -1) return x, fmap
27
350
121
471
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...
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...
25,186
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/onnxexport/model_onnx.py
73,74
51,84
forward
Encoder
74,84
74,84
class Encoder(nn.Module): def __init__(self, in_channels, out_channels, hidden_channels, kernel_size, dilation_rate, n_layers, gin_channels=0): super().__init__() self.in_channels =...
class Encoder(nn.Module): def __init__(self, in_channels, out_channels, hidden_channels, kernel_size, dilation_rate, n_layers, gin_channels=0): super().__init__() self.in_channels =...
# print(x.shape,x_lengths.shape) x_mask = torch.unsqueeze(commons.sequence_mask(x_lengths, x.size(2)), 1).to(x.dtype) x = self.pre(x) * x_mask x = self.enc(x, x_mask, g=g) stats = self.proj(x) * x_mask m, logs = torch.split(stats, self.out_channels, dim=1) z = (m ...
# print(x.shape,x_lengths.shape) x_mask = torch.unsqueeze(commons.sequence_mask(x_lengths, x.size(2)), 1).to(x.dtype) x = self.pre(x) * x_mask x = self.enc(x, x_mask, g=g) stats = self.proj(x) * x_mask m, logs = torch.split(stats, self.out_channels, dim=1) z = (m ...
42
290
181
471
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...
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...
25,187
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/onnxexport/model_onnx.py
217,218
185,228
forward
F0Decoder
218,228
218,228
class F0Decoder(nn.Module): def __init__(self, out_channels, hidden_channels, filter_channels, n_heads, n_layers, kernel_size, p_dropout, spk_channels=0): super().__init__(...
class F0Decoder(nn.Module): def __init__(self, out_channels, hidden_channels, filter_channels, n_heads, n_layers, kernel_size, p_dropout, spk_channels=0): super().__init__(...
x = torch.detach(x) if spk_emb is not None: x = x + self.cond(spk_emb) x += self.f0_prenet(norm_f0) x = self.prenet(x) * x_mask x = self.decoder(x * x_mask, x_mask) x = self.proj(x) * x_mask return x
x = torch.detach(x) if spk_emb is not None: x = x + self.cond(spk_emb) x += self.f0_prenet(norm_f0) x = self.prenet(x) * x_mask x = self.decoder(x * x_mask, x_mask) x = self.proj(x) * x_mask return x
34
397
121
518
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...
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...
25,188
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/onnxexport/model_onnx.py
41,42
16,51
forward
ResidualCouplingBlock
42,51
42,51
class ResidualCouplingBlock(nn.Module): def __init__(self, channels, hidden_channels, kernel_size, dilation_rate, n_layers, n_flows=4, gin_channels=0): super().__init__() self.chann...
class ResidualCouplingBlock(nn.Module): def __init__(self, channels, hidden_channels, kernel_size, dilation_rate, n_layers, n_flows=4, gin_channels=0): super().__init__() self.chann...
if not reverse: for flow in self.flows: x, _ = flow(x, x_mask, g=g, reverse=reverse) else: for flow in reversed(self.flows): x = flow(x, x_mask, g=g, reverse=reverse) return x
if not reverse: for flow in self.flows: x, _ = flow(x, x_mask, g=g, reverse=reverse) else: for flow in reversed(self.flows): x = flow(x, x_mask, g=g, reverse=reverse) return x
27
294
92
386
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...
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...
25,189
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/onnxexport/model_onnx.py
312,313
228,334
forward
SynthesizerTrn
313,334
313,334
class SynthesizerTrn(nn.Module): """ Synthesizer for Training """ def __init__(self, spec_channels, segment_size, inter_channels, hidden_channels, filter_channels, n_heads, n_layers, ...
class SynthesizerTrn(nn.Module): """ Synthesizer for Training """ def __init__(self, spec_channels, segment_size, inter_channels, hidden_channels, filter_channels, n_heads, n_layers, ...
decoder_inp = F.pad(c, [0, 0, 1, 0]) mel2ph_ = mel2ph.unsqueeze(2).repeat([1, 1, c.shape[-1]]) c = torch.gather(decoder_inp, 1, mel2ph_).transpose(1, 2) # [B, T, H] c_lengths = (torch.ones(c.size(0)) * c.size(-1)).to(c.device) g = g.unsqueeze(0) g = self.emb_g(g).trans...
decoder_inp = F.pad(c, [0, 0, 1, 0]) mel2ph_ = mel2ph.unsqueeze(2).repeat([1, 1, c.shape[-1]]) c = torch.gather(decoder_inp, 1, mel2ph_).transpose(1, 2) # [B, T, H] c_lengths = (torch.ones(c.size(0)) * c.size(-1)).to(c.device) g = g.unsqueeze(0) g = self.emb_g(g).trans...
108
970
530
1,500
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...
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...
25,190
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/onnxexport/model_onnx.py
111,112
84,120
forward
TextEncoder
112,120
112,120
class TextEncoder(nn.Module): def __init__(self, out_channels, hidden_channels, kernel_size, n_layers, gin_channels=0, filter_channels=None, n_heads=None, p_dropout=None): ...
class TextEncoder(nn.Module): def __init__(self, out_channels, hidden_channels, kernel_size, n_layers, gin_channels=0, filter_channels=None, n_heads=None, p_dropout=None): ...
x = x + self.f0_emb(f0).transpose(1, 2) x = self.enc_(x * x_mask, x_mask) stats = self.proj(x) * x_mask m, logs = torch.split(stats, self.out_channels, dim=1) z = (m + z * torch.exp(logs)) * x_mask return z, m, logs, x_mask
x = x + self.f0_emb(f0).transpose(1, 2) x = self.enc_(x * x_mask, x_mask) stats = self.proj(x) * x_mask m, logs = torch.split(stats, self.out_channels, dim=1) z = (m + z * torch.exp(logs)) * x_mask return z, m, logs, x_mask
37
293
123
416
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...
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...
25,191
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/onnxexport/model_onnx_speaker_mix.py
114,115
92,125
forward
Encoder
115,125
115,125
class Encoder(nn.Module): def __init__(self, in_channels, out_channels, hidden_channels, kernel_size, dilation_rate, n_layers, gin_channels=0): super().__init__() self.in_channels =...
class Encoder(nn.Module): def __init__(self, in_channels, out_channels, hidden_channels, kernel_size, dilation_rate, n_layers, gin_channels=0): super().__init__() self.in_channels =...
# print(x.shape,x_lengths.shape) x_mask = torch.unsqueeze(commons.sequence_mask(x_lengths, x.size(2)), 1).to(x.dtype) x = self.pre(x) * x_mask x = self.enc(x, x_mask, g=g) stats = self.proj(x) * x_mask m, logs = torch.split(stats, self.out_channels, dim=1) z = (m ...
# print(x.shape,x_lengths.shape) x_mask = torch.unsqueeze(commons.sequence_mask(x_lengths, x.size(2)), 1).to(x.dtype) x = self.pre(x) * x_mask x = self.enc(x, x_mask, g=g) stats = self.proj(x) * x_mask m, logs = torch.split(stats, self.out_channels, dim=1) z = (m ...
42
290
181
471
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, ...
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, ...
25,192
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/onnxexport/model_onnx_speaker_mix.py
194,195
162,205
forward
F0Decoder
195,205
195,205
class F0Decoder(nn.Module): def __init__(self, out_channels, hidden_channels, filter_channels, n_heads, n_layers, kernel_size, p_dropout, spk_channels=0): super().__init__(...
class F0Decoder(nn.Module): def __init__(self, out_channels, hidden_channels, filter_channels, n_heads, n_layers, kernel_size, p_dropout, spk_channels=0): super().__init__(...
x = torch.detach(x) if (spk_emb is not None): x = x + self.cond(spk_emb) x += self.f0_prenet(norm_f0) x = self.prenet(x) * x_mask x = self.decoder(x * x_mask, x_mask) x = self.proj(x) * x_mask return x
x = torch.detach(x) if (spk_emb is not None): x = x + self.cond(spk_emb) x += self.f0_prenet(norm_f0) x = self.prenet(x) * x_mask x = self.decoder(x * x_mask, x_mask) x = self.proj(x) * x_mask return x
34
397
122
519
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, ...
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, ...
25,193
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/onnxexport/model_onnx_speaker_mix.py
42,43
12,51
forward
ResidualCouplingBlock
43,51
43,51
class ResidualCouplingBlock(nn.Module): def __init__(self, channels, hidden_channels, kernel_size, dilation_rate, n_layers, n_flows=4, gin_channels=0, share_parameter=False ...
class ResidualCouplingBlock(nn.Module): def __init__(self, channels, hidden_channels, kernel_size, dilation_rate, n_layers, n_flows=4, gin_channels=0, share_parameter=False ...
if not reverse: for flow in self.flows: x, _ = flow(x, x_mask, g=g, reverse=reverse) else: for flow in reversed(self.flows): x = flow(x, x_mask, g=g, reverse=reverse) return x
if not reverse: for flow in self.flows: x, _ = flow(x, x_mask, g=g, reverse=reverse) else: for flow in reversed(self.flows): x = flow(x, x_mask, g=g, reverse=reverse) return x
27
372
90
462
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, ...
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, ...
25,195
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/onnxexport/model_onnx_speaker_mix.py
152,153
125,162
forward
TextEncoder
153,162
153,162
class TextEncoder(nn.Module): def __init__(self, out_channels, hidden_channels, kernel_size, n_layers, gin_channels=0, filter_channels=None, n_heads=None, p_dropout=None): ...
class TextEncoder(nn.Module): def __init__(self, out_channels, hidden_channels, kernel_size, n_layers, gin_channels=0, filter_channels=None, n_heads=None, p_dropout=None): ...
x = x + self.f0_emb(f0).transpose(1, 2) x = self.enc_(x * x_mask, x_mask) stats = self.proj(x) * x_mask m, logs = torch.split(stats, self.out_channels, dim=1) z = (m + z * torch.exp(logs)) * x_mask return z, m, logs, x_mask
x = x + self.f0_emb(f0).transpose(1, 2) x = self.enc_(x * x_mask, x_mask) stats = self.proj(x) * x_mask m, logs = torch.split(stats, self.out_channels, dim=1) z = (m + z * torch.exp(logs)) * x_mask return z, m, logs, x_mask
37
293
125
418
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, ...
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, ...
25,196
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/onnxexport/model_onnx_speaker_mix.py
82,83
51,92
forward
TransformerCouplingBlock
83,92
83,92
class TransformerCouplingBlock(nn.Module): def __init__(self, channels, hidden_channels, filter_channels, n_heads, n_layers, kernel_size, p_dropout, n_flows=4, gin...
class TransformerCouplingBlock(nn.Module): def __init__(self, channels, hidden_channels, filter_channels, n_heads, n_layers, kernel_size, p_dropout, n_flows=4, gin...
if not reverse: for flow in self.flows: x, _ = flow(x, x_mask, g=g, reverse=reverse) else: for flow in reversed(self.flows): x = flow(x, x_mask, g=g, reverse=reverse) return x
if not reverse: for flow in self.flows: x, _ = flow(x, x_mask, g=g, reverse=reverse) else: for flow in reversed(self.flows): x = flow(x, x_mask, g=g, reverse=reverse) return x
27
395
92
487
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, ...
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, ...
25,197
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/preprocess_flist_config.py
15,16
1,120
get_wav_duration
16,28
16,28
import argparse import json import os import re import wave from random import shuffle from loguru import logger from tqdm import tqdm import diffusion.logger.utils as du pattern = re.compile(r'^[\.a-zA-Z0-9_\/]+$') def get_wav_duration(file_path): FILL_FUNC_BODYif __name__ == "__main__": parser = argparse.Argu...
import argparse import json import os import re import wave from random import shuffle from loguru import logger from tqdm import tqdm import diffusion.logger.utils as du pattern = re.compile(r'^[\.a-zA-Z0-9_\/]+$') def get_wav_duration(file_path): FILL_FUNC_BODYif __name__ == "__main__": parser = argparse.Argu...
try: with wave.open(file_path, 'rb') as wav_file: # 获取音频帧数 n_frames = wav_file.getnframes() # 获取采样率 framerate = wav_file.getframerate() # 计算时长(秒) return n_frames / float(framerate) except Exception as e: logger.error(f"Readi...
try: with wave.open(file_path, 'rb') as wav_file: # 获取音频帧数 n_frames = wav_file.getnframes() # 获取采样率 framerate = wav_file.getframerate() # 计算时长(秒) return n_frames / float(framerate) except Exception as e: logger.error(f"Readi...
30
1,581
137
1,718
import argparse import json import os import re import wave from random import shuffle from loguru import logger from tqdm import tqdm import diffusion.logger.utils as du pattern = re.compile(r'^[\.a-zA-Z0-9_\/]+$') def get_wav_duration(file_path): FILL_FUNC_BODYif __name__ == "__main__": parser = argparse.Argu...
import argparse import json import os import re import wave from random import shuffle from loguru import logger from tqdm import tqdm import diffusion.logger.utils as du pattern = re.compile(r'^[\.a-zA-Z0-9_\/]+$') def get_wav_duration(file_path): FILL_FUNC_BODYif __name__ == "__main__": parser = argparse.Argu...
25,198
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/pretrain/meta.py
30,31
1,40
get_speech_encoder
31,40
31,40
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...
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...
import json with open(config_path, "r") as f: data = f.read() config = json.loads(data) speech_encoder = config["model"]["speech_encoder"] dict = download_dict() return dict[speech_encoder]["url"], dict[speech_encoder]["output"]
import json with open(config_path, "r") as f: data = f.read() config = json.loads(data) speech_encoder = config["model"]["speech_encoder"] dict = download_dict() return dict[speech_encoder]["url"], dict[speech_encoder]["output"]
22
665
100
765
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...
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...
25,199
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/train_diff.py
14,15
1,78
parse_args
16,26
15,26
import argparse import torch from loguru import logger from torch.optim import lr_scheduler from diffusion.data_loaders import get_data_loaders from diffusion.logger import utils from diffusion.solver import train from diffusion.unit2mel import Unit2Mel from diffusion.vocoder import Vocoder def parse_args(args=None...
import argparse import torch from loguru import logger from torch.optim import lr_scheduler from diffusion.data_loaders import get_data_loaders from diffusion.logger import utils from diffusion.solver import train from diffusion.unit2mel import Unit2Mel from diffusion.vocoder import Vocoder def parse_args(args=None...
parser = argparse.ArgumentParser() parser.add_argument( "-c", "--config", type=str, required=True, help="path to the config file") return parser.parse_args(args=args, namespace=namespace)
"""Parse command-line arguments.""" parser = argparse.ArgumentParser() parser.add_argument( "-c", "--config", type=str, required=True, help="path to the config file") return parser.parse_args(args=args, namespace=namespace)
16
774
81
855
import argparse import torch from loguru import logger from torch.optim import lr_scheduler from diffusion.data_loaders import get_data_loaders from diffusion.logger import utils from diffusion.solver import train from diffusion.unit2mel import Unit2Mel from diffusion.vocoder import Vocoder def parse_args(args=None...
import argparse import torch from loguru import logger from torch.optim import lr_scheduler from diffusion.data_loaders import get_data_loaders from diffusion.logger import utils from diffusion.solver import train from diffusion.unit2mel import Unit2Mel from diffusion.vocoder import Vocoder def parse_args(args=None...
25,200
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vdecoder/hifigan/env.py
11,12
1,16
build_env
12,16
12,16
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): FILL_FUNC_BODY
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): FILL_FUNC_BODY
t_path = os.path.join(path, config_name) if config != t_path: os.makedirs(path, exist_ok=True) shutil.copyfile(config, os.path.join(path, config_name))
t_path = os.path.join(path, config_name) if config != t_path: os.makedirs(path, exist_ok=True) shutil.copyfile(config, os.path.join(path, config_name))
13
85
70
155
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): FILL_FUNC_BODY
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): FILL_FUNC_BODY
25,201
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vdecoder/hifigan/nvSTFT.py
12,13
1,110
load_wav_to_torch
13,44
13,44
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): FILL_FUNC_BODYdef dynamic_range_compressi...
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): FILL_FUNC_BODYdef dynamic_range_compressi...
sampling_rate = None try: data, sampling_rate = sf.read(full_path, always_2d=True)# than soundfile. except Exception as ex: print(f"'{full_path}' failed to load.\nException:") print(ex) if return_empty_on_exception: return [], sampling_rate or target_sr or 32000 ...
sampling_rate = None try: data, sampling_rate = sf.read(full_path, always_2d=True)# than soundfile. except Exception as ex: print(f"'{full_path}' failed to load.\nException:") print(ex) if return_empty_on_exception: return [], sampling_rate or target_sr or 32000 ...
176
1,152
556
1,708
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): FILL_FUNC_BODYdef dynamic_range_compressi...
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): FILL_FUNC_BODYdef dynamic_range_compressi...
25,202
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vdecoder/hifigan/nvSTFT.py
70,71
56,109
get_mel
STFT
71,104
71,104
class STFT(): def __init__(self, sr=22050, n_mels=80, n_fft=1024, win_size=1024, hop_length=256, fmin=20, fmax=11025, clip_val=1e-5): self.target_sr = sr self.n_mels = n_mels self.n_fft = n_fft self.win_size = win_size self.hop_length = hop_length ...
class STFT(): def __init__(self, sr=22050, n_mels=80, n_fft=1024, win_size=1024, hop_length=256, fmin=20, fmax=11025, clip_val=1e-5): self.target_sr = sr self.n_mels = n_mels self.n_fft = n_fft self.win_size = win_size self.hop_length = hop_length ...
sampling_rate = self.target_sr n_mels = self.n_mels n_fft = self.n_fft win_size = self.win_size hop_length = self.hop_length fmin = self.fmin fmax = self.fmax clip_val = self.clip_val if torch.min(y) < -1.: ...
sampling_rate = self.target_sr n_mels = self.n_mels n_fft = self.n_fft win_size = self.win_size hop_length = self.hop_length fmin = self.fmin fmax = self.fmax clip_val = self.clip_val if torch.min(y) < -1.: ...
101
294
609
903
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: ...
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: ...
25,203
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vdecoder/hifigan/utils.py
46,47
1,69
save_checkpoint
47,52
47,52
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...
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...
print("Saving checkpoint to {}".format(filepath)) torch.save(obj, filepath) print("Complete.")
print("Saving checkpoint to {}".format(filepath)) torch.save(obj, filepath) print("Complete.")
7
632
41
673
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...
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...
25,204
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vdecoder/hifiganwithsnake/alias/filter.py
29,30
1,111
kaiser_sinc_filter1d
30,61
30,61
# 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....
# 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....
even = (kernel_size % 2 == 0) half_size = kernel_size // 2 #For kaiser window delta_f = 4 * half_width A = 2.285 * (half_size - 1) * math.pi * delta_f + 7.95 if A > 50.: beta = 0.1102 * (A - 8.7) elif A >= 21.: beta = 0.5842 * (A - 21)**0.4 + 0.07886 * (A - 21.) else: ...
even = (kernel_size % 2 == 0) half_size = kernel_size // 2 #For kaiser window delta_f = 4 * half_width A = 2.285 * (half_size - 1) * math.pi * delta_f + 7.95 if A > 50.: beta = 0.1102 * (A - 8.7) elif A >= 21.: beta = 0.5842 * (A - 21)**0.4 + 0.07886 * (A - 21.) else: ...
151
1,068
403
1,471
# 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....
# 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....
25,205
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vdecoder/hifiganwithsnake/alias/filter.py
93,94
61,111
forward
LowPassFilter1d
94,111
94,111
class LowPassFilter1d(nn.Module): def __init__(self, cutoff=0.5, half_width=0.6, stride: int = 1, padding: bool = True, padding_mode: str = 'replicate', kernel_size: int = 12, C=None): # ke...
class LowPassFilter1d(nn.Module): def __init__(self, cutoff=0.5, half_width=0.6, stride: int = 1, padding: bool = True, padding_mode: str = 'replicate', kernel_size: int = 12, C=None): # ke...
if self.conv1d_block[0].weight.device != x.device: self.conv1d_block[0] = self.conv1d_block[0].to(x.device) if self.conv1d_block is None: _, C, _ = x.shape if self.padding: x = F.pad(x, (self.pad_left, self.pad_right), mode...
if self.conv1d_block[0].weight.device != x.device: self.conv1d_block[0] = self.conv1d_block[0].to(x.device) if self.conv1d_block is None: _, C, _ = x.shape if self.padding: x = F.pad(x, (self.pad_left, self.pad_right), mode...
46
449
236
685
# 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....
# 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....
25,206
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vdecoder/hifiganwithsnake/alias/resample.py
69,70
57,73
forward
DownSample1d
70,73
70,73
class DownSample1d(nn.Module): def __init__(self, ratio=2, kernel_size=None, C=None): super().__init__() self.ratio = ratio self.kernel_size = int(6 * ratio // 2) * 2 if kernel_size is None else kernel_size self.lowpass = LowPassFilter1d(cutoff=0.5 / ratio, ...
class DownSample1d(nn.Module): def __init__(self, ratio=2, kernel_size=None, C=None): super().__init__() self.ratio = ratio self.kernel_size = int(6 * ratio // 2) * 2 if kernel_size is None else kernel_size self.lowpass = LowPassFilter1d(cutoff=0.5 / ratio, ...
xx = self.lowpass(x) return xx
xx = self.lowpass(x) return xx
5
158
18
176
# 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...
# 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...
25,207
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vdecoder/hifiganwithsnake/alias/resample.py
38,39
10,57
forward
UpSample1d
39,57
39,57
class UpSample1d(nn.Module): def __init__(self, ratio=2, kernel_size=None, C=None): super().__init__() self.ratio = ratio self.kernel_size = int(6 * ratio // 2) * 2 if kernel_size is None else kernel_size self.stride = ratio self.pad = self.kernel_size // ratio - 1 se...
class UpSample1d(nn.Module): def __init__(self, ratio=2, kernel_size=None, C=None): super().__init__() self.ratio = ratio self.kernel_size = int(6 * ratio // 2) * 2 if kernel_size is None else kernel_size self.stride = ratio self.pad = self.kernel_size // ratio - 1 se...
if self.conv_transpose1d_block[0].weight.device != x.device: self.conv_transpose1d_block[0] = self.conv_transpose1d_block[0].to(x.device) if self.conv_transpose1d_block is None: if C is None: _, C, _ = x.shape # print("snake.conv_t.in:",x.shape) ...
if self.conv_transpose1d_block[0].weight.device != x.device: self.conv_transpose1d_block[0] = self.conv_transpose1d_block[0].to(x.device) if self.conv_transpose1d_block is None: if C is None: _, C, _ = x.shape # print("snake.conv_t.in:",x.shape) ...
63
424
321
745
# 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...
# 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...
25,208
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vdecoder/hifiganwithsnake/env.py
11,12
1,16
build_env
12,16
12,16
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): FILL_FUNC_BODY
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): FILL_FUNC_BODY
t_path = os.path.join(path, config_name) if config != t_path: os.makedirs(path, exist_ok=True) shutil.copyfile(config, os.path.join(path, config_name))
t_path = os.path.join(path, config_name) if config != t_path: os.makedirs(path, exist_ok=True) shutil.copyfile(config, os.path.join(path, config_name))
13
85
70
155
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): FILL_FUNC_BODY
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): FILL_FUNC_BODY
25,209
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vdecoder/hifiganwithsnake/nvSTFT.py
53,54
1,110
dynamic_range_decompression_torch
54,56
54,56
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: ...
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: ...
return torch.exp(x) / C
return torch.exp(x) / C
4
1,664
15
1,679
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: ...
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: ...
25,210
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vdecoder/hifiganwithsnake/nvSTFT.py
70,71
56,109
get_mel
STFT
71,104
71,104
class STFT(): def __init__(self, sr=22050, n_mels=80, n_fft=1024, win_size=1024, hop_length=256, fmin=20, fmax=11025, clip_val=1e-5): self.target_sr = sr self.n_mels = n_mels self.n_fft = n_fft self.win_size = win_size self.hop_length = hop_length ...
class STFT(): def __init__(self, sr=22050, n_mels=80, n_fft=1024, win_size=1024, hop_length=256, fmin=20, fmax=11025, clip_val=1e-5): self.target_sr = sr self.n_mels = n_mels self.n_fft = n_fft self.win_size = win_size self.hop_length = hop_length ...
sampling_rate = self.target_sr n_mels = self.n_mels n_fft = self.n_fft win_size = self.win_size hop_length = self.hop_length fmin = self.fmin fmax = self.fmax clip_val = self.clip_val if torch.min(y) < -1.: ...
sampling_rate = self.target_sr n_mels = self.n_mels n_fft = self.n_fft win_size = self.win_size hop_length = self.hop_length fmin = self.fmin fmax = self.fmax clip_val = self.clip_val if torch.min(y) < -1.: ...
101
294
609
903
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: ...
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: ...
25,211
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vdecoder/hifiganwithsnake/utils.py
52,53
1,69
del_old_checkpoints
53,62
53,62
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...
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...
pattern = os.path.join(cp_dir, prefix + '????????') cp_list = glob.glob(pattern) # get checkpoint paths cp_list = sorted(cp_list)# sort by iter if len(cp_list) > n_models: # if more than n_models models are found for cp in cp_list[:-n_models]:# delete the oldest models other than lastest n_model...
pattern = os.path.join(cp_dir, prefix + '????????') cp_list = glob.glob(pattern) # get checkpoint paths cp_list = sorted(cp_list)# sort by iter if len(cp_list) > n_models: # if more than n_models models are found for cp in cp_list[:-n_models]:# delete the oldest models other than lastest n_model...
57
527
150
677
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...
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...
25,212
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vdecoder/nsf_hifigan/env.py
11,12
1,16
build_env
12,16
12,16
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): FILL_FUNC_BODY
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): FILL_FUNC_BODY
t_path = os.path.join(path, config_name) if config != t_path: os.makedirs(path, exist_ok=True) shutil.copyfile(config, os.path.join(path, config_name))
t_path = os.path.join(path, config_name) if config != t_path: os.makedirs(path, exist_ok=True) shutil.copyfile(config, os.path.join(path, config_name))
13
85
70
155
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): FILL_FUNC_BODY
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): FILL_FUNC_BODY
25,213
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vdecoder/nsf_hifigan/nvSTFT.py
13,14
1,133
load_wav_to_torch
14,45
14,45
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): FILL_FUNC...
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): FILL_FUNC...
sampling_rate = None try: data, sampling_rate = sf.read(full_path, always_2d=True)# than soundfile. except Exception as ex: print(f"'{full_path}' failed to load.\nException:") print(ex) if return_empty_on_exception: return [], sampling_rate or target_sr or 48000 ...
sampling_rate = None try: data, sampling_rate = sf.read(full_path, always_2d=True)# than soundfile. except Exception as ex: print(f"'{full_path}' failed to load.\nException:") print(ex) if return_empty_on_exception: return [], sampling_rate or target_sr or 48000 ...
176
1,480
556
2,036
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): FILL_FUNC...
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): FILL_FUNC...
25,214
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vdecoder/nsf_hifigan/nvSTFT.py
71,72
57,132
get_mel
STFT
72,127
72,127
class STFT(): def __init__(self, sr=22050, n_mels=80, n_fft=1024, win_size=1024, hop_length=256, fmin=20, fmax=11025, clip_val=1e-5): self.target_sr = sr self.n_mels = n_mels self.n_fft = n_fft self.win_size = win_size self.hop_length = hop_length ...
class STFT(): def __init__(self, sr=22050, n_mels=80, n_fft=1024, win_size=1024, hop_length=256, fmin=20, fmax=11025, clip_val=1e-5): self.target_sr = sr self.n_mels = n_mels self.n_fft = n_fft self.win_size = win_size self.hop_length = hop_length ...
sampling_rate = self.target_sr n_mels = self.n_mels n_fft = self.n_fft win_size = self.win_size hop_length = self.hop_length fmin = self.fmin fmax = self.fmax clip_val = self.clip_val factor = 2 ** (keyshift / 12) ...
sampling_rate = self.target_sr n_mels = self.n_mels n_fft = self.n_fft win_size = self.win_size hop_length = self.hop_length fmin = self.fmin fmax = self.fmax clip_val = self.clip_val factor = 2 ** (keyshift / 12) ...
200
304
938
1,242
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...
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...
25,215
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vdecoder/nsf_hifigan/utils.py
54,55
1,71
del_old_checkpoints
55,64
55,64
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...
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...
pattern = os.path.join(cp_dir, prefix + '????????') cp_list = glob.glob(pattern) # get checkpoint paths cp_list = sorted(cp_list)# sort by iter if len(cp_list) > n_models: # if more than n_models models are found for cp in cp_list[:-n_models]:# delete the oldest models other than lastest n_model...
pattern = os.path.join(cp_dir, prefix + '????????') cp_list = glob.glob(pattern) # get checkpoint paths cp_list = sorted(cp_list)# sort by iter if len(cp_list) > n_models: # if more than n_models models are found for cp in cp_list[:-n_models]:# delete the oldest models other than lastest n_model...
57
532
150
682
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...
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...
25,216
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/CNHubertLarge.py
23,24
7,37
encoder
CNHubertLarge
24,37
24,37
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)) self.hidden_dim = 1024 models, saved_cfg, task = checkpoint_utils.load_model_ensemble_and_...
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)) self.hidden_dim = 1024 models, saved_cfg, task = checkpoint_utils.load_model_ensemble_and_...
feats = wav if feats.dim() == 2: # double channels feats = feats.mean(-1) assert feats.dim() == 1, feats.dim() feats = feats.view(1, -1) padding_mask = torch.BoolTensor(feats.shape).fill_(False) inputs = { "source": feats.to(wav.device), "...
feats = wav if feats.dim() == 2: # double channels feats = feats.mean(-1) assert feats.dim() == 1, feats.dim() feats = feats.view(1, -1) padding_mask = torch.BoolTensor(feats.shape).fill_(False) inputs = { "source": feats.to(wav.device), "...
41
230
184
414
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...
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...
25,217
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/ContentVec256L9.py
23,24
7,39
encoder
ContentVec256L9
24,39
24,39
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, saved_cfg, task = checkpoint_utils.load_model_ensemble_and_task( [vec_path], ...
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, saved_cfg, task = checkpoint_utils.load_model_ensemble_and_task( [vec_path], ...
feats = wav if feats.dim() == 2: # double channels feats = feats.mean(-1) assert feats.dim() == 1, feats.dim() feats = feats.view(1, -1) padding_mask = torch.BoolTensor(feats.shape).fill_(False) inputs = { "source": feats.to(wav.device), "...
feats = wav if feats.dim() == 2: # double channels feats = feats.mean(-1) assert feats.dim() == 1, feats.dim() feats = feats.view(1, -1) padding_mask = torch.BoolTensor(feats.shape).fill_(False) inputs = { "source": feats.to(wav.device), "...
49
229
218
447
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,...
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,...
25,218
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/ContentVec768L12.py
23,24
7,38
encoder
ContentVec768L12
24,38
24,38
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.hidden_dim = 768 models, saved_cfg, task = checkpoint_utils.load_model_ensemble_and_task(...
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.hidden_dim = 768 models, saved_cfg, task = checkpoint_utils.load_model_ensemble_and_task(...
feats = wav if feats.dim() == 2: # double channels feats = feats.mean(-1) assert feats.dim() == 1, feats.dim() feats = feats.view(1, -1) padding_mask = torch.BoolTensor(feats.shape).fill_(False) inputs = { "source": feats.to(wav.device), "...
feats = wav if feats.dim() == 2: # double channels feats = feats.mean(-1) assert feats.dim() == 1, feats.dim() feats = feats.view(1, -1) padding_mask = torch.BoolTensor(feats.shape).fill_(False) inputs = { "source": feats.to(wav.device), "...
46
230
203
433
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...
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...
25,219
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/DPHubert.py
20,21
7,30
encoder
DPHubert
21,30
21,30
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 is None: self.dev = torch.device("cuda" if torch.cuda.is_available() else "cpu") else: ...
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 is None: self.dev = torch.device("cuda" if torch.cuda.is_available() else "cpu") else: ...
feats = wav if feats.dim() == 2: # double channels feats = feats.mean(-1) assert feats.dim() == 1, feats.dim() feats = feats[None, :] with torch.no_grad(): with torch.inference_mode(): units = self.model(feats)[0] return un...
feats = wav if feats.dim() == 2: # double channels feats = feats.mean(-1) assert feats.dim() == 1, feats.dim() feats = feats[None, :] with torch.no_grad(): with torch.inference_mode(): units = self.model(feats)[0] return un...
31
224
117
341
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 ...
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 ...
25,220
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/HubertSoft.py
19,20
7,29
encoder
HubertSoft
20,29
20,29
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 = hubert_model.hubert_soft(vec_path) if device is None: self.dev = torch.device("c...
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 = hubert_model.hubert_soft(vec_path) if device is None: self.dev = torch.device("c...
feats = wav if feats.dim() == 2: # double channels feats = feats.mean(-1) assert feats.dim() == 1, feats.dim() feats = feats[None,None,:] with torch.no_grad(): with torch.inference_mode(): units = self.model.units(feats) ...
feats = wav if feats.dim() == 2: # double channels feats = feats.mean(-1) assert feats.dim() == 1, feats.dim() feats = feats[None,None,:] with torch.no_grad(): with torch.inference_mode(): units = self.model.units(feats) ...
30
199
120
319
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 = ...
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 = ...
25,221
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/WavLMBasePlus.py
22,23
7,33
encoder
WavLMBasePlus
23,33
23,33
class WavLMBasePlus(SpeechEncoder): def __init__(self, vec_path="pretrain/WavLM-Base+.pt", device=None): super().__init__() print("load model(s) from {}".format(vec_path)) checkpoint = torch.load(vec_path) self.cfg = WavLMConfig(checkpoint['cfg']) if device is None: ...
class WavLMBasePlus(SpeechEncoder): def __init__(self, vec_path="pretrain/WavLM-Base+.pt", device=None): super().__init__() print("load model(s) from {}".format(vec_path)) checkpoint = torch.load(vec_path) self.cfg = WavLMConfig(checkpoint['cfg']) if device is None: ...
feats = wav if feats.dim() == 2: # double channels feats = feats.mean(-1) assert feats.dim() == 1, feats.dim() if self.cfg.normalize: feats = torch.nn.functional.layer_norm(feats, feats.shape) with torch.no_grad(): with torch.inference_mode():...
feats = wav if feats.dim() == 2: # double channels feats = feats.mean(-1) assert feats.dim() == 1, feats.dim() if self.cfg.normalize: feats = torch.nn.functional.layer_norm(feats, feats.shape) with torch.no_grad(): with torch.inference_mode():...
35
236
152
388
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...
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...
25,223
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/dphubert/components.py
94,99
64,137
forward
ConvLayerBlock
107,122
99,122
class ConvLayerBlock(Module): """Convolution unit of FeatureExtractor""" def __init__( self, in_channels: int, out_channels: int, kernel_size: int, stride: int, bias: bool, layer_norm: Optional[Module], prune_conv_channels: bool = False, ): ...
class ConvLayerBlock(Module): """Convolution unit of FeatureExtractor""" def __init__( self, in_channels: int, out_channels: int, kernel_size: int, stride: int, bias: bool, layer_norm: Optional[Module], prune_conv_channels: bool = False, ): ...
x = self.conv(x) if self.layer_norm is not None: x = self.layer_norm(x) x = nn.functional.gelu(x) if self.hard_concrete is not None: channel_mask = self.hard_concrete() # hard concrete mask, (out_channels,) x = x * channel_mask.unsqueeze(-1) ...
""" Args: x (Tensor): Shape: ``[batch, in_channels, in_frame]``. length (Tensor or None, optional): Shape ``[batch, ]``. Returns: Tensor: Shape ``[batch, out_channels, out_frames]``. Optional[Tensor]: Shape ``[batch, ]``. """ x = se...
69
571
213
784
"""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...
"""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...
25,224
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/dphubert/components.py
319,320
280,336
forward
ConvolutionalPositionalEmbedding
327,336
320,336
class ConvolutionalPositionalEmbedding(Module): """Positional embedding which is placed at the beginning of Transformer. Args: embed_dim (int): Feature dimension of the input Tensor. kernel_size (int): The number of frames to be use. groups (int): The number of groups in feature dimensi...
class ConvolutionalPositionalEmbedding(Module): """Positional embedding which is placed at the beginning of Transformer. Args: embed_dim (int): Feature dimension of the input Tensor. kernel_size (int): The number of frames to be use. groups (int): The number of groups in feature dimensi...
x = x.transpose(-2, -1) x = self.conv(x) if self.num_remove > 0: x = x[..., : -self.num_remove] x = torch.nn.functional.gelu(x) x = x.transpose(-2, -1) return x
""" Args: x (Tensor): shape ``[batch, frame, feature]``. Returns: Tensor: The resulting feature. Shape ``[batch, frame, feature]``. """ x = x.transpose(-2, -1) x = self.conv(x) if self.num_remove > 0: x = x[..., : -self.num_rem...
25
553
98
651
"""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...
"""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...
25,225
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/dphubert/components.py
968,973
958,1020
_preprocess
Encoder
973,986
973,986
class Encoder(Module): def __init__( self, feature_projection: Module, transformer: Module, ): super().__init__() self.feature_projection = feature_projection self.transformer = transformer def _preprocess( self, features: Tensor, leng...
class Encoder(Module): def __init__( self, feature_projection: Module, transformer: Module, ): super().__init__() self.feature_projection = feature_projection self.transformer = transformer def _preprocess( self, features: Tensor, leng...
x = self.feature_projection(features) mask: Optional[Tensor] = None if lengths is not None: batch_size, max_len, _ = x.shape # create mask for padded elements and zero-out them mask = torch.arange(max_len, device=lengths.device).expand(batch_size, max_len) >=...
x = self.feature_projection(features) mask: Optional[Tensor] = None if lengths is not None: batch_size, max_len, _ = x.shape # create mask for padded elements and zero-out them mask = torch.arange(max_len, device=lengths.device).expand(batch_size, max_len) >=...
64
500
196
696
"""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...
"""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...
25,226
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/dphubert/components.py
814,821
794,868
forward
EncoderLayer
835,859
821,859
class EncoderLayer(Module): """A layer unit in encoder. Combines multihead self attention and feed forward.""" def __init__( self, attention: Optional[Module], # can be None if the entire layer is pruned dropout: float, layer_norm_first: bool, feed_forward: Optional[M...
class EncoderLayer(Module): """A layer unit in encoder. Combines multihead self attention and feed forward.""" def __init__( self, attention: Optional[Module], # can be None if the entire layer is pruned dropout: float, layer_norm_first: bool, feed_forward: Optional[M...
if self.attention is not None: residual = x if self.layer_norm_first: x = self.layer_norm(x) x, position_bias = self.attention( x, attention_mask=attention_mask, position_bias=position_bias, key_padding_mask=key_padding_mask ) ...
""" Args: x (Tensor): Input of shape ``(batch, sequence_length, embed_dim)``. attention_mask (Tensor or ``None``, optional): attention mask of shape ``(batch, 1, sequence_length, sequence_length)``. (Default: ``None``) position_bias (Tensor or ``None``...
80
643
271
914
"""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...
"""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...
25,227
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/dphubert/components.py
198,199
137,238
prune
FeatureExtractor
202,238
199,238
class FeatureExtractor(Module): """Extract features from audio Args: conv_layers (nn.ModuleList): convolution layers """ def __init__( self, conv_layers: nn.ModuleList, ): super().__init__() self.conv_layers = conv_layers # NOTE: a dummy...
class FeatureExtractor(Module): """Extract features from audio Args: conv_layers (nn.ModuleList): convolution layers """ def __init__( self, conv_layers: nn.ModuleList, ): super().__init__() self.conv_layers = conv_layers # NOTE: a dummy...
new_config = [] # [(output_channel, kernel_size, stride), ...] for idx, layer in enumerate(self.conv_layers): if layer.hard_concrete is not None: assert not layer.hard_concrete.training mask = layer.hard_concrete() # (out_features,) inde...
""""Prune conv layers and dummy weight based on hardconcrete parameters. This is an in-place operation. """ new_config = [] # [(output_channel, kernel_size, stride), ...] for idx, layer in enumerate(self.conv_layers): if layer.hard_concrete is not None: ...
109
637
487
1,124
"""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...
"""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...
25,228
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/dphubert/components.py
276,277
238,280
get_num_params
FeatureProjection
277,280
277,280
class FeatureProjection(Module): """Layer that connects FeatureExtractor and Encoder Projects features to encoder dimension. Args: in_features (int): Input feature dim. out_features (int): Output feature dim. dropout (float): Dropout probability. """ def __init__( ...
class FeatureProjection(Module): """Layer that connects FeatureExtractor and Encoder Projects features to encoder dimension. Args: in_features (int): Input feature dim. out_features (int): Output feature dim. dropout (float): Dropout probability. """ def __init__( ...
return in_features * 2 + (in_features + 1) * self.projection.out_features
return in_features * 2 + (in_features + 1) * self.projection.out_features
10
318
31
349
"""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...
"""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...
25,229
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/dphubert/components.py
763,764
696,794
prune
FeedForward
764,794
764,794
class FeedForward(Module): """Layer that follows attention layer in encoder layer.""" def __init__( self, io_features: int, intermediate_features: int, intermediate_dropout: float, output_dropout: float, prune_intermediate: bool = False, prune_layer: bool...
class FeedForward(Module): """Layer that follows attention layer in encoder layer.""" def __init__( self, io_features: int, intermediate_features: int, intermediate_dropout: float, output_dropout: float, prune_intermediate: bool = False, prune_layer: bool...
new_config = { "use_feed_forward": True, "ff_interm_features": self.intermediate_dense.out_features } if self.hard_concrete_for_layer is not None: assert not self.hard_concrete_for_layer.training layer_mask = self.hard_concrete_for_layer() ...
new_config = { "use_feed_forward": True, "ff_interm_features": self.intermediate_dense.out_features } if self.hard_concrete_for_layer is not None: assert not self.hard_concrete_for_layer.training layer_mask = self.hard_concrete_for_layer() ...
79
757
429
1,186
"""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...
"""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...
25,230
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/dphubert/components.py
1408,1410
1401,1411
backward
GradMultiply
1410,1411
1410,1411
class GradMultiply(torch.autograd.Function): @staticmethod def forward(ctx, x, scale): ctx.scale = scale res = x.new(x) return res @staticmethod def backward(ctx, grad): FILL_FUNC_BODY
class GradMultiply(torch.autograd.Function): @staticmethod def forward(ctx, x, scale): ctx.scale = scale res = x.new(x) return res @staticmethod def backward(ctx, grad): FILL_FUNC_BODY
return grad * ctx.scale, None
return grad * ctx.scale, None
5
78
11
89
"""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...
"""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...
25,231
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/dphubert/components.py
57,58
54,64
forward
LayerNorm
58,64
58,64
class LayerNorm(nn.LayerNorm): """Layer norm with transpose""" def forward(self, input: Tensor) -> Tensor: FILL_FUNC_BODY
class LayerNorm(nn.LayerNorm): """Layer norm with transpose""" def forward(self, input: Tensor) -> Tensor: FILL_FUNC_BODY
x = input.transpose(-2, -1) x = nn.functional.layer_norm(x, self.normalized_shape, self.weight, self.bias, self.eps) x = x.transpose(-2, -1) return x
x = input.transpose(-2, -1) x = nn.functional.layer_norm(x, self.normalized_shape, self.weight, self.bias, self.eps) x = x.transpose(-2, -1) return x
17
48
76
124
"""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...
"""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...
25,233
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/dphubert/components.py
936,937
868,958
prune
Transformer
937,958
937,958
class Transformer(Module): def __init__( self, pos_conv_embed: Module, dropout: float, layers: Module, layer_norm_first: bool, layer_drop: float, ): super().__init__() self.pos_conv_embed = pos_conv_embed self.layer_norm = nn.LayerNorm(pos_...
class Transformer(Module): def __init__( self, pos_conv_embed: Module, dropout: float, layers: Module, layer_norm_first: bool, layer_drop: float, ): super().__init__() self.pos_conv_embed = pos_conv_embed self.layer_norm = nn.LayerNorm(pos_...
new_config = defaultdict(list) for layer in self.layers: attention_config = layer.attention.prune() new_config["use_attention"].append(attention_config["use_attention"]) if "remaining_heads" in attention_config: new_config["remaining_heads"].append(att...
new_config = defaultdict(list) for layer in self.layers: attention_config = layer.attention.prune() new_config["use_attention"].append(attention_config["use_attention"]) if "remaining_heads" in attention_config: new_config["remaining_heads"].append(att...
37
723
266
989
"""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...
"""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...
25,235
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc
/home/hieuvd/dung_repo/raw/stars_01/svc-develop-team_so-vits-svc/so-vits-svc/vencoder/dphubert/hardconcrete.py
70,71
14,123
reset_parameters
HardConcrete
72,76
71,76
class HardConcrete(nn.Module): """A HarcConcrete module. Use this module to create a mask of size N, which you can then use to perform L0 regularization. To obtain a mask, simply run a forward pass through the module with no input data. The mask is sampled in training mode, and fixed during eva...
class HardConcrete(nn.Module): """A HarcConcrete module. Use this module to create a mask of size N, which you can then use to perform L0 regularization. To obtain a mask, simply run a forward pass through the module with no input data. The mask is sampled in training mode, and fixed during eva...
self.compiled_mask = None mean = math.log(1 - self.init_mean) - math.log(self.init_mean) self.log_alpha.data.normal_(mean, self.init_std)
"""Reset the parameters of this module.""" self.compiled_mask = None mean = math.log(1 - self.init_mean) - math.log(self.init_mean) self.log_alpha.data.normal_(mean, self.init_std)
12
1,110
62
1,172
"""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...
"""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...