[fix] encoding
This commit is contained in:
+1
-4
@@ -6,16 +6,13 @@ import random
|
|||||||
DEFAULT_ROOT_DIR = "examples/input_params"
|
DEFAULT_ROOT_DIR = "examples/input_params"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DataSampler:
|
class DataSampler:
|
||||||
def __init__(self, root_dir=DEFAULT_ROOT_DIR):
|
def __init__(self, root_dir=DEFAULT_ROOT_DIR):
|
||||||
self.root_dir = root_dir
|
self.root_dir = root_dir
|
||||||
|
|
||||||
# glob
|
|
||||||
self.input_params_files = list(Path(self.root_dir).glob("*.json"))
|
self.input_params_files = list(Path(self.root_dir).glob("*.json"))
|
||||||
|
|
||||||
def load_json(self, file_path):
|
def load_json(self, file_path):
|
||||||
with open(file_path, "r") as f:
|
with open(file_path, "r", encoding="utf-8") as f:
|
||||||
return json.load(f)
|
return json.load(f)
|
||||||
|
|
||||||
def sample(self):
|
def sample(self):
|
||||||
|
|||||||
@@ -1166,7 +1166,7 @@ if __name__ == "__main__":
|
|||||||
)
|
)
|
||||||
|
|
||||||
ndone = 0
|
ndone = 0
|
||||||
with open(args.ifile, "r", encoding="utf8") as istream, open(args.ofile, "w+", encoding="utf8") as ostream:
|
with open(args.ifile, "r", encoding="utf-8") as istream, open(args.ofile, "w+", encoding="utf-8") as ostream:
|
||||||
if args.format == "tsv":
|
if args.format == "tsv":
|
||||||
reader = csv.DictReader(istream, delimiter="\t")
|
reader = csv.DictReader(istream, delimiter="\t")
|
||||||
assert "TEXT" in reader.fieldnames
|
assert "TEXT" in reader.fieldnames
|
||||||
|
|||||||
@@ -1172,7 +1172,7 @@ class ACEStepPipeline:
|
|||||||
for output_audio_path in output_paths:
|
for output_audio_path in output_paths:
|
||||||
input_params_json_save_path = output_audio_path.replace(f".{format}", "_input_params.json")
|
input_params_json_save_path = output_audio_path.replace(f".{format}", "_input_params.json")
|
||||||
input_params_json["audio_path"] = output_audio_path
|
input_params_json["audio_path"] = output_audio_path
|
||||||
with open(input_params_json_save_path, "w") as f:
|
with open(input_params_json_save_path, "w", encoding="utf-8") as f:
|
||||||
json.dump(input_params_json, f, indent=4, ensure_ascii=False)
|
json.dump(input_params_json, f, indent=4, ensure_ascii=False)
|
||||||
|
|
||||||
return output_paths + [input_params_json]
|
return output_paths + [input_params_json]
|
||||||
|
|||||||
+2
-2
@@ -74,7 +74,7 @@ class Pipeline(LightningModule):
|
|||||||
from peft import LoraConfig
|
from peft import LoraConfig
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ImportError("Please install peft library to use LoRA training")
|
raise ImportError("Please install peft library to use LoRA training")
|
||||||
with open(lora_config_path) as f:
|
with open(lora_config_path, encoding="utf-8") as f:
|
||||||
lora_config = json.load(f)
|
lora_config = json.load(f)
|
||||||
lora_config = LoraConfig(**lora_config)
|
lora_config = LoraConfig(**lora_config)
|
||||||
transformers.add_adapter(adapter_config=lora_config)
|
transformers.add_adapter(adapter_config=lora_config)
|
||||||
@@ -626,7 +626,7 @@ class Pipeline(LightningModule):
|
|||||||
os.makedirs(save_dir, exist_ok=True)
|
os.makedirs(save_dir, exist_ok=True)
|
||||||
torchaudio.save(f"{save_dir}/target_wav_{key}_{i}.flac", target_wav.float().cpu(), sr)
|
torchaudio.save(f"{save_dir}/target_wav_{key}_{i}.flac", target_wav.float().cpu(), sr)
|
||||||
torchaudio.save(f"{save_dir}/pred_wav_{key}_{i}.flac", pred_wav.float().cpu(), sr)
|
torchaudio.save(f"{save_dir}/pred_wav_{key}_{i}.flac", pred_wav.float().cpu(), sr)
|
||||||
with open(f"{save_dir}/key_prompt_lyric_{key}_{i}.txt", "w") as f:
|
with open(f"{save_dir}/key_prompt_lyric_{key}_{i}.txt", "w", encoding="utf-8") as f:
|
||||||
f.write(key_prompt_lyric)
|
f.write(key_prompt_lyric)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user