".github/git@developer.sourcefind.cn:change/sglang.git" did not exist on "9767a1e41baf3baeb854228a6b70d1007576b5bf"
Unverified Commit 46fc6fee authored by SWHL's avatar SWHL Committed by GitHub
Browse files

Update files

parent 2c39c32e
## Rapid paraformer ## Rapid ASR
<p align="left"> <p align="left">
<a href=""><img src="https://img.shields.io/badge/Python->=3.7,<=3.10-aff.svg"></a>
<a href=""><img src="https://img.shields.io/badge/OS-Linux%2C%20Win%2C%20Mac-pink.svg"></a> <a href=""><img src="https://img.shields.io/badge/OS-Linux%2C%20Win%2C%20Mac-pink.svg"></a>
<a href=""><img src="https://img.shields.io/badge/Python->=3.7,<=3.10-aff.svg"></a>
<a href=""><img src="https://img.shields.io/badge/C++-aff.svg"></a>
</p> </p>
- 模型出自阿里达摩院[Paraformer语音识别-中文-通用-16k-离线-large-pytorch](https://www.modelscope.cn/models/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/summary) - 模型出自阿里达摩院[Paraformer语音识别-中文-通用-16k-离线-large-pytorch](https://www.modelscope.cn/models/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/summary)
- 🎉该项目核心代码已经并入[FunASR](https://github.com/alibaba-damo-academy/FunASR) - 🎉该项目核心代码已经并入[FunASR](https://github.com/alibaba-damo-academy/FunASR)
- 本仓库仅对模型做了转换,只采用ONNXRuntime推理引擎 - 本仓库仅对模型做了转换,只采用ONNXRuntime推理引擎
#### 文档导航
- [Python版](./python/README.md)
- [C++/C版](./cpp_onnx/readme.md)
#### TODO #### TODO
- [ ] 整合vad + asr + pun三个模型,打造可部署使用的方案 - [ ] 整合vad + asr + pun三个模型,打造可部署使用的方案
#### 支持语言
- Python
- C++/C
#### 使用步骤
1. 安装环境
```bash
pip install -r requirements.txt
```
2. 下载模型
- 由于模型太大(823.8M),上传到仓库不容易下载,
- (推荐)自助转换:基于modescope下的notebook环境,可一键转换,详情戳:[快速体验](https://www.modelscope.cn/models/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/summary)
- 打开notebook → Cell中输入`!python -m funasr.export.export_model 'damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch' "./export" true`, 执行即可。
- 提供百度云下载连接:[asr_paraformerv2.onnx](https://pan.baidu.com/s/1-nEf2eUpkzlcRqiYEwub2A?pwd=dcr3)(模型MD5: `9ca331381a470bc4458cc6c0b0b165de`
- 模型下载之后,放在`resources/models`目录下即可,最终目录结构如下:
```text
.
├── demo.py
├── rapid_paraformer
│   ├── __init__.py
│   ├── kaldifeat
│   ├── __pycache__
│   ├── rapid_paraformer.py
│   └── utils.py
├── README.md
├── requirements.txt
├── resources
│   ├── config.yaml
│   └── models
│   ├── am.mvn
│   ├── asr_paraformerv2.onnx # 放在这里
│   └── token_list.pkl
├── test_onnx.py
├── tests
│   ├── __pycache__
│   └── test_infer.py
└── test_wavs
├── 0478_00017.wav
└── asr_example_zh.wav
```
3. 运行demo
```python
from rapid_paraformer import RapidParaformer
config_path = 'resources/config.yaml'
paraformer = RapidParaformer(config_path)
# 输入:支持Union[str, np.ndarray, List[str]] 三种方式传入
# 输出: List[asr_res]
wav_path = [
'test_wavs/0478_00017.wav',
]
result = paraformer(wav_path)
print(result)
```
4. 查看结果
```text
['呃说不配合就不配合的好以上的话呢我们摘取八九十三条因为这三条的话呢比较典型啊一些数字比较明确尤其是时间那么我们要投资者就是了解这一点啊不要轻信这个市场可以快速回来啊这些配市公司啊后期又利好了可
以快速快速攻能包括像前一段时间啊有些媒体在二三月份的时候']
```
#### 更新日志 #### 更新日志
- 2023-02-25 - 2023-02-25
......
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
## 快速使用 ## 快速使用
### Windows ### Windows
安装Vs2022 打开cpp_onnx目录下的cmake工程,直接 build即可。 本仓库已经准备好所有相关依赖库。 安装Vs2022 打开cpp_onnx目录下的cmake工程,直接 build即可。 本仓库已经准备好所有相关依赖库。
Windows下已经预置fftw3、onnxruntime及openblas库 Windows下已经预置fftw3、onnxruntime及openblas库
...@@ -45,9 +45,6 @@ ...@@ -45,9 +45,6 @@
See the bottom of this page: Building Guidance See the bottom of this page: Building Guidance
### 运行程序 ### 运行程序
tester /path/to/models/dir /path/to/wave/file tester /path/to/models/dir /path/to/wave/file
...@@ -56,11 +53,8 @@ tester /path/to/models/dir /path/to/wave/file ...@@ -56,11 +53,8 @@ tester /path/to/models/dir /path/to/wave/file
/data/models 需要包括如下两个文件: model.onnx 和vocab.txt /data/models 需要包括如下两个文件: model.onnx 和vocab.txt
```
```
## 支持平台 ## 支持平台
- Windows - Windows
- Linux/Unix - Linux/Unix
...@@ -68,7 +62,6 @@ tester /path/to/models/dir /path/to/wave/file ...@@ -68,7 +62,6 @@ tester /path/to/models/dir /path/to/wave/file
- fftw3 - fftw3
- onnxruntime - onnxruntime
## 导出onnx格式模型文件 ## 导出onnx格式模型文件
安装 modelscope与FunASR,依赖:torch,torchaudio,安装过程[详细参考文档](https://github.com/alibaba-damo-academy/FunASR/wiki) 安装 modelscope与FunASR,依赖:torch,torchaudio,安装过程[详细参考文档](https://github.com/alibaba-damo-academy/FunASR/wiki)
```shell ```shell
...@@ -92,18 +85,17 @@ cd build ...@@ -92,18 +85,17 @@ cd build
# download an appropriate onnxruntime from https://github.com/microsoft/onnxruntime/releases/tag/v1.14.0 # download an appropriate onnxruntime from https://github.com/microsoft/onnxruntime/releases/tag/v1.14.0
# here we get a copy of onnxruntime for linux 64 # here we get a copy of onnxruntime for linux 64
wget https://github.com/microsoft/onnxruntime/releases/download/v1.14.0/onnxruntime-linux-x64-1.14.0.tgz wget https://github.com/microsoft/onnxruntime/releases/download/v1.14.0/onnxruntime-linux-x64-1.14.0.tgz
#ls # ls
# onnxruntime-linux-x64-1.14.0 onnxruntime-linux-x64-1.14.0.tgz # onnxruntime-linux-x64-1.14.0 onnxruntime-linux-x64-1.14.0.tgz
#install fftw3-dev #install fftw3-dev
apt install libfftw3-dev apt install libfftw3-dev
# build # build
cmake -DCMAKE_BUILD_TYPE=release .. -DONNXRUNTIME_DIR=/mnt/c/Users/ma139/RapidASR/cpp_onnx/build/onnxruntime-linux-x64-1.14.0 cmake -DCMAKE_BUILD_TYPE=release .. -DONNXRUNTIME_DIR=/mnt/c/Users/ma139/RapidASR/cpp_onnx/build/onnxruntime-linux-x64-1.14.0
make make
# then in the subfolder tester of current direcotry, you will see a program, tester # then in the subfolder tester of current direcotry, you will see a program, tester
```` ````
...@@ -113,4 +105,3 @@ onnxruntime_xxx ...@@ -113,4 +105,3 @@ onnxruntime_xxx
├───include ├───include
└───lib └───lib
``` ```
## Rapid ASR
<p align="left">
<a href=""><img src="https://img.shields.io/badge/Python->=3.7,<=3.10-aff.svg"></a>
<a href=""><img src="https://img.shields.io/badge/OS-Linux%2C%20Win%2C%20Mac-pink.svg"></a>
</p>
- 模型出自阿里达摩院[Paraformer语音识别-中文-通用-16k-离线-large-pytorch](https://www.modelscope.cn/models/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/summary)
- 🎉该项目核心代码已经并入[FunASR](https://github.com/alibaba-damo-academy/FunASR)
- 本仓库仅对模型做了转换,只采用ONNXRuntime推理引擎
#### TODO
- [ ] 整合vad + asr + pun三个模型,打造可部署使用的方案
#### 使用步骤
1. 安装环境
```bash
pip install -r requirements.txt
```
2. 下载模型
- 由于模型太大(823.8M),上传到仓库不容易下载,
- (推荐)自助转换:基于modescope下的notebook环境,可一键转换,详情戳:[快速体验](https://www.modelscope.cn/models/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/summary)
- 打开notebook → Cell中输入`!python -m funasr.export.export_model 'damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch' "./export" true`, 执行即可。
- 提供百度云下载连接:[asr_paraformerv2.onnx](https://pan.baidu.com/s/1-nEf2eUpkzlcRqiYEwub2A?pwd=dcr3)(模型MD5: `9ca331381a470bc4458cc6c0b0b165de`
- 模型下载之后,放在`resources/models`目录下即可,最终目录结构如下:
```text
.
├── demo.py
├── rapid_paraformer
│   ├── __init__.py
│   ├── kaldifeat
│   ├── __pycache__
│   ├── rapid_paraformer.py
│   └── utils.py
├── README.md
├── requirements.txt
├── resources
│   ├── config.yaml
│   └── models
│   ├── am.mvn
│   ├── asr_paraformerv2.onnx # 放在这里
│   └── token_list.pkl
├── test_onnx.py
├── tests
│   ├── __pycache__
│   └── test_infer.py
└── test_wavs
├── 0478_00017.wav
└── asr_example_zh.wav
```
3. 运行demo
```python
from rapid_paraformer import RapidParaformer
config_path = 'resources/config.yaml'
paraformer = RapidParaformer(config_path)
# 输入:支持Union[str, np.ndarray, List[str]] 三种方式传入
# 输出: List[asr_res]
wav_path = [
'test_wavs/0478_00017.wav',
]
result = paraformer(wav_path)
print(result)
```
4. 查看结果
```text
['呃说不配合就不配合的好以上的话呢我们摘取八九十三条因为这三条的话呢比较典型啊一些数字比较明确尤其是时间那么我们要投资者就是了解这一点啊不要轻信这个市场可以快速回来啊这些配市公司啊后期又利好了可
以快速快速攻能包括像前一段时间啊有些媒体在二三月份的时候']
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment