title: How to get frequency of sound from AVAudioEngine
body: <p>I'm implementing a speech recognition module for an app. It works fine, however there are some additional things that I need to do. For example, I need to know if a user is speaking or shouting. I know, I can achieve that by knowing the frequency of the sound. Here is how I implement it:</p>
  
  <pre><code>let audioEngine = AVAudioEngine()
  let speechRecognizer: SFSpeechRecognizer? = SFSpeechRecognizer()
  let request = SFSpeechAudioBufferRecognitionRequest()
  var recognitionTask = SFSpeechRecognitionTask()
  
  func recordAndRecognizeSpeech() {
      let node = audioEngine.inputNode
      let recordingFormat = node.outputFormat(forBus: 0)
      node.installTap(onBus: 0, bufferSize: 1024, format: recordingFormat) { (buffer, _) in
          self.request.append(buffer)
      }
  
      audioEngine.prepare()
      do {
          try audioEngine.start()
      } catch {
          return print(error)
      }
  
      guard let myRecoginizer = SFSpeechRecognizer() else {
          return
      }
  
      if !myRecoginizer.isAvailable {
          return
      }
  
      recognitionTask = (speechRecognizer?.recognitionTask(with: request, resultHandler: { (result, error) in
          //Handling speech recognition tasks here
      }))!
  
  }
  </code></pre>
  
  <p>This works fine for the speech recognition, but how can I get the frequency or amplitude value of the sound?</p>