From 33c9c4f0f031e15c4e24f56c8d181286f6c60dc2 Mon Sep 17 00:00:00 2001 From: zxcd <228587199@qq.com> Date: Wed, 8 Feb 2023 07:39:32 +0000 Subject: [PATCH] add encoding=utf8 for text cli. --- paddlespeech/cli/text/infer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/paddlespeech/cli/text/infer.py b/paddlespeech/cli/text/infer.py index ff822f6745b..bd76a13d0a4 100644 --- a/paddlespeech/cli/text/infer.py +++ b/paddlespeech/cli/text/infer.py @@ -127,7 +127,7 @@ def _init_from_path(self, if self.task == 'punc': # punc list self._punc_list = [] - with open(self.vocab_file, 'r') as f: + with open(self.vocab_file, 'r', encoding='utf-8') as f: for line in f: self._punc_list.append(line.strip()) @@ -178,12 +178,12 @@ def _init_from_path_new(self, if self.task == 'punc': # punc list self._punc_list = [] - with open(self.vocab_file, 'r') as f: + with open(self.vocab_file, 'r', encoding='utf-8') as f: for line in f: self._punc_list.append(line.strip()) # model - with open(self.cfg_path) as f: + with open(self.cfg_path, 'r', encoding='utf-8') as f: config = CfgNode(yaml.safe_load(f)) self.model = ErnieLinear(**config["model"])