帖子

iOS 语音转写结果不对,我说的“1234567”,结果是我。

[复制链接]

该用户从未签到

18783 1013751425@qq.c 发表于 2018-5-16 09:47:33 1#
- (void)viewDidLoad {
    [super viewDidLoad];
    UILabel * la1 = [[UILabel alloc]init];
    la1.numberOfLines = 0;
    la1.backgroundColor = [UIColor redColor];
    la1.frame = CGRectMake(30, 55, 300, 300);
    [self.view addSubview:la1];
    self.la1 = la1;
   
   
    self.isrRecognizer = [IFlySpeechRecognizer sharedInstance];
    self.isrRecognizer.delegate = self;
    [self.isrRecognizer setParameter:@"json" forKey:[IFlySpeechConstant RESULT_TYPE]];
    [self.isrRecognizer setParameter:IFLY_AUDIO_SOURCE_STREAM forKey:@"audio_source"];
   
    BOOL ret = [self.isrRecognizer startListening];
    NSLog(@"Debug: ret = %@", ret ? @"Y" : @"N");
    if (ret)
    {///Users/mazhongyi/Desktop/minxingkeda的副本/mazytest.wav
        [self.isrRecognizer writeAudio:[NSData dataWithContentsOfFile:@"/Users/mazhongyi/Desktop/minxingkeda的副本/mazytest.wav"]];
        [self.isrRecognizer stopListening];
    }
}

- (void) onResults:(NSArray *) results isLast:(BOOL)isLast{
  //   NSLog(@"Debug: results = %@", results);
    NSMutableString *result = [[NSMutableString alloc] init];
    NSDictionary *dic = [results objectAtIndex:0];

    for (NSString *key in dic) {
        [result appendFormat:@"%@",key];
    }

    NSString *resultFromJson = [ISRDataHelper stringFromJson:result];


    self.la1.text =  [NSString stringWithFormat:@"%@",resultFromJson];
     NSLog(@"%@",resultFromJson);
}
- (void) onError:(IFlySpeechError *) error
{
     NSLog(@"Debug: code = %d, type = %d, desc = %@.", error.errorCode, error.errorType, error.errorDesc);
}

 楼主| 1013751425@qq.c 发表于 2018-5-16 09:48:56
2#
[IFLYTEK] recog_result_callback resultStatus==0,result={"sn":1,"ls":false,"bg":0,"ed":0,"ws":[{"bg":0,"cw":[{"sc":0.0,"w":"Êàë"}]}]},resultLen=77
2018-05-16 09:41:40.117617+0800 minxingkeda[15025:519483] [IFLYTEK] -[ISREngine isVoiceChange],voiceChange=0
2018-05-16 09:41:40.117790+0800 minxingkeda[15025:519483] [IFLYTEK] -[ISRDataHander dataHander:parse:],params={"sn":1,"ls":false,"bg":0,"ed":0,"ws":[{"bg":0,"cw":[{"sc":0.0,"w":"Êàë"}]}]}
2018-05-16 09:41:40.117942+0800 minxingkeda[15025:519483] [IFLYTEK] -[ISRDataHander dataHander:parse:],resultString={"sn":1,"ls":false,"bg":0,"ed":0,"ws":[{"bg":0,"cw":[{"sc":0.0,"w":""}]}]},isParse=0
2018-05-16 09:41:40.118474+0800 minxingkeda[15025:519360]
2018-05-16 09:41:40.122306+0800 minxingkeda[15025:519483] [IFLYTEK] recog_result_callback resultStatus==5,result={"sn":2,"ls":true,"bg":0,"ed":0,"ws":[{"bg":0,"cw":[{"sc":0.0,"w":"„ÄÇ"}]}]},resultLen=76
2018-05-16 09:41:40.122476+0800 minxingkeda[15025:519483] [IFLYTEK] -[ISREngine isVoiceChange],voiceChange=0
2018-05-16 09:41:40.122780+0800 minxingkeda[15025:519483] [IFLYTEK] -[ISRDataHander dataHander:parse:],params={"sn":2,"ls":true,"bg":0,"ed":0,"ws":[{"bg":0,"cw":[{"sc":0.0,"w":"„ÄÇ"}]}]}
2018-05-16 09:41:40.122930+0800 minxingkeda[15025:519483] [IFLYTEK] -[ISRDataHander dataHander:parse:],resultString={"sn":2,"ls":true,"bg":0,"ed":0,"ws":[{"bg":0,"cw":[{"sc":0.0,"w":""}]}]},isParse=0
2018-05-16 09:41:40.130313+0800 minxingkeda[15025:519360]
2018-05-16 09:41:40.130902+0800 minxingkeda[15025:519483] [IFLYTEK] -[IFlyStreamRecognizer onEnd:] onEnd:0
2018-05-16 09:41:40.131901+0800 minxingkeda[15025:519483] [IFLYTEK] -[IFlyStreamRecognizer setState:],state=3
2018-05-16 09:41:40.132248+0800 minxingkeda[15025:519483] [IFLYTEK] -[IFlyStreamRecognizer setState:],ISREnd,state = 5,_delegate=655008
2018-05-16 09:41:40.133413+0800 minxingkeda[15025:519483] [IFLYTEK] info:{"rec_ustop":"0","app_lrs":390,"app_frs":385,"app_fau":14,"app_start":"2018/05/16 09:41:39 733","app_ssb":0,"app_lau":16}

楼内回复

上传的识别的音频格式是有要求的,目前支持的格式是 pcm 和 wav 格式、音频采样 率要是 16k 或者 8k、采样精度16 位、单声道音频(采样率 16k 比 8k 识别效果要好一 些) 。 具体可以参考: http://bbs.xfyun.cn/for  详情 发表于 2018-5-16 14:45
使用道具 举报 回复
百花 发表于 2018-5-16 14:44:31
3#
1013751425@qq.c 发表于 2018-5-16 09:48
recog_result_callback resultStatus==0,result={"sn":1,"ls":false,"bg":0,"ed":0,"ws":[{"bg":0,"cw":[{ ...

Dear
感谢您致信和支持讯飞开放平台!
音频可以保存下来,http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=28628&highlight=%E4%BF%9D%E5%AD%98,用cooledit 软件打开听下
祝您工作愉快~
使用道具 举报 回复
百花 发表于 2018-5-16 14:45:21
4#
1013751425@qq.c 发表于 2018-5-16 09:48
recog_result_callback resultStatus==0,result={"sn":1,"ls":false,"bg":0,"ed":0,"ws":[{"bg":0,"cw":[{ ...

上传的识别的音频格式是有要求的,目前支持的格式是 pcm 和 wav 格式、音频采样
率要是 16k 或者 8k、采样精度16 位、单声道音频(采样率 16k 比 8k 识别效果要好一
些) 。
具体可以参考:
http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=7051

另外我们识别的音频长度最大为 60S,在使用音频是要注意你的本地音频的
参数要和代码里的读取音频参数保持一致。

使用道具 举报 回复