AIDevKit - AI Suite for Unity
API ReferencesDiscordGlitch9
  • Introduction
    • AI Dev Kit 3.7.0
    • Troubleshooting
    • FAQ
    • Update Logs
  • Provider Setup
    • API Key Setup
    • OpenAI
    • Google Gemini
    • ElevenLabs
    • Ollama
    • OpenRouter
  • Editor Tools
    • Introduction
    • Editor Chat
    • Model Library
    • Voice Library
  • GEN Tasks
    • Overview
    • Prefixes
    • Response
    • Chat
    • Image
    • Video
    • SoundFX
    • Speech
    • Transcript
    • Voice Change
    • Audio Isolation
    • Sequence
  • Advanced API (Pro)
    • Assistants
      • How it works
      • Creating custom functions
      • Creating assistants API
    • Realtime
  • Legacy API
    • OpenAI
      • 💬Chat completions
      • 🖼️Image operations
      • 🗣️Text to speech
      • 🎙️Speech to text
        • Recording real-time in Unity
      • 💾Files
      • 🔎Embeddings
      • 🛡️Moderations
      • ⚙️Fine-tuning
    • Google Gemini
      • 📝System instructions
      • 💬Text generation
      • ⚙️Fine-tuning
      • ▶️Fucntion calling
      • 🔎Embeddings
      • 🛡️Safety
      • 💻Code execution
  • Legacy Documents
    • AI Dev Kit 1.0
      • Preperation
      • Scriptable Toolkits
        • Chat Streamer
        • Image Generator
        • Voice Transcriber
        • Voice Generator
      • Editor Tools
      • Troubleshooting (Legacy)
        • ❗Build Error: The name 'UnityMenu' does not exist in the current context
        • ❗The type or namespace name 'AndroidJavaObject' could not be found
        • ❗The type or namaspace name 'Plastic' does not exist
        • ❗Build Error: The name 'Asset Database' does not exist in the current context
        • ❗'ModelData.Create(Provider, string, UnixTime?, string)': not all code paths return a value
      • Code Generators
        • C# Script Generator
        • Unity Component Generator
    • AI Dev Kit 2.0
      • Event Handlers
      • Editor Chat
      • Editor Vision (TTI, ITI)
      • Editor Speech (TTS)
      • Management Tools
        • Prompt History Viewer
        • AI Model Manager
        • TTS Voice Manager
        • OpenAI File Manager
        • OpenAI Assistant Manager
        • ElevenLabs Voice Library
Powered by GitBook
On this page
  1. GEN Tasks

Speech

Generate a speech using a text-to-speech model

PreviousSoundFXNextTranscript

Last updated 4 hours ago

GENSpeech

returns

Convert written text into natural-sounding speech using AI voices.

Perfect for dialogue, narration, accessibility, or dynamic voice-over content — powered by ElevenLabs and other TTS providers.

Basic Usage

AudioClip voice = await "Welcome to the future of AI voices."
    .GENSpeech()
    .SetModel(ElevenLabsModel.Eleven_Flash_V2) // optional if you have set the default tts model in the settings
    .SetVoice(ElevenLabsVoice.Rachel) // optional if you have set the default voice in the settings
    .SetSpeed(1.0f) // optional
    .ExecuteAsync();

Streaming

Play audio in real-time as it’s generated — ideal for chat avatars or quick feedback loops. It requires StreamAudioPlayer from the Glitch9 core library.

await "Loading complete."
    .GENSpeech()
    .SetVoice(ElevenLabsVoice.Adam)
    .StreamAsync(myStreamAudioPlayer);

// StreamAudioPlayer is a component that plays incoming audio chunks as they arrive.

GeneratedAudio