How can I turn text into speech?
Asked on 07/16/2024
1 search
To turn text into speech, you can use the speech synthesis API. This API allows you to create speech synthesis utterance objects with the text you want to be spoken and then pass these objects into the speech synthesis object to speak them. This process happens locally on the device, ensuring that no data leaves the device, and it does not require any API keys or accounts.
Here's a brief overview of how you can implement this:
- Create a Speech Synthesis Utterance Object: This object contains the text you want to be spoken.
- Pass the Utterance to the Speech Synthesis Object: This object will handle the actual speaking of the text.
For example, in a web environment, you can use the Web Speech API to achieve this. Here is a simple code snippet:
// Create a new instance of SpeechSynthesisUtterance
let utterance = new SpeechSynthesisUtterance("Hello, world!");
// Use the speechSynthesis object to speak the utterance
window.speechSynthesis.speak(utterance);
This API is also available in Safari and can be used in various applications, including games and other interactive content. For more details, you can refer to the session Optimize for the spatial web from WWDC 2024.

Meet the Translation API
Discover how you can translate text across different languages in your app using the new Translation framework. We’ll show you how to quickly display translations in the system UI, and how to translate larger batches of text for your app’s UI.

Bring your app’s core features to users with App Intents
Learn the principles of the App Intents framework, like intents, entities, and queries, and how you can harness them to expose your app’s most important functionality right where people need it most. Find out how to build deep integration between your app and the many system features built on top of App Intents, including Siri, controls and widgets, Apple Pencil, Shortcuts, the Action button, and more. Get tips on how to build your App Intents integrations efficiently to create the best experiences in every surface while still sharing code and core functionality.

Platforms State of the Union
Discover the newest advancements on Apple platforms.