0

I'm trying to implement audio to text,audio is playing well but When RecognitionRequest is passed through recognitionTaskit showing error

:Error is:Error Domain=kAFAssistantErrorDomain Code=1101 "(null)"

and getting null

my code is :

func requestSpeechMethod()
    {
        SFSpeechRecognizer.requestAuthorization {authenticateStatus in

            if authenticateStatus == SFSpeechRecognizerAuthorizationStatus.authorized {
                if let path = Bundle.main.url(forResource: "2", withExtension: "mp3")
                {
                    do {
                        //----------------------------------------
                        let audio = try AVAudioPlayer(contentsOf: path)
                        self.audioPlayer = audio
                        self.audioPlayer.delegate = self
                        audio.play()
                        //----------------------------------------
                    }
                    catch
                         {
                        print("Error")
                    }
                    //----------------------------------------
                    let recognizer = SFSpeechRecognizer()
                    let request = SFSpeechURLRecognitionRequest(url: path)
                    recognizer?.recognitionTask(with: request) { (result,error) in
                        //---------------------
                        if let error = error {
                            print("Error is:\(error)")
                        } else
                           {
                            self.textVOutlet.text = result?.bestTranscription.formattedString
                        }
                        //---------------------
                    }
                }
                   //----------------------------------------
            }
        }
    }
Shabbir Ahmad
  • 615
  • 7
  • 17
  • 1
    Are you running this in the simulator or on a device? Have a look at this answer: http://stackoverflow.com/a/37811160/4063602 where it is suggested that you should run on a device – pbodsk May 04 '17 at 11:07
  • Thanks for reply..My app running on simulator, may be error showing because of that. – Shabbir Ahmad May 04 '17 at 11:14
  • Could be. Could you try running it on a device and see if that works – pbodsk May 04 '17 at 11:16

0 Answers0