问题
I have succesfully implemented native speech recognition (Dictation) in Apple Watch (WatchOS 2.1, iOS 9.2.1) basically I used this code, with an empty "menu options array":
func launchDictation(){
self.presentTextInputControllerWithSuggestions([], allowedInputMode: WKTextInputMode.Plain, completion:{
(results) -> Void in
let aResult = results?[0] as? String
if(!(aResult == nil)){
print(aResult)
print("SHORT ASR COMPLETED")
dispatch_async(dispatch_get_main_queue()) {
// Update UI
}
}//end if
})//end show voice menu
}
As it is... the user taps a "Speak button", then a view pops up (showing the detected words as the user speaks and a nice small volume graph). Right now, the user has to speak, and tap "Done" to complete speech recognition. If a phrase is detected but "Done" is not tapped a "dictation failed" will eventually appear onscreen. Does somebody know how to implement some listener or delegate that detects when the end of the Dictation process a few seconds after the user has stopped speaking?
来源:https://stackoverflow.com/questions/35268552/how-to-stop-speech-recognition-dictation-in-apple-watch-when-the-user-stops-sp