Logo

iOS SDK

Note:

Supports iOS versions 11.0 and above.

Only activation via internet connection is supported.

1 Integration Steps

Note: If you are interested in trying the on-device recognition feature, please get in touch with our business contact in advance to receive an APPID. Also, please specify the language type you want to try. Contact: voice.contact@dolphin-ai.jp.

  1. Manual import: Drag SpeechEvaluate.framework into your project. Then, under General -> Frameworks, Libraries, and Embedded Content, change the Embed setting for SpeechRecognitionSDK.framework to Embed&Sign.
  2. Ensure the following pods are included: SocketRocket0.6.0, AFNetworking, SSZipArchive2.4.0.
  3. Offline sdk add model file: Place the model file (.zip) into the framework folder.
  1. Add Privacy - Microphone Usage Description to your project's info.plist file to add microphone access permissions.

1.2 Invocation Steps/Sample Code

In the file that requires the recognition function, please adhere to the delegate protocol EvalListener.

//Configuration Main Parameters
SDKParams *params = [[SDKParams alloc] init];
params.appId = @"";
params.appSecret = @"";
params.sample_rate = 16000;
params.format = @"pcm";
params.realtime = NO;
params.langType = @"ja-JP";
params.enable_intermediate_result = YES;
params.enable_punctuation_prediction = YES;
params.max_sentence_silence = 450;
params.enable_words = YES;

/**
@sourcePath Customized paths
@Documents/userPatu/model,The path before the model can be named arbitrarily.
@The vad file must be under the model file, for example:Documents/userPath/model/vad
@The language file must be under the model/asr file, for example:Documents/userPath/model/asr/ja-JP
*/
params.sourcePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"/userPath/model"];

1.2.1 Create a Speech Recognition Class and Grant Authorization

NameTypeDescription
SpeechRecognitionSpeechRecognitionRecognition class
paramsSDKParamsParameters and settings
self.params.initType = YES;
self.params.online = NO;
SpeechRecognition *speechManger = [[SpeechRecognition alloc] init];
[speechManger setInitSDK:self params:params];
self.speechManger = speechManger;

1.2.2 Callback Method Description

NameTypeDescription
onStartStringCallback method when engine connection starts
onResultStringCallback method when engine returns results
onRealtimeResultStringCallback method when engine returns intermediate results
onWarningStringCallback method when engine returns a result warning
onErrorStringCallback method when engine returns a result error
onMachineCodeStringEngine returns machine code
- (void) onRealtimeResult: (NSString *) result;

- (void) onResult: (NSString *) result;

- (void) onStart: (NSString *) taskId;

- (void) onStop;

- (void) onGetAudio: (NSData *)data;

- (void) onError: (NSString *)code msg:(NSString*)msg taskId:(nullable NSString*)taskId;

- (void) onWarning: (NSString *)code msg:(NSString*)msg taskId:(nullable NSString*)taskId;

- (void) onMachineCode: (NSString *)MachineCode;

1.2.3 Interface Parameter Description

ParameterTypeRequiredDescriptionDefault Value
lang_typeStringYesLanguage optionRequired
formatStringNoAudio encoding formatpcm
sample_rateIntegerNoAudio sampling rate16000
enable_intermediate_resultBooleanNoWhether to return intermediate recognition resultsfalse
enable_punctuation_predictionBooleanNoWhether to add punctuation in post-processingfalse
enable_inverse_text_normalizationBooleanNoWhether to perform ITN in post-processingfalse
max_sentence_silenceIntegerNoSpeech sentence breaking detection threshold. Silence longer than this threshold is considered as a sentence break. The valid parameter range is 200~1200. Unit: Milliseconds450
enable_wordsBooleanNoWhether to return word informationfalse
enable_modal_particle_filterBooleanNoWhether to enable modal particle filteringfalse
hotwords_idStringNoHotwords IDNone
hotwords_weightFloatNoHotwords weight, the range is [0.1, 1.0]0.4

1.2.4 Start/Stop Recognition

<1>Start Recognition (Internal Recording by SDK)
    [self.speechManger startRecording];
    
End Recognition
    [self.speechManger stopRecording];
    
<2>File Recognition (Directly pass the path of the audio file, local path)   
    [self.speechManger startRecognitionOralWithWavPath:@"wav audio path"];

<3>Audio Data Recognition (External recording by SDK, or file converted to NSData for recognition)    
- (void)doStart:(FinishBlock)finishBlock;
- (BOOL)doSetData:(NSData *) data isLast:(bool)isLast;
Call Method
[self.speechManger doStart:^(_Bool success) {
            if (success) {
If(Last Segment With Audio) {
[self.speechManger doSetData:data isLast:YES];
}else{
[self.speechManger doSetData:data isLast:NO];
}
}
}];

1.2.5 Load Hotwords

[self.speechManger loadWords];

1.2.6 Destroy on Exit

//Release the current model
[self.speechManger offLineRelese];

//Release all models
[self.speechManger offLineReleseAll];

1.2.7 Cancel the generation of logs

Set the parameters in model/asr/ja-JP/config:
log-level = 6
log-rotate-days=0

2 Status Code Table

Error CodeError MessageDescriptionSolution
110100UnauthorizedUnauthorizedChange the parameter to an authorized capability or contact the business department to add AI capabilities
110101Invalid Activation CodeActivation key is incorrectEnter the correct activation key
110102Model Count Exceeds LimitThe number of models exceeds the limitPlease contact the business department
110103Authorization ExpiredAuthorization has expiredContact the business department to extend the authorization period
110104Authorization FailedAuthorization failedPlease contact the business department

3 SDK Download & On-Device Model Download

3.1 SDK Download

The download link for the SDK is as follows: iOS SDK

iOS Demo

3.2 On-Device Model Download

Language TypeLanguage CodeDownload LinkRemarks
Japanese - Generalja-JPJapanese - GeneralOnly Japanese
Japanese - Hotelja-JPJapanese - HotelSupports mixed speech of Japanese and English
Englishen-USEnglish
Mandarinzh-cmn-Hans-CNMandarinSupports mixed speech of Mandarin and English