谁能帮我在Apple Watchkit应用程序中添加语音到文本转换功能的示例代码。
发布于 2015-03-11 17:26:31
是的,有可能。以下是文档:ref/occ/instm/WKInterfaceController/presentTextInputControllerWithSuggestions:allowedInputMode:completion
代码看起来是这样的。您提供了一个包含单词(或表情符号)的建议数组,并设置了允许的输入模式,该模式只能接受动画表情符号、表情符号或计划文本。
[self presentTextInputControllerWithSuggestions:@[@"hello", @"world"] allowedInputMode:WKTextInputModePlain completion:^(NSArray *results) {
NSLog(@"results: %@", results);
}];其结果是:

发布于 2015-03-15 15:34:01
您可以要求用户输入并给他建议(参见下面的Swift示例)。
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")
}
}
})如果建议是nil,则直接去听写。它不是在模拟器上工作,而是在真正的观察中。
发布于 2015-10-27 23:56:44
self.presentTextInputControllerWithSuggestions(["Y","N"], allowedInputMode: WKTextInputMode.Plain,
completion:{(results) -> Void in
let aResult = results?[0] as? String
print(aResult)
})https://stackoverflow.com/questions/28984678
复制相似问题