IFlySpeechRecognizerDelegate Protocol Reference
| Conforms to | NSObject |
|---|---|
| Declared in | IFlySpeechRecognizerDelegate.h |
– onCompleted:
required method
识别结果回调
- (void)onCompleted:(IFlySpeechError *)errorCodeParameters
errorCode |
错误描述 |
|---|
Discussion
在进行语音识别过程中的任何时刻都有可能回调此函数,你可以根据errorCode进行相应的处理,当errorCode没有错误时,表示此次会话正常结束;否则,表示此次会话有错误发生。特别的当调用cancel函数时,引擎不会自动结束,需要等到回调此函数,才表示此次会话结束。在没有回调此函数之前如果重新调用了startListenging函数则会报错误。
Declared In
IFlySpeechRecognizerDelegate.h
– onResults:isLast:
required method
识别结果回调
- (void)onResults:(NSArray *)results isLast:(BOOL)isLastParameters
results |
-[out] 识别结果,NSArray的第一个元素为NSDictionary,NSDictionary的key为识别结果,sc为识别结果的置信度。 |
|---|---|
isLast |
-[out] 是否最后一个结果 |
Return Value
appendFormat:@“%@”,key];//合并结果 } }
Discussion
在识别过程中可能会多次回调此函数,你最好不要在此回调函数中进行界面的更改等操作,只需要将回调的结果保存起来。
使用results的示例如下:
- (void) onResults:(NSArray ) results{
NSMutableString result = [[NSMutableString alloc] init];
NSDictionary dic = [results objectAtIndex:0];
for (NSString key in dic){
Declared In
IFlySpeechRecognizerDelegate.h
– onVolumeChanged:
音量变化回调
在录音过程中,回调音频的音量。
- (void)onVolumeChanged:(int)volumeParameters
volume |
-[out] 音量,范围从0-30 |
|---|
Declared In
IFlySpeechRecognizerDelegate.h
– onBeginOfSpeech
开始录音回调
当调用了startListening函数之后,如果没有发生错误则会回调此函数。
如果发生错误则回调onCompleted:函数
- (void)onBeginOfSpeechDeclared In
IFlySpeechRecognizerDelegate.h
– onEndOfSpeech
停止录音回调
当调用了stopListening函数或者引擎内部自动检测到断点,如果没有发生错误则回调此函数。
如果发生错误则回调onCompleted:函数
- (void)onEndOfSpeechDeclared In
IFlySpeechRecognizerDelegate.h
– onCancel
取消识别回调
当调用了cancel函数之后,会回调此函数,在调用了cancel函数和回调onCompleted之前会有一个
短暂时间,您可以在此函数中实现对这段时间的界面显示。
- (void)onCancelDeclared In
IFlySpeechRecognizerDelegate.h
– getAudioKey:
返回音频Key
- (void)getAudioKey:(NSString *)keyParameters
key |
音频Key |
|---|
Declared In
IFlySpeechRecognizerDelegate.h
– onEvent:arg0:arg1:data:
扩展事件回调
根据事件类型返回额外的数据
- (void)onEvent:(int)eventType arg0:(int)arg0 arg1:(int)arg1 data:(NSData *)eventDataParameters
eventType |
事件类型,具体参见IFlySpeechEventType的IFlySpeechEventTypeVoiceChangeResult枚举。 |
|---|---|
arg0 |
arg0 |
arg1 |
arg1 |
eventData |
事件数据 |
Declared In
IFlySpeechRecognizerDelegate.h