8

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?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Josh
  • 6,251
  • 2
  • 46
  • 73
  • "a nice small volume graph": did you do it your self or by the dictation API? – user523234 Feb 08 '16 at 12:07
  • The dictation API shows it by default, although I have read in SO that the amazon app apparently shows a colored graph like the one used by Siri @user523234 – Josh Feb 08 '16 at 12:20
  • @Josh, did you find a solution ? – Pierre Charpentier Jul 22 '16 at 13:11
  • Nope, the user has to stop voice recognition by tapping. It is so ugly! @PierreCharpentier – Josh Aug 01 '16 at 11:24
  • Thanks for your answer @Josh. Do you know if we can stop dictation programmatically after a fix time ? ( stop dictation after 10 seconds for example) – Pierre Charpentier Aug 01 '16 at 12:01
  • You can set a timer that starts inside the onBeginningOfSpeech() method of the recognizer, that does recognizer.cancel() or recognizer.stop after X seconds. @PierreCharpentier – Josh Aug 01 '16 at 15:14
  • Hmm.. It's a solution for Android and not WatchOS, isn't it ? – Pierre Charpentier Aug 02 '16 at 06:53
  • Omg, sorry for that, I am having huge ASR problems with android right now and I am starting to lose my wits!! Sorry. As far as I know, there is no way to stop speech recognition in WatchOS programmatically. @PierreCharpentier – Josh Aug 02 '16 at 07:37

0 Answers0