# Modules

These modules act as optional extensions that can be plugged into AI components like [`Chatbot`](https://glitch9.gitbook.io/ai-dev-kit/legacy-documents/ai-dev-kit-3.0/broken-reference), [`Chatbot (Assistants API)`](https://glitch9.gitbook.io/ai-dev-kit/legacy-documents/ai-dev-kit-3.0/broken-reference), and other higher-level interfaces.

They allow your AI to listen, speak, generate images, or execute user-defined functions in response to AI requests.

***

#### 1. Speech to Text

Enables voice input functionality using microphone capture.

**What it does**

* Records audio using the microphone.
* Converts speech to text asynchronously.
* Returns a [`Transcript`](https://glitch9inc.github.io/DocFx.AIDevKit/api/Glitch9.AIDevKit.Transcript.html) object.

**Typical usage**\
Call `StartRecording()`, speak, then call `StopRecording()` to get the [`Transcript`](https://glitch9inc.github.io/DocFx.AIDevKit/api/Glitch9.AIDevKit.Transcript.html).

```csharp
stt.StartRecording();
// user speaks
Transcript transcript = await stt.StopRecording();
```

<figure><img src="https://3976940093-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl7yXji5RzYhdDYsx9d1n%2Fuploads%2FZ4WMFM2FL9dgEPr2yQRF%2Fimage.png?alt=media&#x26;token=0acb1c22-56b4-43eb-9e86-50e50d613a97" alt="" width="563"><figcaption></figcaption></figure>

***

#### Text to Speech

Provides voice output via TTS generation.

**What it does**

* Converts a string response into [`GeneratedAudio`](https://glitch9inc.github.io/DocFx.AIDevKit/api/Glitch9.AIDevKit.GeneratedAudio.html) (`AudioClip`).
* Can play automatically if `AudioSource` is attached.

**Use with**\
[`Chatbot`](https://glitch9.gitbook.io/ai-dev-kit/legacy-documents/ai-dev-kit-3.0/broken-reference) or [`Chatbot (Assistants API)`](https://glitch9.gitbook.io/ai-dev-kit/legacy-documents/ai-dev-kit-3.0/broken-reference) to read responses aloud.

```csharp
GeneratedAudio audio = await tts.GenerateSpeechAsync("Hello!");
audioSource.clip = audio;
audioSource.Play();
```

<figure><img src="https://3976940093-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl7yXji5RzYhdDYsx9d1n%2Fuploads%2FTaAO18bWoAvKDovt4VMr%2Fimage.png?alt=media&#x26;token=d846c1b7-4933-4d1a-833b-06df0e4402f3" alt="" width="563"><figcaption></figcaption></figure>

***

#### Voice Changer

Applies optional pitch and speed post-processing to audio output.

**What it does**

* Alters pitch and speed for stylistic or character-based transformation.
* Simulates different speaker characteristics.

**Optional**\
Enhances immersion but is not required.

<figure><img src="https://3976940093-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl7yXji5RzYhdDYsx9d1n%2Fuploads%2FtEOj2GhGJN5Y07IZT31A%2Fimage.png?alt=media&#x26;token=71da0991-e9c3-4ce2-b5e2-53c51ac1806f" alt="" width="563"><figcaption></figcaption></figure>

***

#### Image Generator

Generates images from natural language prompts.

**What it does**

* Supports models like DALL·E (OpenAI) and Imagen (Google).
* Customizable: resolution, style, aspect ratio, quality.

**Output**\
Returns a [`GeneratedImage`](https://glitch9inc.github.io/DocFx.AIDevKit/api/Glitch9.AIDevKit.GeneratedImage.html) containing a `Texture2D`.

```csharp
var image = await imageGenerator.GenerateImageAsync("A futuristic city at night");
```

<figure><img src="https://3976940093-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl7yXji5RzYhdDYsx9d1n%2Fuploads%2FPlxe13NwH77AbxJ33G0Q%2Fimage.png?alt=media&#x26;token=6a6158d4-9e66-45bb-a62a-0088badeadc3" alt="" width="563"><figcaption></figcaption></figure>

***

#### Function Manager

Registers C# methods as callable functions through Function Calling.

**What it does**

* Makes Unity methods callable by the AI.
* Auto-generates parameter schema and metadata.

**How to Use**

1. Add [`FunctionManager`](https://glitch9inc.github.io/DocFx.AIDevKit/api/Glitch9.AIDevKit.Components.FunctionManager.html) to a GameObject.
2. Assign a script with public void methods.
3. Select a method in the Inspector.
4. Optionally describe parameters for the AI.

<figure><img src="https://3976940093-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl7yXji5RzYhdDYsx9d1n%2Fuploads%2FRTYTo1HKXvdICRRNivOJ%2Fimage.png?alt=media&#x26;token=7381d20c-daa3-41be-aa74-c82085afa77c" alt="" width="563"><figcaption></figcaption></figure>

```csharp
public class GameFunctions : MonoBehaviour
{
    public void HealPlayer(int amount, string reason)
    {
        Debug.Log($"Healing player by {amount} because {reason}");
    }
}
```

<figure><img src="https://3976940093-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl7yXji5RzYhdDYsx9d1n%2Fuploads%2FIoR5iqvYFTpzVgMTJTga%2Fimage.png?alt=media&#x26;token=013e891a-75f4-49f9-8f08-2f62f369e3f5" alt=""><figcaption></figcaption></figure>
