iOS第三方语音-讯飞语音
2015-08-19 12:08
459 查看
官方网站:http://www.xfyun.cn/
注册还要绑定微信,坑啊,识别率感觉没得微信语音好,但是微信语音审核一直不过,研究下这个
1.下载sdk,主要就下面几个文件,我主要用的是语音识别
2.导入相关的库
3.在官网上注册一个应用,得到key,这里用的我注册的key
AppDelegate中导入头文件
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中加入
4.主要分为有UI,和无UI两种IFlySpeechRecognizer(无UI),IFlyRecognizerView(有UI)
无UI代码
有UI代码
其中用了一个解析返回的数据的类,可以看讯飞的demo,下面是我写的demo
百度云demo下载链接:http://pan.baidu.com/s/1nt9thKd
补:压缩包的体积好大,郁闷
注册还要绑定微信,坑啊,识别率感觉没得微信语音好,但是微信语音审核一直不过,研究下这个
1.下载sdk,主要就下面几个文件,我主要用的是语音识别
2.导入相关的库
3.在官网上注册一个应用,得到key,这里用的我注册的key
AppDelegate中导入头文件
#import <iflyMSC/iflyMSC.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中加入
NSString *initString = [[NSString alloc] initWithFormat:@"appid=%@",@"55d3e4d6"]; [IFlySpeechUtility createUtility:initString];
4.主要分为有UI,和无UI两种IFlySpeechRecognizer(无UI),IFlyRecognizerView(有UI)
无UI代码
_iFlySpeechRecognizer = [IFlySpeechRecognizer sharedInstance]; //设置听写模式 [_iFlySpeechRecognizer setParameter:@"iat" forKey:[IFlySpeechConstant IFLY_DOMAIN]]; [_iFlySpeechRecognizer setParameter: @"iat" forKey: [IFlySpeechConstant IFLY_DOMAIN]]; [_iFlySpeechRecognizer setParameter:@"asrview.pcm" forKey:[IFlySpeechConstant ASR_AUDIO_PATH]]; _iFlySpeechRecognizer.delegate = self;
#pragma mark - 事件监听 //录音 - (IBAction)startButtonPressed:(UIButton *)sender { [_iFlySpeechRecognizer startListening]; // [_iflyRecognizerView start]; } //停止 - (IBAction)stopButtonPressed:(UIButton *)sender { [_iFlySpeechRecognizer stopListening]; // [_iflyRecognizerView start]; }
#pragma mark - IFlySpeechRecognizerDelegate - (void)onResults:(NSArray *)results isLast:(BOOL)isLast { NSMutableString *resultString = [[NSMutableString alloc] init]; NSDictionary *dic = results[0]; for (NSString *key in dic) { [resultString appendFormat:@"%@",key]; } NSString *strResult = nil; strResult =[NSString stringWithFormat:@"%@",resultString]; NSString * resultFromJson = [ISRDataHelper stringFromJson:resultString]; if (!isLast){ _label.text = resultFromJson; } NSLog(@"%@",resultString); NSLog(@"resultFromJson=%@",resultFromJson); } - (void)onEndOfSpeech { NSLog(@"停止录音"); } - (void)onError:(IFlySpeechError *)errorCode { NSLog(@"%d",errorCode.errorCode); NSLog(@"%@",[errorCode errorDesc]); }
有UI代码
if (_iflyRecognizerView == nil) { //UI显示居中 _iflyRecognizerView= [[IFlyRecognizerView alloc] initWithCenter:self.view.center]; [_iflyRecognizerView setParameter:@"" forKey:[IFlySpeechConstant PARAMS]]; //设置听写模式 [_iflyRecognizerView setParameter:@"iat" forKey:[IFlySpeechConstant IFLY_DOMAIN]]; } _iflyRecognizerView.delegate = self;
#pragma mark - 事件监听 //录音 - (IBAction)startButtonPressed:(UIButton *)sender { // [_iFlySpeechRecognizer startListening]; [_iflyRecognizerView start]; }
#pragma mark - <IFlyRecognizerViewDelegate>有界面的 - (void)onResult:(NSArray *)resultArray isLast:(BOOL) isLast { NSMutableString *resultString = [[NSMutableString alloc] init]; NSDictionary *dic = resultArray[0]; for (NSString *key in dic) { [resultString appendFormat:@"%@",key]; } NSString *strResult = nil; strResult =[NSString stringWithFormat:@"%@",resultString]; NSString * resultFromJson = [ISRDataHelper stringFromJson:resultString]; if (!isLast){ _label.text = resultFromJson; } NSLog(@"%@",resultString); NSLog(@"resultFromJson=%@",resultFromJson); }
其中用了一个解析返回的数据的类,可以看讯飞的demo,下面是我写的demo
百度云demo下载链接:http://pan.baidu.com/s/1nt9thKd
补:压缩包的体积好大,郁闷
相关文章推荐
- IOS中CocoaPods安装与使用
- 今天开始慢下脚步,开始ios技术知识的查漏补缺。
- iOS文件操作NSFileManager和NSFileHandle
- iOS 开发中几种多线程方案
- iOS 传值总结
- 【iOS学习】八、JSON数据学习
- iOS View添加圆角
- iOS开发~CocoaPods使用详细说明
- 关于ios注册推送
- iOS SDK详解之IBInspectable和IB_DESIGNABLE-Storyboad动态刷新(自定义控件)
- IOS框架和服务
- iOS中TableView小技巧
- iOS 根据颜色创建个图片
- iOS下拨打电话
- [iOS]CoreText 学习笔记(1)
- iOS侧滑返回事件问题和解决方案
- 小胖说事36----iOS通过js 获取webview中的html内容
- iOS 9学习系列:Search API
- iOS设计模式——委托(delegate)
- IOS block