<commit_before># 边牧 iOS SDK 接入指南(v1.0.0)

This project is a public SDK for who want analyse user behaviors.
Deploy target : iOS 8.0.

## 1 如何接入

### 1.1 在机器上添加Pod仓库
在命令行输入并执行：
```bash
pod repo add frameworkplatform https://code.aliyun.com/xhzy-ios/frameworkplatform.git
```

### 1.2 在项目的 Podfile 中，添加如下依赖：

```ruby
source 'https://github.com/CocoaPods/Specs.git'
source 'https://code.aliyun.com/xhzy-ios/frameworkplatform.git'

target 'YourProject' do
  pod 'SHWNLSClientSDK', '~> 1.0.0'
end
```

> 注: 以上 pod 版本号，请自行更新到最新版本

### 1.3 更新安装 
`pod repo update`
`pod install`

## 2 Regist your app.
Get your AppKey in our web site.
appKey值可从新华智云接口人获取（网站建设中，目前请联系接口人）



## 3 How to use
### 3.1 设置AppKey和AppSecret
```Objective-C
[SHWNLSGlobleConfig setAppKey:@“Your_APPKEY”];
[SHWNLSGlobleConfig setAppSecret:@“Your_APPSECRET”];
```

### 3.2 ASR, 语音转文字
语音只支持麦克风录制，长度限制```15s```
delegate方法，最终都在主线程中回调
>多次调用beginRecord，如果已经处于Recording状态，后面的调用无效

```Objective-C
@protocol SHWASRClientDelegate <NSObject>
@optional

/*!
    Called when the asr procedure starts recording audio.
 */
- (void)asrClientDidBeginRecording:(SHWASRClient *)asrClient;

/*!
    Called when the asr procedure stops recording audio.
 */
- (void)asrClientDidFinishRecording:(SHWASRClient *)asrClient;

/*!
 Called when the asr procedure stops recording audio.
 */
- (void)asrClientDidFinishRecognizing:(SHWASRClient *)asrClient;

/*!
    Called when the asr procedure returns a custom application response.
    {data:{recognitionText:@""}, code:200}。
 */
- (void)asrClient:(SHWASRClient *)asrClient didReceiveServiceResponse:(NSDictionary *)result;

/*!
    Called when the asr procedure has an error.
 */
- (void)asrClient:(SHWASRClient *)asrClient didFailWithError:(NSError *)error;
@end

@interface SHWASRClient : NSObject
+ (instancetype)initWithDelegate:(id<SHWASRClientDelegate>)delegate;
- (void)beginRecord;
- (void)finishRecordAndRecognize;
- (BOOL)isRecording;
- (void)cancel;
@end
```


### 3.3 tts, 文字转语音
长度没有限制，ttsClient:didReceiveAudio:sequence:会多次返回音频文件。
返回的NSData音频格式为mp3
delegate方法，最终都在主线程中回调
>多次调用tts:language:，后一次会cancel前一次的请求。

```Objective-C
@protocol SHWTTSClientDelegate <NSObject>
@optional

/*!
    Called when the tts procedure returns audio data.
 */<commit_msg>README format<commit_after># 边牧 iOS SDK 接入指南(v1.0.0)

This project is a public SDK for who want analyse user behaviors.
Deploy target : iOS 8.0.

## 1 如何接入

### 1.1 在机器上添加Pod仓库
在命令行输入并执行：
```bash
pod repo add frameworkplatform https://code.aliyun.com/xhzy-ios/frameworkplatform.git
```

### 1.2 在项目的 Podfile 中，添加如下依赖：

```ruby
source 'https://github.com/CocoaPods/Specs.git'
source 'https://code.aliyun.com/xhzy-ios/frameworkplatform.git'

target 'YourProject' do
  pod 'SHWNLSClientSDK', '~> 1.0.0'
end
```

> 注: 以上 pod 版本号，请自行更新到最新版本

### 1.3 更新安装 
`pod repo update`
`pod install`

## 2 Regist your app.
Get your AppKey in our web site.
appKey值可从新华智云接口人获取（网站建设中，目前请联系接口人）



## 3 How to use
### 3.1 设置AppKey和AppSecret
```Objective-C
[SHWNLSGlobleConfig setAppKey:@“Your_APPKEY”];
[SHWNLSGlobleConfig setAppSecret:@“Your_APPSECRET”];
```

### 3.2 ASR, 语音转文字
语音只支持麦克风录制，长度限制```15s```。
delegate方法，最终都在主线程中回调。
>多次调用beginRecord，如果已经处于Recording状态，后面的调用无效。

```Objective-C
@protocol SHWASRClientDelegate <NSObject>
@optional

/*!
    Called when the asr procedure starts recording audio.
 */
- (void)asrClientDidBeginRecording:(SHWASRClient *)asrClient;

/*!
    Called when the asr procedure stops recording audio.
 */
- (void)asrClientDidFinishRecording:(SHWASRClient *)asrClient;

/*!
 Called when the asr procedure stops recording audio.
 */
- (void)asrClientDidFinishRecognizing:(SHWASRClient *)asrClient;

/*!
    Called when the asr procedure returns a custom application response.
    {data:{recognitionText:@""}, code:200}。
 */
- (void)asrClient:(SHWASRClient *)asrClient didReceiveServiceResponse:(NSDictionary *)result;

/*!
    Called when the asr procedure has an error.
 */
- (void)asrClient:(SHWASRClient *)asrClient didFailWithError:(NSError *)error;
@end

@interface SHWASRClient : NSObject
+ (instancetype)initWithDelegate:(id<SHWASRClientDelegate>)delegate;
- (void)beginRecord;
- (void)finishRecordAndRecognize;
- (BOOL)isRecording;
- (void)cancel;
@end
```


### 3.3 tts, 文字转语音
长度没有限制，ttsClient:didReceiveAudio:sequence:会多次返回音频文件。
返回的NSData音频格式为mp3。
delegate方法，最终都在主线程中回调。
>多次调用tts:language:，后一次会cancel前一次的请求。

```Objective-C
@protocol SHWTTSClientDelegate <NSObject>
@optional

/*!
    Called when the tts procedure returns audio data.
 */
{'fraction_non_alphanumeric': 0.13334812513867317, 'fraction_numerical': 0.012868870645662302, 'mean_word_length': 5.533333333333333, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6996075', 'n_tokens_mistral': 1990, 'n_tokens_neox': 1985, 'n_words': 363}