zoukankan      html  css  js  c++  java
  • 关于集成科大讯飞语音识别

     一、添加静态库

    ⚠️将开发工具包中lib目录下地iflyMSC.framework添加到工程中去。

    再添加如下图所示的库:

    添加静态库

    二、导入头文件

     1 #import <iflyMSC/IFlyRecognizerViewDelegate.h>
     2 #import <iflyMSC/IFlyRecognizerView.h>
     3   
     4 #import <iflyMSC/IFlySpeechRecognizerDelegate.h>
     5 #import <iflyMSC/IFlySpeechRecognizer.h>
     6   
     7 #import <iflyMSC/IFlySpeechUnderstander.h>
     8   
     9 #import <iflyMSC/IFlySpeechSynthesizerDelegate.h>
    10 #import <iflyMSC/IFlySpeechSynthesizer.h>
    11   
    12 #import <iflyMSC/IFlyContact.h>
    13 #import <iflyMSC/IFlyDataUploader.h>
    14 #import <iflyMSC/IFlyUserWords.h>
    15 #import <iflyMSC/IFlySpeechConstant.h>
    16 #import <iflyMSC/IFlySpeechUtility.h>

    三、初始化SDK

    1 //在AppDelegate.m文件中的
    2 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    3 
    4 NSString *appid = @"53be3a59";
    5     NSString *initString = [NSString stringWithFormat:@"appid=%@",appid];
    6 [IFlySpeechUtility createUtility:initString];
    7 
    8 
    9 }

    四、语音听写(带界面)

     1  _iflyRecognizerView = [[IFlyRecognizerView alloc] initWithCenter:self.view.center];
     2    _iflyRecognizerView.delegate = self;
     3   [_iflyRecognizerView setParameter: @"iat" forKey: [IFlySpeechConstant IFLY_DOMAIN]];
     4     //asr_audio_path保存录音文件名,如不再需要,设置value为nil表示取消,默认目录是documents
     5     [_iflyRecognizerView setParameter:@"asrview.pcm " forKey:[IFlySpeechConstant ASR_AUDIO_PATH]];
     6      //设置数据返回的类型
     7     [_iflyRecognizerView setParameter:@"plain" forKey:[IFlySpeechConstant RESULT_TYPE]];
     8    //设置识别语言为英语
     9  [_iflyRecognizerView setParameter:@"en_us" forKey:[IFlySpeechConstant LANGUAGE]]; 
    10   //设置识别语言为中文 普通话
    11  [_iflyRecognizerView setParameter:@"zh_ch" forKey:[IFlySpeechConstant LANGUAGE]];
    12          [_iflyRecognizerView setParameter:@"mandarin"forKey:[IFlySpeechConstant ACCENT]];
    13 
    14 - (void)onResult: (NSArray *)resultArray isLast:(BOOL) isLast
    15 {
    16     NSMutableString *result = [[NSMutableString alloc] init];
    17     NSDictionary *dic = resultArray[0];
    18 
    19     for (NSString *key in dic) {
    20        [result appendFormat:@"%@",key];
    21     }
    22     self.label.text = [NSString stringWithFormat:@"%@%@",self.label.text,result];
    23     NSLog(@"self.textField.text = %@",self.textField.text);
    24 
    25 }
    26 
    27 /*识别会话错误返回代理
    28  @ param  error 错误码
    29  */
    30 - (void)onError: (IFlySpeechError *) error
    31 {
    32 }
    33 
    34 
    35 
    36  
    37  
  • 相关阅读:
    板邓:php获取数组元素个数
    板邓:PHP解决Using $this when not in object context in【转】
    板邓:MYSQL distinct关键字查询重复值只显示一条记录
    板邓: php 过滤文章的html标签方法
    板邓:PHP使用mb_strimwidth截取中文字符串方法大全
    板邓:php str_replace单双引号的替换问题
    板邓:PHP下利用PHPMailer配合QQ邮箱下的域名邮箱发送邮件(转)
    板邓:wordpress自定义伪静态 WP_Rewrite
    板邓:wordpress获取当前页面的id、别名
    获取文件夹名
  • 原文地址:https://www.cnblogs.com/cecely-clj/p/5665677.html
Copyright © 2011-2022 走看看