Skip to content

Commit 609de03

Browse files
committed
update README.md
1 parent 5d2acb5 commit 609de03

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

README.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,34 @@ react-native-speech-iflytek 是一个 React Native 下的科大讯飞语音库
44
## Support
55
- React Native >= 0.47.0 from 0.2.0
66
- React Native >= 0.42.0 from 0.1.2
7-
- Android,目前仅支持 Android
7+
- Android
8+
- iOS from 1.0.0
89

910
## Install
1011
```
1112
npm i react-native-speech-iflytek --save
1213
react-native link
1314
```
14-
安装后还须进行下面两步:
15-
1.[讯飞开放平台](http://www.xfyun.cn/sdk/dispatcher) 下载组合服务SDK(选择`语音听写``在线语音合成`
16-
2. 使用下载 SDK 的 `Android_voice_xxxx_xxxxxxxx/libs` 文件夹替换 `YourProject/node_modules/react-native-speech-iflytek/android/libs` 文件夹,这是因为讯飞语音的原生库与注册应用进行了绑定。
15+
安装、链接后还须进行下面两步(以 `Example` 工程为例):
16+
1.[讯飞开放平台](http://www.xfyun.cn/sdk/dispatcher) 下载组合服务 SDK (选择`语音听写``在线语音合成`),分别下载 Android 与 iOS 平台 SDK。
17+
2. 替换 SDK 文件:
18+
1. 使用下载 Android SDK 的 `Android_voice_xxxx_xxxxxxxx/libs` 文件夹替换 `Example/node_modules/react-native-speech-iflytek/android/libs` 文件夹;
19+
2. 使用下载 iOS SDK 的 `iOS_voice_xxxx_xxxxxxxx/libs` 文件夹替换 `Example/node_modules/react-native-speech-iflytek/ios/libs` 文件夹。
20+
3. iOS 平台还需手动添加部分依赖库:
21+
1. 在 XCode 中打开 `Example/ios/YourProject.xcodeproj`
22+
2. 将讯飞框架文件 `Example/node_modules/react-native-speech-iflytek/ios/libs/iflyMSC.framework` 拖入 Project navigator 的 `Frameworks` 下,注意选择 `Copy items if needed`
23+
3. 添加讯飞依赖的系统库(见:[科大讯飞MSC开发指南-iOS-集成流程](http://doc.xfyun.cn/msc_ios/302721)):
24+
- CoreLocation.framework
25+
- CoreTelephony.framework
26+
- AVFoundation.framework
27+
- AddressBook.framework
28+
- Contacts.framework
29+
- AudioToolbox.framework
30+
- SystemConfiguration.framework
31+
- QuartzCore.framework
32+
- UIKit.framework
33+
- Foundation.framework
34+
- CoreGraphics.framework
1735

1836
## Usage
1937
(详见 Example)引入包:
@@ -23,7 +41,8 @@ import { Recognizer, Synthesizer, SpeechConstant } from "react-native-speech-ifl
2341
语音识别:
2442
```
2543
Recognizer.init("57c7c5b0");
26-
DeviceEventEmitter.addListener("onRecognizerResult", this.onRecognizerResult);
44+
this.recognizerEventEmitter = new NativeEventEmitter(Recognizer);
45+
this.recognizerEventEmitter.addListener('onRecognizerResult', this.onRecognizerResult);
2746
Recognizer.start();
2847
```
2948
处理识别结果:
@@ -32,7 +51,6 @@ onRecognizerResult(e) {
3251
if (!e.isLast) {
3352
return;
3453
}
35-
ToastAndroid.show(e.result, ToastAndroid.SHORT);
3654
this.setState({ text: e.result });
3755
}
3856
```
@@ -67,9 +85,11 @@ onRecognizerResult(e) {
6785
- `onRecognizerError(JSON error)`
6886
语音识别出现错误,错误信息与讯飞文档保持一致,其值:
6987

70-
- `errorCode`: 获取错误码
71-
- `errorDescription`: 获取错误描述,不包含错误码的描述信息
72-
- `plainDescription`: 获取错误描述,包含错误码的描述信息
88+
- `errorCode`: 获取错误码,关于错误码请见官方文档 [MSC错误码](http://www.xfyun.cn/index.php/default/doccenter/doccenterInner?itemTitle=ZmFx&anchor=Y29udGl0bGU2Ng==) :
89+
- `errorType`: (仅 iOS)获取错误码类型
90+
- `errorDesc`: (仅 iOS)获取错误描述
91+
- `errorDescription`: (仅 Android)获取错误描述,不包含错误码的描述信息
92+
- `plainDescription`: (仅 Android)获取错误描述,包含错误码的描述信息
7393

7494
### Synthesizer
7595
#### Methods
@@ -90,7 +110,7 @@ onRecognizerResult(e) {
90110
#### Events
91111
- `onSynthesizerBufferCompletedEvent()`
92112
语音合成缓冲完成时触发该事件
93-
- `onSynthesizerSpeakCompletedEvent()`
113+
- `onSynthesizerSpeakCompletedEvent()`
94114
语音合成播放完成时触发该事件
95115

96116
### SpeechConstant

0 commit comments

Comments
 (0)