---
title: fst_itn_zh
canonical_url: "https://www.modelscope.cn/models/thuduj12/fst_itn_zh"
md_url: "https://www.modelscope.cn/models/thuduj12/fst_itn_zh.md"
repository: thuduj12/fst_itn_zh
chinese_name: "基于FST的中文ITN"
last_updated: 2023-09-14
license: "Apache License 2.0"
pipeline_tag: inverse-text-processing
tasks:
  - inverse-text-processing
library_name:
  - c++
frameworks:
  - C++
downloads: 60000502
stars: 34
---

# fst_itn_zh

> fst_itn_zh - thuduj12 在 ModelScope 开源的模型。基于规则的文本反正则（ITN）模型，由https://github.com/wenet-e2e/WeTextProcessing构建，可用于CPP-runtime。

thuduj12/fst_itn_zh 是 ModelScope 魔搭社区上的inverse-text-processing模型，采用 Apache License 2.0 许可。

- **Repository**: thuduj12/fst_itn_zh
- **License**: Apache License 2.0
- **Tasks**: inverse-text-processing
- **Downloads**: 60000502
- **Stars**: 34
- **Last updated**: 2023-09-14

Source: https://www.modelscope.cn/models/thuduj12/fst_itn_zh

---

基于openfst构建的，自定义规则的ITN模型。
使用[WeTextProcessing](https://github.com/wenet-e2e/WeTextProcessing)构建。
# 模型下载
```bash
 git clone https://www.modelscope.cn/thuduj12/fst_itn_zh.git
```

# 模型生成
如果想使用原始开源版本定义的规则，可以使用如下代码
```bash 
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中使用
```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)和[Wenet](https://github.com/wenet-e2e/wenet)的支持还在开发中，
### FunASR
可以参考 https://github.com/alibaba-damo-academy/FunASR/pull/884

### Wenet
可以参考 https://github.com/wenet-e2e/wenet/pull/2001
