title: How to know when an AVSpeechUtterance has finished, so as to continue app activity?
body: <p>When an <code>AVSpeechUtterance</code> is speaking, I want to wait until it's finished before doing something else.</p>
  
  <p>There is a property of <code>AVSpeechSynthesizer</code> that's seemingly indicative of when speech is occuring:</p>
  
  <p><a href="https://developer.apple.com/reference/avfoundation/avspeechsynthesizer/1619680-isspeaking" rel="nofollow noreferrer"><code>isSpeaking</code></a></p>
  
  <p>As stupid and simple as this question might sound, I'm wondering how do I use/check this property to wait until speech has concluded before going on?</p>
  
  <p><strong>ALTERNATIVELY:</strong></p>
  
  <p>There's a delegate, that I'm also clueless as to how to use, which has an ability to do something when an utterance has finished: </p>
  
  <p><a href="https://developer.apple.com/reference/avfoundation/avspeechsynthesizerdelegate" rel="nofollow noreferrer"><code>AVSpeechSynthesizerDelegate</code></a></p>
  
  <p>There's an answer, <a href="https://stackoverflow.com/questions/28335310/objective-c-wait-for-avspeechsynthesizer-until-it-finishes-speaking-a-word">here</a>, that says to use this. But that doesn't help me because I don't know how to use a Delegate.</p>
  
  <h2>UPDATE:</h2>
  
  <p>This is how I setup my speaking class:</p>
  
  <pre><code>import AVFoundation
  
  class CanSpeak: NSObject, AVSpeechSynthesizerDelegate {
  
      let voices = AVSpeechSynthesisVoice.speechVoices()
      let voiceSynth = AVSpeechSynthesizer()
      var voiceToUse: AVSpeechSynthesisVoice?
  
      override init(){
          voiceToUse = AVSpeechSynthesisVoice.speechVoices().filter({ $0.name == "Karen" }).first
      }
  
      func sayThis(_ phrase: String){
          let utterance = AVSpeechUtterance(string: phrase)
          utterance.voice = voiceToUse
          utterance.rate = 0.5
          voiceSynth.speak(utterance)
      }
  }
  </code></pre>
  
  <h2>UPDATE 2: Wrongheaded workaround...</h2>
  
  <p>using the above mentioned <code>isSpeaking</code> property, in the gameScene:</p>
  
  <pre><code>voice.sayThis(targetsToSay)
  
      let initialPause = SKAction.wait(forDuration: 1.0)
      let holdWhileSpeaking = SKAction.run {
          while self.voice.voiceSynth.isSpeaking {print("STILL SPEAKING!")}
      }
      let pauseAfterSpeaking = SKAction.wait(forDuration: 0.5)
      let doneSpeaking = SKAction.run {print("TIME TO GET ON WITH IT!!!")}
  
  run(SKAction.sequence(
      [   initialPause,
          holdWhileSpeaking,
          pauseAfterSpeaking,
          doneSpeaking
      ]))
  </code></pre>