# GoogleSpeechBuilderExtensions

> 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.googlespeechbuilderextensions/
> Summary: GoogleSpeechBuilderExtensions: Adds Google Gemini speech to the Tracon chain.

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

Adds Google Gemini speech to the Tracon chain.

```csharp
public static class GoogleSpeechBuilderExtensions
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.googlespeechbuilderextensions/">GoogleSpeechBuilderExtensions</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_GoogleSpeechBuilderExtensions_UseGoogleSpeech_Tracon_ITraconBuilder_System_Action_Tracon_GoogleSpeechOptions__"></a> UseGoogleSpeech\(ITraconBuilder, Action<GoogleSpeechOptions\>\)

Registers Gemini text-to-speech as a named Tracon speech synthesizer that also voices a dialogue.

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

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

`configure` [Action](https://learn.microsoft.com/dotnet/api/system.action\-1)<[GoogleSpeechOptions](/api/tracon.googlespeechoptions/)\>

The speech settings. The model is required.

#### Returns

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

#### Remarks

Call [GoogleProviderExtensions.UseGoogle](/api/tracon.googleproviderextensions/)
first. This call shares the authenticated Google client that `UseGoogle` registers and adds no package
and no second connection pool.

The synthesizer is a named speech provider: every call passes the tenant's egress policy against the
provider name `google`, the name the chat provider uses, so one rule covers chat, images and speech.
A tenant that has its own Google key is served with that key: the request goes to the same client the
tenant's chat requests use.

**One voice.** `POST /api/voice/speak` with `"provider": "gemini"` answers a WAV file.
[SpeechRequest.OutputFormat](/api/tracon.speechrequest/#Tracon_SpeechRequest_OutputFormat) takes `wav` (the default) or `pcm`; another format is
refused before the call. A streamed answer is raw 16-bit PCM at the model's sample rate.

**A dialogue.** The same instance voices a dialogue of exactly two voices
([ISpeechProviderResolver.GetDialogueSynthesizerAsync](/api/tracon.ispeechproviderresolver/#Tracon_ISpeechProviderResolver_GetDialogueSynthesizerAsync_System_String_System_Threading_CancellationToken_)). The request names its speakers in the
format the model takes; see [GoogleSpeechOptions.DialogueSpeakerMode](/api/tracon.googlespeechoptions/#Tracon_GoogleSpeechOptions_DialogueSpeakerMode). Gemini reports no timing,
so a request for timestamps is refused.

Billing is an estimate. Gemini bills speech by tokens, and the answer carries no character count, so Tracon
records the length of the text and labels it as estimated.

```csharp
builder.AddTracon()
       .UseGoogle(builder.Configuration["Google:ApiKey"]!)
       .UseGoogleSpeech(options =>
       {
           options.Model = "gemini-3.8-flash-tts";
           options.Voices.Add(new VoiceDescriptor { VoiceId = "Kore", Name = "Kore" });
           options.Voices.Add(new VoiceDescriptor { VoiceId = "Puck", Name = "Puck" });
       });
```

#### Exceptions

 [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception)

`builder` or `configure` is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

 [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception)

`configure` sets no model, a name that is not a valid speech provider name, a character
limit that is not greater than zero, or a [GoogleSpeechOptions.DialogueSpeakerMode](/api/tracon.googlespeechoptions/#Tracon_GoogleSpeechOptions_DialogueSpeakerMode) that is
not defined.
