Skip to content

mapluisch/OpenAI-Text-To-Speech-for-Unity

Repository files navigation

OpenAI Text-to-Speech Integration for Unity

Implementation of OpenAI's Text-To-Speech in Unity - synthesize any text and play it via any AudioSource.


Overview

This project integrates OpenAI's Text-to-Speech API into any Unity project, allowing users to convert and synthesize text to spoken audio via any AudioSource component within seconds.

It does not use third-party libraries, making it super lightweight and easy to use cross-platform.

What's new in v.1.1.

  • Added a new custom editor script for easily setting up TTS within your Unity project (see demo videos below)

Demos

Once you've installed this project, setting up OpenAI's TTS within Unity takes seconds.

Integrate this project (either in your existing project, or in a fresh one), then open up the TTS Setup Prefab and click through the steps, as shown in this demo:

OpenAI.TTS.Setup.Demo.mp4

I've also added a quick UI example scene, so you can tinker around with some TTS settings easily:

OpenAI.TTS.for.Unity.Demo.mp4

Setup

  1. Download the latest release .unitypackage.
  2. Import it into your own project, e.g. via Assets > Import Package.
  3. Either open the OpenAI-TTS-Example scene, or open up the TTS Setup Prefab and click through the installation steps.
  • Optional: Change the TTSManager Prefab settings to your liking (useful if you want to have different entities with predefined voices, speeds, etc.)
  1. Reference the TTSManager and call TTSManager.SynthesizeAndPlay via script.

Using OpenAI TTS in your own scene

  1. Open up the TTS Setup Prefab.
  2. Add your OpenAI API key first, then click through the installation steps.
  • Optional: Change the TTSManager Prefab settings to your liking (useful if you want to have different entities with predefined voices, speeds, etc.)
  1. Reference a TTSManager and call TTSManager.SynthesizeAndPlay via script.

Disclaimer

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 😊

About

Implementation of OpenAI's Text-To-Speech in Unity. Synthesize any text and play it via any AudioSource.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages