Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WatchKit: Speech to text conversion in WatchKit Apps

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

like image 255
Teja Kumar Bethina Avatar asked Mar 11 '15 10:03

Teja Kumar Bethina


2 Answers

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

like image 123
BalestraPatrick Avatar answered Oct 03 '22 23:10

BalestraPatrick


You can ask for user input and give him suggestion (see Swift example bellow).

self.presentTextInputControllerWithSuggestions(["suggestion 1", "suggestion 2"] allowedInputMode: .Plain, completion: { (answers) -> Void in
    if reply && reply.count > 0 {
        if let answer = answers[0] as? String {
            println("\answer")
        }
    }
})

If suggestion is nil it goes directly to dictation. It is not working on the simulator but it is on real watch.

like image 31
jfgrang Avatar answered Oct 04 '22 01:10

jfgrang