Skip to content

Commit

Permalink
Format import using isort --profile black --gitignore --lai 2 .
Browse files Browse the repository at this point in the history
  • Loading branch information
litagin02 committed Mar 11, 2024
1 parent 164b5c4 commit dada0af
Show file tree
Hide file tree
Showing 29 changed files with 50 additions and 35 deletions.
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from style_bert_vits2.logging import logger


# If not cuda available, set possible devices to cpu
cuda_available = torch.cuda.is_available()

Expand Down
1 change: 1 addition & 0 deletions data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from style_bert_vits2.models.utils import load_filepaths_and_text, load_wav_to_torch
from style_bert_vits2.nlp import cleaned_text_to_sequence


"""Multi speaker version"""


Expand Down
7 changes: 4 additions & 3 deletions default_style.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import json
import os
from style_bert_vits2.constants import DEFAULT_STYLE
from style_bert_vits2.logging import logger

import numpy as np
import json

from style_bert_vits2.constants import DEFAULT_STYLE
from style_bert_vits2.logging import logger


def set_style_config(json_path, output_path):
Expand Down
1 change: 1 addition & 0 deletions gen_yaml.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import os
import shutil

import yaml


Expand Down
4 changes: 3 additions & 1 deletion mel_processing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import warnings

import torch
import torch.utils.data
from librosa.filters import mel as librosa_mel_fn
import warnings


# warnings.simplefilter(action='ignore', category=FutureWarning)
warnings.filterwarnings(action="ignore")
Expand Down
4 changes: 3 additions & 1 deletion preprocess_all.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import argparse
from webui.train import preprocess_all
from multiprocessing import cpu_count

from webui.train import preprocess_all


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
Expand Down
1 change: 1 addition & 0 deletions preprocess_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from style_bert_vits2.nlp import clean_text
from style_bert_vits2.utils.stdout_wrapper import SAFE_STDOUT


preprocess_text_config = config.preprocess_text_config


Expand Down
3 changes: 2 additions & 1 deletion resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import soundfile
from tqdm import tqdm

from config import config
from style_bert_vits2.logging import logger
from style_bert_vits2.utils.stdout_wrapper import SAFE_STDOUT
from config import config


DEFAULT_BLOCK_SIZE: float = 0.400 # seconds

Expand Down
1 change: 1 addition & 0 deletions server_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from style_bert_vits2.nlp.japanese import pyopenjtalk_worker as pyopenjtalk
from style_bert_vits2.tts_model import TTSModel, TTSModelHolder


ln = config.server_config.language


Expand Down
1 change: 1 addition & 0 deletions slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from style_bert_vits2.logging import logger
from style_bert_vits2.utils.stdout_wrapper import SAFE_STDOUT


vad_model, utils = torch.hub.load(
repo_or_dir="snakers4/silero-vad",
model="silero_vad",
Expand Down
1 change: 1 addition & 0 deletions speech_mos.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from style_bert_vits2.logging import logger
from style_bert_vits2.tts_model import TTSModel


warnings.filterwarnings("ignore")

mos_result_dir = Path("mos_results")
Expand Down
2 changes: 1 addition & 1 deletion style_bert_vits2/models/attentions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import math
from typing import Any, Optional

import math
import torch
from torch import nn
from torch.nn import functional as F
Expand Down
3 changes: 2 additions & 1 deletion style_bert_vits2/models/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
コードと完全に一致している保証はない。あくまで参考程度とすること。
"""

from typing import Any, Optional, Union

import torch
from torch.nn import functional as F
from typing import Any, Optional, Union


def init_weights(m: torch.nn.Module, mean: float = 0.0, std: float = 0.01) -> None:
Expand Down
5 changes: 2 additions & 3 deletions style_bert_vits2/models/infer.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from typing import Any, cast, Optional, Union
from typing import Any, Optional, Union, cast

import torch
from numpy.typing import NDArray

from style_bert_vits2.constants import Languages
from style_bert_vits2.logging import logger
from style_bert_vits2.models import commons
from style_bert_vits2.models import utils
from style_bert_vits2.models import commons, utils
from style_bert_vits2.models.hyper_parameters import HyperParameters
from style_bert_vits2.models.models import SynthesizerTrn
from style_bert_vits2.models.models_jp_extra import (
Expand Down
5 changes: 1 addition & 4 deletions style_bert_vits2/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
from torch.nn import functional as F
from torch.nn.utils import remove_weight_norm, spectral_norm, weight_norm

from style_bert_vits2.models import attentions
from style_bert_vits2.models import commons
from style_bert_vits2.models import modules
from style_bert_vits2.models import monotonic_alignment
from style_bert_vits2.models import attentions, commons, modules, monotonic_alignment
from style_bert_vits2.nlp.symbols import NUM_LANGUAGES, NUM_TONES, SYMBOLS


Expand Down
5 changes: 1 addition & 4 deletions style_bert_vits2/models/models_jp_extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
from torch.nn import functional as F
from torch.nn.utils import remove_weight_norm, spectral_norm, weight_norm

from style_bert_vits2.models import attentions
from style_bert_vits2.models import commons
from style_bert_vits2.models import modules
from style_bert_vits2.models import monotonic_alignment
from style_bert_vits2.models import attentions, commons, modules, monotonic_alignment
from style_bert_vits2.nlp.symbols import NUM_LANGUAGES, NUM_TONES, SYMBOLS


Expand Down
5 changes: 3 additions & 2 deletions style_bert_vits2/models/monotonic_alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
コードと完全に一致している保証はない。あくまで参考程度とすること。
"""

from typing import Any

import numba
import torch
from numpy import int32, float32, zeros
from typing import Any
from numpy import float32, int32, zeros


def maximum_path(neg_cent: torch.Tensor, mask: torch.Tensor) -> torch.Tensor:
Expand Down
3 changes: 2 additions & 1 deletion style_bert_vits2/models/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import re
import subprocess
from pathlib import Path
from typing import Any, Optional, Union, TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Optional, Union

import numpy as np
import torch
Expand All @@ -15,6 +15,7 @@
from style_bert_vits2.models.utils import checkpoints # type: ignore
from style_bert_vits2.models.utils import safetensors # type: ignore


if TYPE_CHECKING:
# tensorboard はライブラリとしてインストールされている場合は依存関係に含まれないため、型チェック時のみインポートする
from torch.utils.tensorboard import SummaryWriter
Expand Down
7 changes: 4 additions & 3 deletions style_bert_vits2/nlp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, TYPE_CHECKING
from typing import TYPE_CHECKING, Optional

from style_bert_vits2.constants import Languages
from style_bert_vits2.nlp.symbols import (
Expand All @@ -7,6 +7,7 @@
SYMBOLS,
)


# __init__.py は配下のモジュールをインポートした時点で実行される
# PyTorch のインポートは重いので、型チェック時以外はインポートしない
if TYPE_CHECKING:
Expand Down Expand Up @@ -99,10 +100,10 @@ def cleaned_text_to_sequence(
cleaned_phones: list[str], tones: list[int], language: Languages
) -> tuple[list[int], list[int], list[int]]:
"""
テキスト文字列を、テキスト内の記号に対応する一連の ID に変換する
音素リスト・アクセントリスト・言語を、テキスト内の対応する ID に変換する
Args:
cleaned_phones (list[str]): clean_text() でクリーニングされた音素のリスト (?)
cleaned_phones (list[str]): clean_text() でクリーニングされた音素のリスト
tones (list[int]): 各音素のアクセント
language (Languages): テキストの言語
Expand Down
2 changes: 1 addition & 1 deletion style_bert_vits2/nlp/bert_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

import gc
from typing import cast, Optional, Union
from typing import Optional, Union, cast

import torch
from transformers import (
Expand Down
2 changes: 1 addition & 1 deletion style_bert_vits2/nlp/chinese/g2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path

import jieba.posseg as psg
from pypinyin import lazy_pinyin, Style
from pypinyin import Style, lazy_pinyin

from style_bert_vits2.nlp.chinese.tone_sandhi import ToneSandhi
from style_bert_vits2.nlp.symbols import PUNCTUATIONS
Expand Down
3 changes: 1 addition & 2 deletions style_bert_vits2/nlp/chinese/tone_sandhi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# limitations under the License.

import jieba
from pypinyin import lazy_pinyin
from pypinyin import Style
from pypinyin import Style, lazy_pinyin


class ToneSandhi:
Expand Down
1 change: 1 addition & 0 deletions style_bert_vits2/nlp/japanese/normalizer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
import unicodedata

from num2words import num2words

from style_bert_vits2.nlp.symbols import PUNCTUATIONS
Expand Down
3 changes: 2 additions & 1 deletion style_bert_vits2/nlp/japanese/user_dict/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@

from style_bert_vits2.constants import DEFAULT_USER_DICT_DIR
from style_bert_vits2.nlp.japanese import pyopenjtalk_worker as pyopenjtalk
from style_bert_vits2.nlp.japanese.user_dict.word_model import UserDictWord, WordTypes
from style_bert_vits2.nlp.japanese.user_dict.part_of_speech_data import (
MAX_PRIORITY,
MIN_PRIORITY,
part_of_speech_data,
)
from style_bert_vits2.nlp.japanese.user_dict.word_model import UserDictWord, WordTypes


# root_dir = engine_root()
# save_dir = get_save_dir()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
WordTypes,
)


MIN_PRIORITY = USER_DICT_MIN_PRIORITY
MAX_PRIORITY = USER_DICT_MAX_PRIORITY

Expand Down
1 change: 1 addition & 0 deletions style_bert_vits2/nlp/japanese/user_dict/word_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from pydantic import BaseModel, Field, validator


USER_DICT_MIN_PRIORITY = 0
USER_DICT_MAX_PRIORITY = 10

Expand Down
4 changes: 3 additions & 1 deletion style_gen.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import argparse
from concurrent.futures import ThreadPoolExecutor
import warnings
from concurrent.futures import ThreadPoolExecutor

import numpy as np
import torch
Expand All @@ -11,9 +11,11 @@
from style_bert_vits2.models.hyper_parameters import HyperParameters
from style_bert_vits2.utils.stdout_wrapper import SAFE_STDOUT


warnings.filterwarnings("ignore", category=UserWarning)
from pyannote.audio import Inference, Model


model = Model.from_pretrained("pyannote/wespeaker-voxceleb-resnet34-LM")
inference = Inference(model, window="whole")
device = torch.device(config.style_gen_config.device)
Expand Down
4 changes: 2 additions & 2 deletions train_ms.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
from losses import discriminator_loss, feature_loss, generator_loss, kl_loss
from mel_processing import mel_spectrogram_torch, spec_to_mel_torch
from style_bert_vits2.logging import logger
from style_bert_vits2.models import commons
from style_bert_vits2.models import utils
from style_bert_vits2.models import commons, utils
from style_bert_vits2.models.hyper_parameters import HyperParameters
from style_bert_vits2.models.models import (
DurationDiscriminator,
Expand All @@ -35,6 +34,7 @@
from style_bert_vits2.nlp.symbols import SYMBOLS
from style_bert_vits2.utils.stdout_wrapper import SAFE_STDOUT


torch.backends.cuda.matmul.allow_tf32 = True
torch.backends.cudnn.allow_tf32 = (
True # If encontered training problem,please try to disable TF32.
Expand Down
4 changes: 2 additions & 2 deletions train_ms_jp_extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
from losses import WavLMLoss, discriminator_loss, feature_loss, generator_loss, kl_loss
from mel_processing import mel_spectrogram_torch, spec_to_mel_torch
from style_bert_vits2.logging import logger
from style_bert_vits2.models import commons
from style_bert_vits2.models import utils
from style_bert_vits2.models import commons, utils
from style_bert_vits2.models.hyper_parameters import HyperParameters
from style_bert_vits2.models.models_jp_extra import (
DurationDiscriminator,
Expand All @@ -36,6 +35,7 @@
from style_bert_vits2.nlp.symbols import SYMBOLS
from style_bert_vits2.utils.stdout_wrapper import SAFE_STDOUT


torch.backends.cuda.matmul.allow_tf32 = True
torch.backends.cudnn.allow_tf32 = (
True # If encontered training problem,please try to disable TF32.
Expand Down

0 comments on commit dada0af

Please sign in to comment.