Fix: ensure encoding utf-8

This commit is contained in:
litagin02
2024-03-11 09:27:36 +09:00
parent 03d4b4c97e
commit 42ee7d7608
2 changed files with 6 additions and 6 deletions

View File

@@ -9,7 +9,7 @@ from style_bert_vits2.logging import logger
def download_bert_models(): def download_bert_models():
with open("bert/bert_models.json", "r") as fp: with open("bert/bert_models.json", "r", encoding="utf-8") as fp:
models = json.load(fp) models = json.load(fp)
for k, v in models.items(): for k, v in models.items():
local_path = Path("bert").joinpath(k) local_path = Path("bert").joinpath(k)

View File

@@ -53,11 +53,11 @@ class HyperParametersData(BaseModel):
n_speakers: int = 512 n_speakers: int = 512
cleaned_text: bool = True cleaned_text: bool = True
spk2id: dict[str, int] = { spk2id: dict[str, int] = {
"Dummy": 0, "Dummy": 0,
} }
num_styles: int = 1 num_styles: int = 1
style2id: dict[str, int] = { style2id: dict[str, int] = {
"Neutral": 0, "Neutral": 0,
} }
@@ -68,6 +68,7 @@ class HyperParametersModelSLM(BaseModel):
nlayers: int = 13 nlayers: int = 13
initial_channel: int = 64 initial_channel: int = 64
class HyperParametersModel(BaseModel): class HyperParametersModel(BaseModel):
use_spk_conditioned_encoder: bool = True use_spk_conditioned_encoder: bool = True
use_noise_scaled_mas: bool = True use_noise_scaled_mas: bool = True
@@ -98,7 +99,7 @@ class HyperParametersModel(BaseModel):
class HyperParameters(BaseModel): class HyperParameters(BaseModel):
model_name: str = 'Dummy' model_name: str = "Dummy"
version: str = "2.0-JP-Extra" version: str = "2.0-JP-Extra"
train: HyperParametersTrain = HyperParametersTrain() train: HyperParametersTrain = HyperParametersTrain()
data: HyperParametersData = HyperParametersData() data: HyperParametersData = HyperParametersData()
@@ -112,7 +113,6 @@ class HyperParameters(BaseModel):
# model_ 以下を Pydantic の保護対象から除外する # model_ 以下を Pydantic の保護対象から除外する
model_config = ConfigDict(protected_namespaces=()) model_config = ConfigDict(protected_namespaces=())
@staticmethod @staticmethod
def load_from_json(json_path: Union[str, Path]) -> "HyperParameters": def load_from_json(json_path: Union[str, Path]) -> "HyperParameters":
""" """
@@ -125,5 +125,5 @@ class HyperParameters(BaseModel):
HyperParameters: ハイパーパラメータ HyperParameters: ハイパーパラメータ
""" """
with open(json_path, "r") as f: with open(json_path, "r", encoding="utf-8") as f:
return HyperParameters.model_validate_json(f.read()) return HyperParameters.model_validate_json(f.read())