WatchKit: Speech to text conversion in WatchKit Apps

后端 未结 3 824
孤城傲影
孤城傲影 2020-12-19 07:39

Can any one help me with a sample code for adding Speech to Text conversion feature in Apple Watchkit apps.

3条回答
  •  清酒与你
    2020-12-19 08:02

    Yes, it's possible. Here is the documentation: https://developer.apple.com/library/prerelease/ios/documentation/WatchKit/Reference/WKInterfaceController_class/index.html#//apple_ref/occ/instm/WKInterfaceController/presentTextInputControllerWithSuggestions:allowedInputMode:completion:

    The code look like this. You provide a suggestions array with words (or emoji too) and you set the allowed input mode that can accept animated emoji, emoji or plan text only.

    [self presentTextInputControllerWithSuggestions:@[@"hello", @"world"] allowedInputMode:WKTextInputModePlain completion:^(NSArray *results) {
        NSLog(@"results: %@", results);
    }];
    

    The result is this:

    enter image description here

提交回复
热议问题