Refactor: rename text_processing to nlp
"text_processing" is clearer, but the import statement is longer. "nlp" is shorter and makes it clear that it is natural language processing.
This commit is contained in:
@@ -23,7 +23,7 @@ DEFAULT_BERT_TOKENIZER_PATHS = {
|
||||
}
|
||||
|
||||
# デフォルトのユーザー辞書ディレクトリ
|
||||
## style_bert_vits2.text_processing.japanese.user_dict モジュールのデフォルト値として利用される
|
||||
## style_bert_vits2.nlp.japanese.user_dict モジュールのデフォルト値として利用される
|
||||
## ライブラリとしての利用などで外部のユーザー辞書を指定したい場合は、user_dict 以下の各関数の実行時、引数に辞書データファイルのパスを指定する
|
||||
DEFAULT_USER_DICT_DIR = BASE_DIR / "dict_data"
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ from style_bert_vits2.logging import logger
|
||||
from style_bert_vits2.models import commons
|
||||
from style_bert_vits2.models.models import SynthesizerTrn
|
||||
from style_bert_vits2.models.models_jp_extra import SynthesizerTrn as SynthesizerTrnJPExtra
|
||||
from style_bert_vits2.text_processing import clean_text, cleaned_text_to_sequence, extract_bert_feature
|
||||
from style_bert_vits2.text_processing.symbols import SYMBOLS
|
||||
from style_bert_vits2.nlp import clean_text, cleaned_text_to_sequence, extract_bert_feature
|
||||
from style_bert_vits2.nlp.symbols import SYMBOLS
|
||||
|
||||
|
||||
def get_net_g(model_path: str, version: str, device: str, hps):
|
||||
|
||||
@@ -11,7 +11,7 @@ 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.commons import get_padding, init_weights
|
||||
from style_bert_vits2.text_processing.symbols import NUM_LANGUAGES, NUM_TONES, SYMBOLS
|
||||
from style_bert_vits2.nlp.symbols import NUM_LANGUAGES, NUM_TONES, SYMBOLS
|
||||
|
||||
|
||||
class DurationDiscriminator(nn.Module): # vits2
|
||||
|
||||
@@ -10,7 +10,7 @@ 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.text_processing.symbols import SYMBOLS, NUM_TONES, NUM_LANGUAGES
|
||||
from style_bert_vits2.nlp.symbols import SYMBOLS, NUM_TONES, NUM_LANGUAGES
|
||||
|
||||
|
||||
class DurationDiscriminator(nn.Module): # vits2
|
||||
|
||||
@@ -2,7 +2,7 @@ import torch
|
||||
from typing import Optional
|
||||
|
||||
from style_bert_vits2.constants import Languages
|
||||
from style_bert_vits2.text_processing.symbols import (
|
||||
from style_bert_vits2.nlp.symbols import (
|
||||
LANGUAGE_ID_MAP,
|
||||
LANGUAGE_TONE_START_MAP,
|
||||
SYMBOLS,
|
||||
@@ -36,11 +36,11 @@ def extract_bert_feature(
|
||||
"""
|
||||
|
||||
if language == Languages.JP:
|
||||
from style_bert_vits2.text_processing.japanese.bert_feature import extract_bert_feature
|
||||
from style_bert_vits2.nlp.japanese.bert_feature import extract_bert_feature
|
||||
elif language == Languages.EN:
|
||||
from style_bert_vits2.text_processing.english.bert_feature import extract_bert_feature
|
||||
from style_bert_vits2.nlp.english.bert_feature import extract_bert_feature
|
||||
elif language == Languages.ZH:
|
||||
from style_bert_vits2.text_processing.chinese.bert_feature import extract_bert_feature
|
||||
from style_bert_vits2.nlp.chinese.bert_feature import extract_bert_feature
|
||||
else:
|
||||
raise ValueError(f"Language {language} not supported")
|
||||
|
||||
@@ -68,15 +68,15 @@ def clean_text(
|
||||
|
||||
# Changed to import inside if condition to avoid unnecessary import
|
||||
if language == Languages.JP:
|
||||
from style_bert_vits2.text_processing.japanese import g2p, normalize_text
|
||||
from style_bert_vits2.nlp.japanese import g2p, normalize_text
|
||||
norm_text = normalize_text(text)
|
||||
phones, tones, word2ph = g2p(norm_text, use_jp_extra, raise_yomi_error)
|
||||
elif language == Languages.EN:
|
||||
from style_bert_vits2.text_processing.english import g2p, normalize_text
|
||||
from style_bert_vits2.nlp.english import g2p, normalize_text
|
||||
norm_text = normalize_text(text)
|
||||
phones, tones, word2ph = g2p(norm_text)
|
||||
elif language == Languages.ZH:
|
||||
from style_bert_vits2.text_processing.chinese import g2p, normalize_text
|
||||
from style_bert_vits2.nlp.chinese import g2p, normalize_text
|
||||
norm_text = normalize_text(text)
|
||||
phones, tones, word2ph = g2p(norm_text)
|
||||
else:
|
||||
@@ -5,8 +5,8 @@ import cn2an
|
||||
import jieba.posseg as psg
|
||||
from pypinyin import lazy_pinyin, Style
|
||||
|
||||
from style_bert_vits2.text_processing.chinese.tone_sandhi import ToneSandhi
|
||||
from style_bert_vits2.text_processing.symbols import PUNCTUATIONS
|
||||
from style_bert_vits2.nlp.chinese.tone_sandhi import ToneSandhi
|
||||
from style_bert_vits2.nlp.symbols import PUNCTUATIONS
|
||||
|
||||
|
||||
current_file_path = os.path.dirname(__file__)
|
||||
@@ -177,7 +177,7 @@ def normalize_text(text: str) -> str:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from style_bert_vits2.text_processing.chinese.bert_feature import extract_bert_feature
|
||||
from style_bert_vits2.nlp.chinese.bert_feature import extract_bert_feature
|
||||
|
||||
text = "啊!但是《原神》是由,米哈\游自主, [研发]的一款全.新开放世界.冒险游戏"
|
||||
text = normalize_text(text)
|
||||
@@ -5,7 +5,7 @@ import torch
|
||||
from transformers import PreTrainedModel
|
||||
|
||||
from style_bert_vits2.constants import Languages
|
||||
from style_bert_vits2.text_processing import bert_models
|
||||
from style_bert_vits2.nlp import bert_models
|
||||
|
||||
|
||||
__models: dict[torch.device | str, PreTrainedModel] = {}
|
||||
@@ -4,8 +4,8 @@ import re
|
||||
from g2p_en import G2p
|
||||
|
||||
from style_bert_vits2.constants import Languages
|
||||
from style_bert_vits2.text_processing import bert_models
|
||||
from style_bert_vits2.text_processing.symbols import PUNCTUATIONS, SYMBOLS
|
||||
from style_bert_vits2.nlp import bert_models
|
||||
from style_bert_vits2.nlp.symbols import PUNCTUATIONS, SYMBOLS
|
||||
|
||||
|
||||
current_file_path = os.path.dirname(__file__)
|
||||
@@ -5,7 +5,7 @@ import torch
|
||||
from transformers import PreTrainedModel
|
||||
|
||||
from style_bert_vits2.constants import Languages
|
||||
from style_bert_vits2.text_processing import bert_models
|
||||
from style_bert_vits2.nlp import bert_models
|
||||
|
||||
|
||||
__models: dict[torch.device | str, PreTrainedModel] = {}
|
||||
2
style_bert_vits2/nlp/japanese/__init__.py
Normal file
2
style_bert_vits2/nlp/japanese/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from style_bert_vits2.nlp.japanese.g2p import g2p # noqa: F401
|
||||
from style_bert_vits2.nlp.japanese.normalizer import normalize_text # noqa: F401
|
||||
@@ -5,8 +5,8 @@ import torch
|
||||
from transformers import PreTrainedModel
|
||||
|
||||
from style_bert_vits2.constants import Languages
|
||||
from style_bert_vits2.text_processing import bert_models
|
||||
from style_bert_vits2.text_processing.japanese.g2p import text_to_sep_kata
|
||||
from style_bert_vits2.nlp import bert_models
|
||||
from style_bert_vits2.nlp.japanese.g2p import text_to_sep_kata
|
||||
|
||||
|
||||
__models: dict[torch.device | str, PreTrainedModel] = {}
|
||||
@@ -2,11 +2,11 @@ import re
|
||||
|
||||
from style_bert_vits2.constants import Languages
|
||||
from style_bert_vits2.logging import logger
|
||||
from style_bert_vits2.text_processing import bert_models
|
||||
from style_bert_vits2.text_processing.japanese import pyopenjtalk_worker as pyopenjtalk
|
||||
from style_bert_vits2.text_processing.japanese.mora_list import MORA_KATA_TO_MORA_PHONEMES
|
||||
from style_bert_vits2.text_processing.japanese.normalizer import replace_punctuation
|
||||
from style_bert_vits2.text_processing.symbols import PUNCTUATIONS
|
||||
from style_bert_vits2.nlp import bert_models
|
||||
from style_bert_vits2.nlp.japanese import pyopenjtalk_worker as pyopenjtalk
|
||||
from style_bert_vits2.nlp.japanese.mora_list import MORA_KATA_TO_MORA_PHONEMES
|
||||
from style_bert_vits2.nlp.japanese.normalizer import replace_punctuation
|
||||
from style_bert_vits2.nlp.symbols import PUNCTUATIONS
|
||||
|
||||
pyopenjtalk.initialize()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from style_bert_vits2.text_processing.japanese.g2p import g2p
|
||||
from style_bert_vits2.text_processing.japanese.mora_list import (
|
||||
from style_bert_vits2.nlp.japanese.g2p import g2p
|
||||
from style_bert_vits2.nlp.japanese.mora_list import (
|
||||
MORA_KATA_TO_MORA_PHONEMES,
|
||||
MORA_PHONEMES_TO_MORA_KATA,
|
||||
)
|
||||
from style_bert_vits2.text_processing.symbols import PUNCTUATIONS
|
||||
from style_bert_vits2.nlp.symbols import PUNCTUATIONS
|
||||
|
||||
|
||||
def g2kata_tone(norm_text: str) -> list[tuple[str, int]]:
|
||||
@@ -2,7 +2,7 @@ import re
|
||||
import unicodedata
|
||||
from num2words import num2words
|
||||
|
||||
from style_bert_vits2.text_processing.symbols import PUNCTUATIONS
|
||||
from style_bert_vits2.nlp.symbols import PUNCTUATIONS
|
||||
|
||||
|
||||
def normalize_text(text: str) -> str:
|
||||
@@ -6,8 +6,8 @@ to avoid user dictionary access error
|
||||
from typing import Any, Optional
|
||||
|
||||
from style_bert_vits2.logging import logger
|
||||
from style_bert_vits2.text_processing.japanese.pyopenjtalk_worker.worker_client import WorkerClient
|
||||
from style_bert_vits2.text_processing.japanese.pyopenjtalk_worker.worker_common import WORKER_PORT
|
||||
from style_bert_vits2.nlp.japanese.pyopenjtalk_worker.worker_client import WorkerClient
|
||||
from style_bert_vits2.nlp.japanese.pyopenjtalk_worker.worker_common import WORKER_PORT
|
||||
|
||||
|
||||
WORKER_CLIENT: Optional[WorkerClient] = None
|
||||
@@ -1,7 +1,7 @@
|
||||
import argparse
|
||||
|
||||
from style_bert_vits2.text_processing.japanese.pyopenjtalk_worker.worker_common import WORKER_PORT
|
||||
from style_bert_vits2.text_processing.japanese.pyopenjtalk_worker.worker_server import WorkerServer
|
||||
from style_bert_vits2.nlp.japanese.pyopenjtalk_worker.worker_common import WORKER_PORT
|
||||
from style_bert_vits2.nlp.japanese.pyopenjtalk_worker.worker_server import WorkerServer
|
||||
|
||||
|
||||
def main() -> None:
|
||||
@@ -2,7 +2,7 @@ import socket
|
||||
from typing import Any, cast
|
||||
|
||||
from style_bert_vits2.logging import logger
|
||||
from style_bert_vits2.text_processing.japanese.pyopenjtalk_worker.worker_common import RequestType, receive_data, send_data
|
||||
from style_bert_vits2.nlp.japanese.pyopenjtalk_worker.worker_common import RequestType, receive_data, send_data
|
||||
|
||||
|
||||
class WorkerClient:
|
||||
@@ -6,7 +6,7 @@ from typing import Any, cast
|
||||
import pyopenjtalk
|
||||
|
||||
from style_bert_vits2.logging import logger
|
||||
from style_bert_vits2.text_processing.japanese.pyopenjtalk_worker.worker_common import (
|
||||
from style_bert_vits2.nlp.japanese.pyopenjtalk_worker.worker_common import (
|
||||
ConnectionClosedException,
|
||||
RequestType,
|
||||
receive_data,
|
||||
@@ -16,9 +16,9 @@ import numpy as np
|
||||
from fastapi import HTTPException
|
||||
|
||||
from style_bert_vits2.constants import DEFAULT_USER_DICT_DIR
|
||||
from style_bert_vits2.text_processing.japanese import pyopenjtalk_worker as pyopenjtalk
|
||||
from style_bert_vits2.text_processing.japanese.user_dict.word_model import UserDictWord, WordTypes
|
||||
from style_bert_vits2.text_processing.japanese.user_dict.part_of_speech_data import MAX_PRIORITY, MIN_PRIORITY, part_of_speech_data
|
||||
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
|
||||
|
||||
pyopenjtalk.initialize()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
from typing import Dict
|
||||
|
||||
from style_bert_vits2.text_processing.japanese.user_dict.word_model import (
|
||||
from style_bert_vits2.nlp.japanese.user_dict.word_model import (
|
||||
USER_DICT_MAX_PRIORITY,
|
||||
USER_DICT_MIN_PRIORITY,
|
||||
PartOfSpeechDetail,
|
||||
@@ -1,2 +0,0 @@
|
||||
from style_bert_vits2.text_processing.japanese.g2p import g2p # noqa: F401
|
||||
from style_bert_vits2.text_processing.japanese.normalizer import normalize_text # noqa: F401
|
||||
Reference in New Issue
Block a user