Implementation of OpenAI's Text-To-Speech in Unity - synthesize any text and play it via any AudioSource.
This project integrates OpenAI's Text-to-Speech API into a Unity application, allowing users to convert and synthesize text to spoken audio within Unity via any AudioSource component. Tested with Unity version 2022.3.13f1.
Unity.TTS.Demo.mp4
- Download the latest release
.unitypackage
. - Import it into your own project, e.g. via
Assets > Import Package
. - Either open the
OpenAI-TTS-Example
scene, or add the necessary Prefabs to your own scene:
- Add
OpenAI
andTTSManager
Prefabs to your scene. - Add your OpenAI API key to the OpenAI-Prefab.
- Optional: Change the
TTSManager
Prefab settings to your liking (useful if you want to have different entities with predefined voices, speeds, etc.)
- Call
TTSManager.SynthesizeAndPlay
of yourTTSManager
object.
This project is a prototype and serves as a basic example of integrating OpenAI's TTS API with Unity. Feel free to create a PR.