Objective-c微软认知语音服务 [英] Objective-c microsoft cognitive speech service

查看:85
本文介绍了Objective-c微软认知语音服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

_ speechConfiguration = [[ SPXSpeechConfiguration
alloc ]
initWithSubscription :speechKey
region :regionService];

_speechConfiguration = [[SPXSpeechConfiguration alloc] initWithSubscription:speechKey region:regionService];

_recognizer = [[> SPXSpeechRecognizer alloc ]
init _speechConfiguration ];

_recognizer = [[SPXSpeechRecognizer alloc] init:_speechConfiguration];

[ _识别器   startContinuousRecognition ];

有什么办法吗? startContinuousRecognition`没有重新启动配置?

Is there any possible way to do `startContinuousRecognition` without re-initiate the configuration?

只有

推荐答案

您好,

您的意思是不使用 

Do you mean to not use 

_recognizer = [[SPXSpeechRecognizer_alloc] init:_speechConfiguration]:

我对目标C不是很熟悉,但看起来识别器正在使用SPXSpeechRecognizer类,配置正在使用SPXSpeechConfiguration类。  

I am not so familiar with objective C but it looks like recognizer is using SPXSpeechRecognizer class and the configuration is using SPXSpeechConfiguration class. 

以下是来自客观C的样本
quickstart
可以提供帮助。

Here is a sample from objective C quickstart from azure docs that can help.

- (void)recognizeFromMicrophone {
    SPXSpeechConfiguration *speechConfig = [[SPXSpeechConfiguration alloc] initWithSubscription:speechKey region:serviceRegion];
    if (!speechConfig) {
        NSLog(@"Could not load speech config");
        [self updateRecognitionErrorText:(@"Speech Config Error")];
        return;
    }
    
    [self updateRecognitionStatusText:(@"Recognizing...")];
    
    SPXSpeechRecognizer* speechRecognizer = [[SPXSpeechRecognizer alloc] init:speechConfig];
    if (!speechRecognizer) {
        NSLog(@"Could not create speech recognizer");
        [self updateRecognitionResultText:(@"Speech Recognition Error")];
        return;
    }
    
    SPXSpeechRecognitionResult *speechResult = [speechRecognizer recognizeOnce];
    if (SPXResultReason_Canceled == speechResult.reason) {
        SPXCancellationDetails *details = [[SPXCancellationDetails alloc] initFromCanceledRecognitionResult:speechResult];
        NSLog(@"Speech recognition was canceled: %@. Did you pass the correct key/region combination?", details.errorDetails);
        [self updateRecognitionErrorText:([NSString stringWithFormat:@"Canceled: %@", details.errorDetails ])];
    } else if (SPXResultReason_RecognizedSpeech == speechResult.reason) {
        NSLog(@"Speech recognition result received: %@", speechResult.text);
        [self updateRecognitionResultText:(speechResult.text)];
    } else {
        NSLog(@"There was an error.");
        [self updateRecognitionErrorText:(@"Speech Recognition Error")];
    }
}

我希望这有帮助!!


这篇关于Objective-c微软认知语音服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆