How to stop Speech Recognition (Dictation) in Apple Watch when the user stops speaking?

为君一笑 提交于 2019-12-19 05:58:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!