 extension ViewController {
     
     func startRecording() {
+        
+        // 检查 recognitionTask 是否在运行，若在则取消任务
         if recognitionTask != nil {
             recognitionTask?.cancel()
             recognitionTask = nil
         }
         
+        // 创建一个 AVAudioSession 对象来记录语音 设置属性时会抛出一场 因此需要放进 try-catch 语句中
         let audioSession = AVAudioSession.sharedInstance()
         do {
             try audioSession.setCategory(AVAudioSessionCategoryRecord)

            print("audioSession properties weren't set because of an error.")
        }
        
        recognitionRequest = SFSpeechAudioBufferRecognitionRequest()
        
        guard let inputNode = audioEngine.inputNode else {
            fatalError("Audio engine has no input node")
        }
        
        guard let recognitionRequest = recognitionRequest else {
            fatalError("Unable to create an SFSpeechAudioBufferRecognitionRequest object")
        }
        
        recognitionRequest.shouldReportPartialResults = true;
        
        recognitionTask = speechRecognizer?.recognitionTask(with: recognitionRequest, resultHandler: { (result, error) in
            var isFinal = false
            
            if result != nil {
                self.textView.text = result?.bestTranscription.formattedString
                isFinal = (result?.isFinal)!
            }

                self.audioEngine.stop()
                inputNode.removeTap(onBus: 0)
                
                // 如果没有错误，或者结果时最终结果的话，停止request&task， 同时使识别按钮生效
                self.recognitionRequest = nil
                self.recognitionTask = nil
                self.microphoneButton.isEnabled = true
            }
        })
        
        // 向 recognitionRequest 增加一个语音输入
        // **在开始的 recognitionTask 之后增加语音输入是可行的**
        // Speech Framework 会在语音输入被加入的同时就开始进行语音识别
        let recordingFormat = inputNode.outputFormat(forBus: 0)
        inputNode.installTap(onBus: 0, bufferSize: 1024, format: recordingFormat) { (buffer, when) in
            self.recognitionRequest?.append(buffer)
        }
        
        // 准备并且开始 audioEngine
        audioEngine.prepare()
        
        do {
