GUIDE

Swift text to speech for iOS with natural voices

On iOS, text to speech starts with AVSpeechSynthesizer: a few lines of Swift and the phone reads any text with its built-in voices, offline and free. Those voices depend on what the user has installed, and they are the same ones every other app uses.

The free SuperClonica engine gives an iOS or macOS app its own natural voice, in two ways: audio files voiced in advance and bundled with the app, or a speech server the app calls. This guide shows both with ready Swift code and says when AVSpeechSynthesizer is still the right tool.

Three ways to make an iOS app speak

Many apps combine them: bundled lines for the interface, the server for user text, the system voice as a fallback.

  • AVSpeechSynthesizer: the system voices, offline and free, depending on what the user has installed.
  • Bundled audio: every fixed line voiced once with SuperClonica and shipped in the app.
  • A speech server: the app sends text to your SuperClonica server and plays the WAV it returns.
  • SuperClonica speaks 31 languages; Chinese is not supported yet.

Pick a voice free online

On the page of any voice, type a line of your app, 30 to 100 characters, choose the language and press Voice it. In a few seconds you hear whether it fits, with no account, right on your iPhone.

Bundle pre-voiced lines

Bundled files work offline with no delay; a change means a new app version.

  • Voice each line on your Mac with the engine: python -m pip install superclonica-cpu, then superclonica --text "Welcome back!" --voice F1 --lang en --output welcome.mp3.
  • Add the files to the Xcode project, so they are copied into the app bundle.
  • Play a line with AVFoundation: player = try AVAudioPlayer(contentsOf: Bundle.main.url(forResource: "welcome", withExtension: "mp3")!); player.play()
  • Keep player in a property of your class: a local AVAudioPlayer stops as soon as it is released.

Call your own speech server

Run the server on a machine you control: docker run -d -p 8000:8000 -v superclonica-models:/models superclonica/superclonica:cpu. iOS expects HTTPS by default, so put it behind a certificate, and set SUPERCLONICA_API_KEY so only your app can use it. Then a line is one request: var request = URLRequest(url: URL(string: "https://tts.example.com/synthesize")!); request.httpMethod = "POST"; request.setValue("application/json", forHTTPHeaderField: "Content-Type"); request.httpBody = try JSONEncoder().encode(["text": "Your order is on its way.", "voice": "F1", "lang": "en"]); let (data, _) = try await URLSession.shared.data(for: request); player = try AVAudioPlayer(data: data); player.play() Add an Authorization header with the key, and cache the data of lines that repeat.

When AVSpeechSynthesizer is enough

AVSpeechSynthesizer is enough when the voice only has to be understood: reading a notification, an accessibility helper, a prototype, or an app that must speak without any network. Choose SuperClonica when the voice is part of the product: a language tutor, a game character, a guided meditation, a brand that must sound the same for every user.