ios - Watchkit:通过 WKInterfaceController 单击文本听写

标签 ios watchkit speech-to-text dictation

这个问题在这里已经有了答案:





WatchKit Option to ONLY Dictate?

(2 个回答)


6年前关闭。




根据 Apple 的文档 WKInterfaceController您可以让用户以这种非常简单的方式来指示预设新界面 Controller 的文本:

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")
    }
}

})

如解释 here .

我已经看到 Apple Watch 的 Amazon App 让您可以通过直接点击搜索图标来搜索产品

enter image description here

因此,您可以一步进入听写

enter image description here

通过WKInterfaceController方法,我们会得到不同的东西

enter image description here

哪个 Apple 的 API Amazon 应用程序正在使用这种方式启用听写?

(更新)
我刚刚发现它非常简单,正如 here 所解释的那样

所以我出来的最终解决方案是这个
    - (void) table:(WKInterfaceTable *)table didSelectRowAtIndex:(NSInteger)rowIndex {
if (rowIndex==0) { // handle manual selection
    __weak MainInterfaceController *weakSelf = self;
    [self presentTextInputControllerWithSuggestions:nil allowedInputMode:WKTextInputModePlain completion:^(NSArray *results) {
       if(results && [results count]>0) {
           NSString *inputText=nil;
           for(NSString *input in results) {
               NSLog(@"Input %@", input);
               inputText=input;
               break;
           }
           if(inputText!=nil && [inputText length]>0) {
               [weakSelf pushControllerWithName:@"Search" context:
                [NSDictionary dictionaryWithObjectsAndKeys:
                 inputText, @"query", nil]
                ];
           }
       } else {
           NSLog(@"No input provided");
       }
   }];
}}

最佳答案

设置模式为.Plain并且不提供任何建议。

关于ios - Watchkit:通过 WKInterfaceController 单击文本听写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30460008/

相关文章:

android - 在 phonegap/android 中语音转文本

javascript - 将语音转文本模块添加到 C# 机器人

ios - 仅在登录时获取数据

ios - 设备方向在标签栏应用程序中启动所有 View Controller

iOS 5 : UIScrollView not pass touches to nextResponder

ios - Watchkit 应用程序 : slider background color

json - 如何将服务器数据传递/解析到 WatchKit 表行中的对象?

c++ - iOS:如何在运行时使用音频单元对音频(PCM 数据)进行重新采样?

ios - 我们可以在 Apple Watch 上的通知上显示与手机应用程序上不同的操作吗?

python - 用于语音识别的流输入