# VoiceBuilderExtensions

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.voicebuilderextensions/
> Summary: VoiceBuilderExtensions: Adds the voice tools to the Tracon chain.

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.Voice.dll</code></div>

Adds the voice tools to the Tracon chain.

```csharp
public static class VoiceBuilderExtensions
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.voicebuilderextensions/">VoiceBuilderExtensions</a></dd><dt>Inherited Members</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a></dd></dl>

## Methods

### <a id="Tracon_VoiceBuilderExtensions_UseVoice_Tracon_ITraconBuilder_Microsoft_Extensions_Configuration_IConfiguration_System_Action_Tracon_VoiceOptions__"></a> UseVoice\(ITraconBuilder, IConfiguration, Action<VoiceOptions\>?\)

Registers the voice tools, reading settings from configuration.

```csharp
public static ITraconBuilder UseVoice(this ITraconBuilder builder, IConfiguration configurationSection, Action<VoiceOptions>? configure = null)
```

#### Parameters

`builder` [ITraconBuilder](/api/tracon.itraconbuilder/)

The Tracon chain.

`configurationSection` [IConfiguration](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration.iconfiguration)

The `Tracon:Voice` section.

`configure` [Action](https://learn.microsoft.com/dotnet/api/system.action\-1)<[VoiceOptions](/api/tracon.voiceoptions/)\>?

Changes to apply after configuration binding.

#### Returns

 [ITraconBuilder](/api/tracon.itraconbuilder/)

The continuation of the chain.

#### Remarks

Registers the speech tools an agent can call. The real-time
conversation layer is a separate, opt-in call
(`UseVoiceConversation`).

```csharp
builder.AddTracon()
       .UseVoice(builder.Configuration.GetSection("Tracon:Voice"));
```

#### Exceptions

 [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception)

When a dependency is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

### <a id="Tracon_VoiceBuilderExtensions_UseVoice_Tracon_ITraconBuilder_System_Action_Tracon_VoiceOptions__"></a> UseVoice\(ITraconBuilder, Action<VoiceOptions\>\)

Registers the voice tools.

```csharp
public static ITraconBuilder UseVoice(this ITraconBuilder builder, Action<VoiceOptions> configure)
```

#### Parameters

`builder` [ITraconBuilder](/api/tracon.itraconbuilder/)

The Tracon chain.

`configure` [Action](https://learn.microsoft.com/dotnet/api/system.action\-1)<[VoiceOptions](/api/tracon.voiceoptions/)\>

The settings.

#### Returns

 [ITraconBuilder](/api/tracon.itraconbuilder/)

The continuation of the chain.

#### Remarks

Registration uses `TryAdd*`: when the consumer registered its own
[ISpeechSynthesizer](/api/tracon.ispeechsynthesizer/) or [ISpeechTranscriber](/api/tracon.ispeechtranscriber/)
implementation BEFORE this call, theirs is preserved. When both are the
consumer's, the ElevenLabs settings (provider name, API key, address) are
not required.

The settings are validated when the application starts; an invalid value
stops the host before the first request.

Three tools are registered: `speak`, `transcribe`, `list_voices`.
tools are defined IN CODE; the UI only selects them.

The built-in client also voices a dialogue (several speakers in one request). No
[ISpeechDialogueSynthesizer](/api/tracon.ispeechdialoguesynthesizer/) is registered: code takes the capability
from [ISpeechProviderResolver.GetDialogueSynthesizerAsync](/api/tracon.ispeechproviderresolver/#Tracon_ISpeechProviderResolver_GetDialogueSynthesizerAsync_System_String_System_Threading_CancellationToken_), which reads
it from the bound synthesizer and applies the tenant's checks. A synthesizer of
your own that implements the interface is used instead; one that does not is
reported, not replaced by the built-in client.

#### Exceptions

 [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception)

When a dependency is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).
