title: Swift text to speech
body: <p>I have a block of code that is not working, but not giving me a runtime error either. There is just no speech coming out of the speaker.</p>
  
  <pre><code>let synth = AVSpeechSynthesizer()
  var myUtterance = AVSpeechUtterance(string: audioTextField.text)
  myUtterance.rate = 0.3
  synth.speak(myUtterance)
  </code></pre>
  
  <p>Is there any code I'm missing out on or is it something else? Help would be much appreciated.</p>
  
  <p>Edit: It's not working in any @IBActions, but is working fine in the view did load function....</p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
      speechRecognizer?.delegate = self
      timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(tick), userInfo: nil, repeats: true)
      tick()
      requestSpeechAuth()
  //WORKS HERE
  }
  
  @IBAction func audioButtonPressed(_ sender: Any) {
  //DOESN"T WORK HERE    
      if isRecording {
          stopRecording()
      } else {
          startRecording()
      }
  }
  </code></pre>