Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] encoding阶段生成的codec.txt, 无法直接读取? #34

Open
zyy-fc opened this issue Mar 26, 2024 · 1 comment
Open

[bug] encoding阶段生成的codec.txt, 无法直接读取? #34

zyy-fc opened this issue Mar 26, 2024 · 1 comment

Comments

@zyy-fc
Copy link

zyy-fc commented Mar 26, 2024

按照提供的encoding_decoding.sh脚本,encoding阶段会生成codec.txt文件

这个文件的形式类似于:
utts_id "空格" json.dumps(codecs)

这个形式无法被read_text.py直接读取,需要改写“load_jsonl_trans_int”函数,如下

def load_jsonl_trans_int(path: Union[Path, str]) -> Dict[str, np.ndarray]: d = read_2column_text(path) retval = {} for k, v in d.items(): try: value = json.loads(v) if isinstance(value, dict): retval[k] = np.array(value["trans"], dtype=int) elif isinstance(value, list): retval[k] = np.array(value, dtype=int) else: raise TypeError except TypeError: logging.error(f'Error happened with path="{path}", id="{k}", value="{v}"') raise return retval

@zyy-fc zyy-fc changed the title encoding阶段生成的codec.txt, 无法直接读取? [bug] encoding阶段生成的codec.txt, 无法直接读取? Mar 26, 2024
@ZhihaoDU
Copy link
Collaborator

Thanks for your report. As expect, the codec.txt should be loaded with load_codec_json function in funcodec/datasets/iterable_dataset.py. The function load_jsonl_trans_int in read_text.py is not used to load codec tokens. Thanks for your modification as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants