基于FST的中文ITN 已完整同步
基于openfst构建的,自定义规则的ITN模型。 使用WeTextProcessing构建。
模型下载
git clone https://www.modelscope.cn/thuduj12/fst_itn_zh.git
模型生成
如果想使用原始开源版本定义的规则,可以使用如下代码
git clone https://github.com/wenet-e2e/WeTextProcessing.git
cd WeTextProcessing
python -m itn --text "二点五平方电线" --overwrite_cache
运行后在WeTextProcessing/itn下会生成两个fst文件。
如果需要自定义规则,则需要修改WeTextProcessing/itn/chinese/xxx.py文件, 然后再基于新的规则,重新构建,并覆盖之前构建的模型。
模型使用
Python中使用
>>> from itn.chinese.inverse_normalizer import InverseNormalizer
>>> invnormalizer = InverseNormalizer(cache_dir="/path/to/your/itn")
>>> result = invnormalizer.normalize("二点五平方电线")
>>> print(result)
Cpp Runtime
FunASR
可以参考 https://github.com/alibaba-damo-academy/FunASR/pull/884
Wenet
5 个文件
浏览文件数据集版权信息
本数据集的许可证为 Apache License 2.0。如有违反相关条款,请联系 WEHUB,我们将及时处理。 查看许可证
下载数据集
通过 WeHub CLI 下载当前数据集快照。下列命令会固定为当前页面展示的数据版本(如果页面提供版本)。文件字节由本机直连存储下载,浏览器不会签发或保存下载链接。
前置要求
需要 Node.js 18 及以上,以及 npm(或 npx)。
1. 安装 CLI
npm install -g wehub-cli@latest
2. 下载此数据集
wehub datasets download ds_thuduj12_fst_itn_zh_609ecb3c76 --revision c68f5aee5ed480e9cefb8af9758d5a1a05f8dd18 --output ./ds_thuduj12_fst_itn_zh_609ecb3c76
若中断或部分失败,在同一目录重新执行同一命令即可续传。默认会校验 SHA-256。
免全局安装
npx --yes wehub-cli@latest datasets download ds_thuduj12_fst_itn_zh_609ecb3c76 --revision c68f5aee5ed480e9cefb8af9758d5a1a05f8dd18 --output ./ds_thuduj12_fst_itn_zh_609ecb3c76
高级选项
以下为 wehub datasets download 已支持的参数示例:
强制重新下载,不复用已校验的本地文件
wehub datasets download ds_thuduj12_fst_itn_zh_609ecb3c76 --revision c68f5aee5ed480e9cefb8af9758d5a1a05f8dd18 --output ./ds_thuduj12_fst_itn_zh_609ecb3c76 --overwrite
仅包含匹配路径
wehub datasets download ds_thuduj12_fst_itn_zh_609ecb3c76 --revision c68f5aee5ed480e9cefb8af9758d5a1a05f8dd18 --output ./ds_thuduj12_fst_itn_zh_609ecb3c76 --include "*.jsonl"
排除匹配路径
wehub datasets download ds_thuduj12_fst_itn_zh_609ecb3c76 --revision c68f5aee5ed480e9cefb8af9758d5a1a05f8dd18 --output ./ds_thuduj12_fst_itn_zh_609ecb3c76 --exclude "*.md"
提高并发下载数
wehub datasets download ds_thuduj12_fst_itn_zh_609ecb3c76 --revision c68f5aee5ed480e9cefb8af9758d5a1a05f8dd18 --output ./ds_thuduj12_fst_itn_zh_609ecb3c76 --jobs 8
完整帮助:wehub datasets download --help