title: Swift or Objective-C command line tool and text to speech not outputting audio
body: <p>I am writing a morse code command line tool for Mac OS X written with Swift as a scripting language. I want to give the user the option to hear the morse code using Apple's NSSpeechSynthesizer. I can get this to work inside an app no sweat. But inside a command line tool or a Swift script the startSpeakingString() function is not audible--unless I step through the code line by line.</p>
  
  <p><em>Here is the code in Swift (it's the same for a proper command line tool or a script)</em></p>
  
  <pre><code>import Foundation
  import AppKit
  
  var synth:NSSpeechSynthesizer = NSSpeechSynthesizer.init()
  synth.startSpeakingString("dit dah")
  </code></pre>
  
  <p><em>And here is the code in an Objective-C command line tool</em></p>
  
  <pre><code>@import Foundation;
  @import AppKit;
  
  int main(int argc, const char * argv[]) {
      @autoreleasepool {
           NSSpeechSynthesizer *synth = [[NSSpeechSynthesizer alloc] init];
           [synth startSpeakingString:@"dit dah"];
      }
      return 0
  }
  </code></pre>
  
  <p>The NSSpeechSythesizer instance seems legit in all cases. The startSpeakingString() function returns true in all cases. Here is my repo (work in progress): <a href="https://github.com/jpavley/swift-scripts" rel="nofollow">https://github.com/jpavley/swift-scripts</a></p>