README_cn.md 2.6 KB
Newer Older
Y
Yang Zhou 已提交
1
(简体中文|[English](./README.md))
Y
Yang Zhou 已提交
2 3 4

# 定制化语音识别演示
## 介绍
Y
Yang Zhou 已提交
5
在一些场景中,识别系统需要高精度的识别一些稀有词,例如导航软件中地名识别。而通过定制化识别可以满足这一需求。  
Y
Yang Zhou 已提交
6

Y
Yang Zhou 已提交
7
这个 demo 是打车报销单的场景识别,需要识别一些稀有的地名,可以通过如下操作实现。
Y
Yang Zhou 已提交
8

Y
format  
Yang Zhou 已提交
9
* G with slot: 打车到 "address_slot"。  
Y
Yang Zhou 已提交
10 11
![](https://ai-studio-static-online.cdn.bcebos.com/28d9ef132a7f47a895a65ae9e5c4f55b8f472c9f3dd24be8a2e66e0b88b173a4)

Y
format  
Yang Zhou 已提交
12
* 这是address slot wfst, 可以添加一些需要识别的地名.  
Y
Yang Zhou 已提交
13 14
![](https://ai-studio-static-online.cdn.bcebos.com/47c89100ef8c465bac733605ffc53d76abefba33d62f4d818d351f8cea3c8fe2)

Y
format  
Yang Zhou 已提交
15
* 通过replace 操作, G = fstreplace(G_with_slot, address_slot), 最终可以得到定制化的解码图。  
Y
Yang Zhou 已提交
16
![](https://ai-studio-static-online.cdn.bcebos.com/60a3095293044f10b73039ab10c7950d139a6717580a44a3ba878c6e74de402b)  
Y
Yang Zhou 已提交
17 18 19

## 使用方法
### 1. 配置环境
Y
Yang Zhou 已提交
20 21
安装paddle:2.2.2 docker镜像。
```
Y
format  
Yang Zhou 已提交
22
sudo docker pull registry.baidubce.com/paddlepaddle/paddle:2.2.2
Y
Yang Zhou 已提交
23

Y
format  
Yang Zhou 已提交
24
sudo docker run --privileged  --net=host --ipc=host -it --rm -v $PWD:/paddle --name=paddle_demo_docker registry.baidubce.com/paddlepaddle/paddle:2.2.2 /bin/bash 
Y
Yang Zhou 已提交
25
```
Y
Yang Zhou 已提交
26 27

### 2. 演示
Y
Yang Zhou 已提交
28 29
* 运行如下命令,完成相关资源和库的下载和服务启动。
```
Y
format  
Yang Zhou 已提交
30
cd /paddle
Y
Yang Zhou 已提交
31 32 33
bash websocket_server.sh
```
上面脚本完成了如下两个功能:
Y
format  
Yang Zhou 已提交
34
1. 完成resource.tar.gz下载,解压后,会在resource中发现如下目录:  
Y
format  
Yang Zhou 已提交
35 36 37 38 39
model: 声学模型  
graph: 解码构图  
lib: 相关库  
bin: 运行程序  
data: 语音数据  
Y
Yang Zhou 已提交
40 41

2. 通过websocket_server_main来启动服务。
Y
format  
Yang Zhou 已提交
42 43
这里简单的介绍几个参数:  
port是服务端口,  
Y
format  
Yang Zhou 已提交
44
graph_path用来指定解码图文件,  
Y
format  
Yang Zhou 已提交
45 46 47
其他参数说明可参见代码:  
PaddleSpeech/speechx/speechx/decoder/param.h  
PaddleSpeech/speechx/examples/ds2_ol/websocket/websocket_server_main.cc  
Y
Yang Zhou 已提交
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

* 在另一个终端中, 通过client发送数据,得到结果。运行如下命令:
```
bash websocket_client.sh
```
通过websocket_client_main来启动client服务,其中$wav_scp是发送的语音句子集合,port为服务端口。

* 结果:
client的log中可以看到如下类似的结果
```
0513 10:58:13.827821 41768 recognizer_test_main.cc:56] wav len (sample): 70208
I0513 10:58:13.884493 41768 feature_cache.h:52] set finished
I0513 10:58:24.247171 41768 paddle_nnet.h:76] Tensor neml: 10240
I0513 10:58:24.247249 41768 paddle_nnet.h:76] Tensor neml: 10240
LOG ([5.5.544~2-f21d7]:main():decoder/recognizer_test_main.cc:90)  the result of case_10 is 五月十二日二十二点三十六分加班打车回家四十一元
```