     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
         
-        textView.text = "Listening..."
-    }
-
-    override func viewDidAppear(_ animated: Bool) {
-        super.viewDidAppear(animated)
-        
         speechRecognizer?.delegate = self
         startListening()
     }
-    
+
     func startListening() {
-        if recognitionTask != nil {
-            recognitionTask?.cancel()
-            recognitionTask = nil
-        }
-        
         recognitionRequest = SFSpeechAudioBufferRecognitionRequest()
         guard let recognitionRequest = recognitionRequest else {
             return

            let alertController = UIAlertController(title: nil,
                                                    message: "Speech Recognition is currently unavailable.",
                                                    preferredStyle: .alert)
            let alertAction = UIAlertAction(title: "OK", style: .default, handler: nil)
            alertController.addAction(alertAction)
            self.present(alertController, animated: true, completion: nil)
        }
    }
}

        
        do {
            try audioEngine.start()
            textView.text = "Listening..."
        } catch {
            print("Audio engine failed to start")
        }
