---
title: asr_speech_post_processing_itn-en
canonical_url: "https://www.modelscope.cn/models/iic/asr_speech_post_processing_itn-en"
md_url: "https://www.modelscope.cn/models/iic/asr_speech_post_processing_itn-en.md"
repository: iic/asr_speech_post_processing_itn-en
chinese_name: "英文文本反正则化"
last_updated: 2022-12-28
license: "Apache License 2.0"
pipeline_tag: auto-speech-recognition
tasks:
  - auto-speech-recognition
model_type:
  - speech-post-processing
library_name:
  - pytorch
frameworks:
  - pytorch
language:
  - en
domain:
  - audio
downloads: 91
stars: 3
tags:
  - ITN
  - Alibaba
  - "Speech Post Processing"
---

# asr_speech_post_processing_itn-en

> asr_speech_post_processing_itn-en - iic 在 ModelScope 开源的模型。英文文本反正则化，用于对英文语音识别之后的后处理。

iic/asr_speech_post_processing_itn-en 是 ModelScope 魔搭社区上的auto-speech-recognition模型，采用 Apache License 2.0 许可。

- **Repository**: iic/asr_speech_post_processing_itn-en
- **License**: Apache License 2.0
- **Tasks**: auto-speech-recognition
- **Tags**: ITN, Alibaba, Speech Post Processing
- **Downloads**: 91
- **Stars**: 3
- **Last updated**: 2022-12-28

Source: https://www.modelscope.cn/models/iic/asr_speech_post_processing_itn-en

---

## 多语言文本正则化和反正则化

文本正则化（Text Normalization, TN）和反正则化（Inverse Text Normalization, ITN）是什么

文本正则化（Text Normalization, TN）和反正则化（Inverse Text Normalization, ITN）是语音交互系统中必不可少的部分。对于TN，广泛用于语音合成系统的前端的数据处理，对于ITN，则广泛用于语音识别后的文本数据处理，实现从口语域到书面域的文字的转换，使显示的文字更加符合人的阅读习惯。

当前学术界和工业界被广泛使用的TN/ITN系统
1. 基于语法规则WFST的系统 这种系统由大量特定语言的语法组成，该方法的优点是准确性可控，可以快速修复语法中的Badcase,该方法的不足在于没有特定上下文情况下，对于产生歧义的文本不够鲁棒。
2. 基于神经网络模型的系统 这种系统需要大量的训练数据，需要这种语言的语法规则，将书面域转换为相应的口语域的数据，以产生大量的覆盖范围更广的数据。同时其方法的另外一个主要的缺点是无法修复转变的错误，修复Badcase的方法不如基于语法规则的方式来的简单。
3. 混合使用语法和神经网络系统 这种混合系统中当系统没有找到匹配的语法规则时，才利用神经网络模型进行转换。该方法比较好的权衡了规则和模型的优劣，但对系统的计算资源等提出更高的要求。


基于上述三种不同系统的优劣，选择利用基于语法的WFST方案，同时利用最广泛的Google公司推出的Sparrowhawk框架，开源包括中、韩、日等十多种不同语言的ITN规则。同时基于FunASR/fun_text_processing，开源了设计和生成这些ITN规则的工具。该工具提供了安装、测试、导出的python工具。具体的使用方法可以参考FunASR/fun_text_processing中的README。

文本正则化和反正则化示意如下：


<div align=center>
<img src="fig/struct.png" width="821" height="327"/>
</div>


## 快速上手

运行范围
- 现阶段只能在Linux-x86_64运行，不支持Mac和Windows。

使用方式
- 直接推理：可以直接对输入的反正话的文字，输出转换之后的文字。
- 修改：利用FunASR/fun_text_processing/inverse_text_normalization相应语言的不同语法规则进行修改。

使用范围与目标场景
- 相应语言语音识别的后处理。

### 安装
```shell
bash fun_text_processing/install_pynini.sh
```

### 例子

中文ITN例子
```python
python fun_text_processing/inverse_text_normalization/inverse_normalize.py --text="二零二二年十二月二十四日，有二分之一的概率都不会在下午两点半外出。" --language=zh

```

英文ITN例子
```python
python fun_text_processing/inverse_text_normalization/inverse_normalize.py --text="one hundred twenty three" --language=en

```

印尼语ITN例子
```python
python fun_text_processing/inverse_text_normalization/inverse_normalize.py --text="ratus dua puluh tiga" --language=id --cache_dir ./model/ --output_file output.txt
cat output.txt
```

#### api调用范例
```python
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

itn_inference_pipline = pipeline(
    task=Tasks.inverse_text_processing,
    model='damo/asr_speech_post_processing_itn-en')

rec_result = itn_inference_pipline(text_in='on december second, we paid one hundred and twenty three dollars for christmas tree.')
print(rec_result)
```
## 数据评估及结果

### 相关论文以及引用信息

```github
https://github.com/alibaba-damo-academy/FunASR/tree/main/fun_text_processing
```
```
