# ASR SDK

#### 介绍
百度、腾讯、阿里云、华为云 ASR服务的集成SDK

#### 软件架构
```
            |--->baiduASR
ASRFactory==|--->tencentASR
            |--->aliyunASR
            |--->huaweiASR
```

#### 安装教程
1、直接引入项目
2、需引入相关依赖
```
"dependencies": {
  "alibabacloud-nls": "^1.0.2",
  "tencentcloud-sdk-nodejs": "^4.0.463",
  "axios": "^0.27.2",
  "node-uuid": "^1.4.8",
  "ws": "^8.8.1",
  "xmlhttprequest": "^1.8.0"
}
```
#### 使用说明
##### 实时语音转写
调用说明
```
import ASR from "../SDK/ASR/index.js";
//初始化Asr
const asrApi = new ASR(sp);
asrApi.init();
//开始识别
asrApi.start();
//传入音频数据
asrApi.write(msg);
//获取识别结果
asrApi.eventEmitter.addListener("OnSentenceEnd",(res)=>{
        console.log("【ASR】一句话识别结果：", res);
        });
//关闭ASR
 asrApi.stop();

```
识别结果统一格式
```
{
  message: 'success',
  start_time: 1020,
  end_time: 1020,
  result: '北京科技馆',
  word_list: []
}
```
##### 语音听写(async)
调用说明
```
var shortVoiceASR = new ShortVoiceASR(sp || "ali");
//data 传入音频文件buffer 二进制数据
const result= await asrApi.speechRecognition(data, params);
```
识别结果统一格式
```
{
  sp: 'aliyun',
  message: 'SUCCESS',
  result: '北京科技馆。',
  statusCode: 200,
  error: {}
}
```

#### 备注
集成文档：https://bhi1m2vq3p.feishu.cn/docx/doxcnTCOPh2VFyteqbEWGi1NXeb




