2016-09-28 4 views
1

Стараюсь с использованием распознавания речи, как показано нижеIOS 10 распознавания речи API: Error Domain = kAFAssistantErrorDomain Code = 1101

- (void)viewDidLoad { 

    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
    [self startRecognizer]; 
} 

- (void)startRecognizer { 

    [SFSpeechRecognizer requestAuthorization:^(SFSpeechRecognizerAuthorizationStatus status) { 
     if (status == SFSpeechRecognizerAuthorizationStatusAuthorized) 
     { 
     SFSpeechRecognizer *sf =[[SFSpeechRecognizer alloc] init]; 
     NSURL *mp3Path = [[NSBundle bundleForClass:[self class]] URLForResource:@"test" withExtension:@"mp3"]; 
     SFSpeechURLRecognitionRequest *speechRequest = [[SFSpeechURLRecognitionRequest alloc]initWithURL:mp3Path]; 
     [sf recognitionTaskWithRequest:speechRequest resultHandler:^(SFSpeechRecognitionResult * _Nullable result, NSError * _Nullable error) { 
      NSString * translatedString = [[[result bestTranscription] formattedString] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 

      NSLog(@"%@",translatedString); 
     }]; 
     } 
    }]; 
} 

ответ

0

добавить NSSpeechRecognitionUsageDescription ключ в вашем info.plist и запустить этот проект в устройстве, если вы проверяете в simulator. Вам нужно ios real device running ios10, чтобы проверить это!

Для получения более подробной информации вы можете обратиться к hackingwithswift's arcticle!