百度语音使用步骤(语音识别接入流程)

请参考《百度语音开放平台使用指南》创建应用,开通服务并完成个性化设置。


引入编译需要的Framework

BDVRClient包含的功能以及需要的Framework有:

功能                                                                  framework名称

录音和播放                                                  AudioToolbox.framework

                                                                    AVFoundation.framework

网络状态检测                                              SystemConfiguration.framework

判断当前网络连接类型(2G/3G/4G        CoreTelephony.framework

生成设备UDID                                             Security.framework

支持gzip压缩                                               libz.1.dylib

网络模块                                                     CFNetwork.framework

获取设备地理位置以提高识别准确度          CoreLocation.framework

支持识别控件                                              OpenGLES.framework

                                                                    QuartzCore.framework

                                                                    GLKit.framework

                                                                    CoreGraphics.framework

                                                                    CoreText.framework



ViewController.m代码



#import "ViewController.h"

#import "BDRecognizerViewController.h"

#import "BDRecognizerViewDelegate.h"

#import "BDVoiceRecognitionClient.h"

@interface ViewController ()<BDRecognizerViewDelegate>

{

    //创建语音界面对象

    BDRecognizerViewController * BDVC;

    //创建接受语音的界面

    BDRecognizerViewParamsObject * bdvc;

    NSMutableData * allData;

}

@property(nonatomic,strong)UITextView * vw;


@end


@implementation ViewController


- (void)viewDidLoad

{

    [super viewDidLoad];

    UIButton * btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];

    btn.frame=CGRectMake(60, 300, 60, 50);

    [btn setTitle:@"开始识别" forState:UIControlStateNormal];

    [btn addTarget:self action:@selector(click1) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:btn];

    UIButton * btn2=[UIButton buttonWithType:UIButtonTypeRoundedRect];

    btn2.frame=CGRectMake(120, 300, 60, 50);

    [btn2 addTarget:self action:@selector(click2) forControlEvents:UIControlEventTouchUpInside];

    [btn2 setTitle:@"清除" forState:UIControlStateNormal];

    [self.view addSubview:btn2];

    self.vw=[[UITextView alloc]initWithFrame:CGRectMake(20, 20,self.view.frame.size.width-40, 200)];

    self.vw.backgroundColor=[UIColor grayColor];

    [self.view addSubview:self.vw];

    //设置主题

    BDTheme * theme=[BDTheme lightGreenTheme];

    BDVC=[[BDRecognizerViewController alloc]initWithOrigin:CGPointMake(9,128) withTheme:theme];

    BDVC.delegate=self;

    BDVC.enableFullScreenMode=YES;

    

    bdvc=[[BDRecognizerViewParamsObject alloc]init];

    

    bdvc.apiKey=@"***********************************";

    bdvc.secretKey=@"***********************************";

}

-(void)click1{

    [BDVC startWithParams:bdvc];

    allData =[[NSMutableData alloc]init];

}


-(void)click2{

    self.vw.text=nil;

}

- (void)onEndWithViews:(BDRecognizerViewController *)aBDRecognizerViewController withResults:(NSArray *)aResults{

    //可以不写内容但是必须有

}

- (void)onPartialResults:(NSString *)results{

    NSMutableString * ss=[[NSMutableString alloc]init];

    [ss appendString:results];

    self.vw.text=ss;

}

- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end


转载于:https://my.oschina.net/xiaoyaokm/blog/629768

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值