> For the complete documentation index, see [llms.txt](https://anything-world.gitbook.io/anything-world/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://anything-world.gitbook.io/anything-world/unity-1/legacy-package-api-references/api-references/anythingspeech.md).

# AnythingSpeech

## AnythingSpeech Class Reference

### Public Member Functions

> `delegate void` <mark style="color:blue;">AWSpeechHandler</mark> (string testResponse)
>
> `delegate void` <mark style="color:blue;">AWSpeechDoneHandler</mark> (string testResponse)
>
> `void`` `<mark style="color:blue;">`StartListening`</mark>` ``(`<mark style="color:blue;">`AWSpeechHandler`</mark>` ``responseCallback,`` `<mark style="color:blue;">`AWSpeechDoneHandler`</mark>` ``doneCallback)`
>
> `void`` `<mark style="color:blue;">`StartListening`</mark>` ``(`<mark style="color:blue;">`AWSpeechDoneHandler`</mark>` ``doneCallback)`
>
> `void`` `<mark style="color:blue;">`StopListening`</mark>` ``()`
>
> `void`` `<mark style="color:blue;">`Speak`</mark>` ``(string thingToSay, string voiceName="none")`
>
> `void`` `<mark style="color:blue;">`ListenForInterval`</mark>` ``(float time,`` `<mark style="color:blue;">`AWSpeechDoneHandler`</mark>` ``doneCallBack)`
>
> `void`` `<mark style="color:blue;">`ListenForInterval`</mark>` ``(float time,`` `<mark style="color:blue;">`AWSpeechHandler`</mark>` ``responseCallBack, AWSpeechDoneHandler doneCallBack)`

### Member Functions

#### <mark style="color:purple;">AWSpeechDoneHandler()</mark>

delegate void AnythingWorld.Speech.AnythingSpeech.AWSpeechDoneHandler (string <mark style="color:blue;">testResponse</mark>)

#### <mark style="color:purple;">AWSpeechHandler()</mark>

delegate void AnythingWorld.Speech.AnythingSpeech.AWSpeechHandler (string <mark style="color:blue;">testResponse</mark>)

#### <mark style="color:purple;">**ListenForInterval()**</mark>

void AnythingWorld.Speech.AnythingSpeech.ListenForInterval (float <mark style="color:blue;">time</mark>, <mark style="color:blue;">AWSpeechDoneHandler doneCallBack</mark>)

{% hint style="info" %}
**Listen for a specified amount of time and receive a string to a callback.**
{% endhint %}

#### <mark style="color:purple;">ListenForInterval()</mark>

void AnythingWorld.Speech.AnythingSpeech.ListenForInterval (float <mark style="color:blue;">time</mark>, <mark style="color:blue;">AWSpeechHandler responseCallBack</mark>, <mark style="color:blue;">AWSpeechDoneHandler doneCallBack</mark>)

#### <mark style="color:purple;">Speak()</mark>

void AnythingWorld.Speech.AnythingSpeech.Speak (string <mark style="color:blue;">thingToSay</mark>, string <mark style="color:blue;">voiceName =</mark> "none")

{% hint style="info" %}
**Use speech synthesis to say input string**.
{% endhint %}

#### <mark style="color:purple;">StartListening()</mark>

void AnythingWorld.Speech.AnythingSpeech.StartListening (<mark style="color:blue;">AWSpeechDoneHandler doneCallback</mark>)

#### <mark style="color:purple;">StartListening()</mark>

void AnythingWorld.Speech.AnythingSpeech.StartListening (<mark style="color:blue;">AWSpeechHandler responseCallback</mark>, <mark style="color:blue;">AWSpeechDoneHandler doneCallback</mark>)

{% hint style="info" %}
**Activates voice input and starts listening to the user.**
{% endhint %}

#### <mark style="color:purple;">StopListening()</mark>

void AnythingWorld.Speech.AnythingSpeech.StopListening()

{% hint style="info" %}
**Deactivate voice input and stop listening.**
{% endhint %}

### Property

#### <mark style="color:purple;">Instance</mark>

<mark style="color:blue;">AnythingSpeech</mark> AnythingWorld.Speech.AnythingSpeech.Instance

### Parameters

| Parameters                                          | Definition                                                                   |
| --------------------------------------------------- | ---------------------------------------------------------------------------- |
| <mark style="color:blue;">`time`</mark>             | Time in seconds to listen.                                                   |
| <mark style="color:blue;">`responseCallBack`</mark> | Callback handling any detected changes to the input string during listening. |
| <mark style="color:blue;">`doneCallBack`</mark>     | Callback handling the final detected string once listening completed         |
| <mark style="color:blue;">`thingToSay`</mark>       | String to vocalise                                                           |
| <mark style="color:blue;">`voiceName`</mark>        | Name of voice                                                                |

### Example

```csharp
using AnythingWorld.Speech;

public class SpeechController: MonoBehaviour
{  
    void Start()
    {
        AnythingSpeech speech = AnythingSpeech.Instance;
        speech.Speak("Hello Anything World");
    }
}
```
