WatchKit: Speech to text conversion in WatchKit Apps

后端 未结 3 822
孤城傲影
孤城傲影 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:06

    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.

提交回复
热议问题