Przejdź do treści
Biblioteka skilli
Programowanie · Integracja z narzędziem

deepgram-dotnet-voice-agent

/deepgram-dotnet-voice-agent

Buduje w C# interaktywnego agenta głosowego Deepgram przez WebSocket: SettingsSchema, subskrypcje zdarzeń, strumieniowanie dźwięku z mikrofonu, wstrzykiwane wiadomości użytkownika i typy wiadomości wywołań funkcji.

Licencja
MIT
Ostatnia zmiana repozytorium
14.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
3
Przestarzałość

Brak sygnałów. Repozytorium zmienione 14.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Buduje w C# interaktywnego agenta głosowego Deepgram przez WebSocket: SettingsSchema, subskrypcje zdarzeń, strumieniowanie dźwięku z mikrofonu, wstrzykiwane wiadomości użytkownika i typy wiadomości wywołań funkcji.

Oryginalny opis (EN)

Use when writing or reviewing C# code in this repo that builds an interactive Deepgram Voice Agent over WebSocket. Covers `ClientFactory.CreateAgentWebSocketClient()`, `SettingsSchema`, event subscriptions, microphone audio streaming, injected user messages, and function-call-related message types. Use `deepgram-dotnet-text-to-speech` for one-way synthesis and STT skills for transcription-only flows.

Jak działa

  1. Authentication
  2. Quick start
  3. Streaming microphone audio
  4. Key params and events
  5. References
  6. Gotchas
  7. Example files in this repo
Sekcje z nagłówków SKILL.md, w oryginale · 152 linii, 506 słów
Podgląd SKILL.md
---
name: deepgram-dotnet-voice-agent
description: "Use when writing or reviewing C# code in this repo that builds an interactive Deepgram Voice Agent over WebSocket. Covers `ClientFactory.CreateAgentWebSocketClient()`, `SettingsSchema`, event subscriptions, microphone audio streaming, injected user messages, and function-call-related message types. Use `deepgram-dotnet-text-to-speech` for one-way synthesis and STT skills for transcription-only flows."
---

# Using Deepgram Voice Agent (.NET SDK)

Full-duplex voice agent sessions over a single WebSocket.

**Use a different skill when:**
- One-way transcription → `deepgram-dotnet-speech-to-text` or `deepgram-dotnet-conversational-stt`.
- One-way synthesis → `deepgram-dotnet-text-to-speech`.
- Admin APIs → `deepgram-dotnet-management-api`.

## Authentication

```bash
dotnet add package Deepgram
dotnet add package Deepgram.Microphone   # only if you need local mic capture
```

```csharp
using Deepgram;

Deepgram.Library.Initialize();
// Uses DEEPGRAM_API_KEY env var; pass apiKey: "..." to override
var agentClient = ClientFactory.CreateAgentWebSocketClient();
```

## Quick start

```csharp
using Deepgram.Models.Agent.v2.WebSocket;

var agentClient = ClientFactory.CreateAgentWebSocketClient();

await agentClient.Subscribe(new EventHandler<ConversationTextResponse>((sender, e) =>
{
    Console.WriteLine(e);
}));

await agentClient.Subscribe(new EventHandler<AudioResponse>((sender, e) =>
{
    if (e.Stream != null)
    {
        // Raw linear16 PCM — see examples/agent/websocket/no_mic/Program.cs for WAV header.
        using var writer = new BinaryWriter(File.Open("output.raw", FileMode.Append));
        writer.Write(e.Stream.ToArray());
    }
}));

var settings = new SettingsSchema();
settings.Agent.Think.Provider.Type = "open_ai";
settings.Agent.Think.Provider.Model = "gpt-4o-mini";
settings.Agent.Greeting = "Hello! How can I help you today?";
settings.Agent.Listen.Provider.Type = "deepgram";
settings.Agent.Listen.Provider.Model = "nova-3";
settings.Agent.Speak.Provider.Type = "deepgram";
settings.Agent.Speak.Provider.Model = "aura-2-thalia-en";
settings.Audio.Input.Encoding = "linear16";
settings.Audio.Input.SampleRate = 24000;
settings.Audio.Output.Encoding = "linear16";
settings.Audio.Output.SampleRate = 24000;

bool connected = await agentClient.Connect(settings);
if (!connected)
{
    Console.Error.WriteLine("Agent WebSocket connection failed — check API key and network.");
    return;
}

await agentClient.SendInjectUserMessage("Say hello in one sentence.");

// Cleanup when done
Console.ReadKey();
await agentClient.Stop();
```

## Streaming microphone audio

```csharp
var microphone = new Microphone(
    push_callback: (audioData, length) =>
    {
        byte[] chunk = new byte[length];
        Array.Copy(audioData, chunk, length);
        agentClient.SendBinary(chunk);
    },
    rate: 24000,
    channels: 1,
    format: SampleFormat.Int16);

microphone.Start();

// Cleanup
Console.ReadKey();
microphone.Stop();
await agentClient.Stop();
```

## Key params and events

Settings models:
- `SettingsSchema`
- `Audio`, `Input`, `Output`
- `Agent`, `Listen`, `Think`, `Speak`
- `Provider` (dynamic extra properties supported)

Important events:
- `ConversationTextResponse`
- `AudioResponse`
- `AgentStartedSpeakingResponse`
- `AgentAudioDoneResponse`
- `AgentThinkingResponse`
- `UserStartedSpeakingResponse`
- `FunctionCallRequestResponse`
- `SettingsAppliedResponse`

Protocol events (subscribe through `ClientFactory.CreateAgentProtocolClient()`, which returns `IAgentProtocolClient`):
- `ListenUpdatedResponse`, `ThinkUpdatedResponse`
- `FunctionCallCancelledResponse`, `FunctionCallResponse`
- `LatencyReportResponse`, `AgentWarningResponse`, `AgentHistoryResponse`

Send helpers:
- `SendInjectUserMessage(string)`
- `SendInjectUserMessage(InjectUserMessageSchema)`
- `SendBinary(...)`
- `SendBinaryImmediately(...)`
- `SendKeepAlive()`
- `SendUpdateListen(...)`, `SendUpdateThink(...)`, `SendUpdateSpeak(...)`, `SendUpdatePrompt(...)`
- `SendInjectAgentMessage(...)`, `SendFunctionCallResponse(...)`
- `SendForceEndTurn()` (requires a Flux STT listen provider; flushes queued audio first)

## References

- In-repo: `Deepgram/Clients/Agent/v2/Websocket/Client.cs`, `Deepgram/Clients/Interfaces/v2/IAgentWebSocketClient.cs`, `Deepgram/Models/Agent/v2/WebSocket/*.cs`, `Deepgram.Microphone/Microphone.cs`
- AsyncAPI (WSS): https://developers.deepgram.com/asyncapi.yaml
- Product docs: https://developers.deepgram.com/docs/voice-agent, https://developers.deepgram.com/docs/voice-agent-message-flow

## Gotchas

1. **Use the actual event/model names in this repo.** `SettingsSchema`, `ConversationTextResponse`, etc. — not the Python names.
2. **`Provider` is dynamic.** Extra provider-specific properties are stored through `JsonExtensionData`; set them carefully.
3. **Function calls are typed.** `FunctionCallRequestResponse.Functions` carries typed calls. For each client-side call, send an ID-matched `AgentFunctionCallResponseSchema`; never respond after receiving `FunctionCallCancelled` for that ID. Subscribe to `FunctionCallCancelledResponse` through `IAgentProtocolClient` (`ClientFactory.CreateAgentProtocolClient()`); without that subscription the message arrives as `UnhandledResponse`.
4. **Use `SendFunctionCallResponse(...)` for current function results.** Build an `AgentFunctionCallResponseSchema` with `id`, `name`, and `content`; do not use the legacy `FunctionCallResponseSchema` wire shape for new code.
5. **Audio formats must match.** The examples align both input and output around `linear16` / `24000`.
6. **`Deepgram.Microphone` depends on PortAudio.** Local microphone examples need the helper project/package and a working PortAudio environment.

## Example files in this repo

- `examples/agent/websocket/simple/Program.cs`
- `examples/agent/websocket/no_mic/Program.cs`
- `examples/agent/websocket/arbitrary_keys/Program.cs`

Cross-language product knowledge (API reference, recipes, MCP setup): `npx skills add deepgram/skills`.

Wersje

W bazie nie ma innych skilli o nazwie deepgram-dotnet-voice-agent.

Migawka bazy z 28.10.2026 · wersja paczki 7d1ded1afe6e (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100deepgram-go-voice-agent
    Obsługuje w Go sesję Deepgram Voice Agent przez WebSocket: ustawienia w czasie działania, aktualizacje promptu i mowy, wstrzykiwane wiadomości oraz obsługę zdarzeń.
  • 100deepgram-dotnet-text-to-speech
    Obsługuje w C# syntezę mowy Deepgram Text-to-Speech: klient REST z ToStream i ToFile oraz klient WebSocket z Connect, SpeakWithText, Flush i strumieniowymi zdarzeniami AudioResponse.
  • 100deepgram-java-voice-agent
    Buduje w Javie interaktywnego agenta głosowego przez agent.deepgram.com/v1/agent/converse: AgentV1Settings, sendSettings, sendMedia, obsługę zdarzeń, konfigurację dostawców i wstrzykiwanie wiadomości.
  • 100deepgram-dotnet-speech-to-text
    Obsługuje w C# transkrypcję Deepgram Speech-to-Text nagrań i na żywo: klient REST z TranscribeUrl i TranscribeFile oraz klient WebSocket z Connect, Subscribe i Send.
  • 100deepgram-python-voice-agent
    Buduje w Pythonie interaktywnego agenta głosowego przez agent.deepgram.com/v1/agent/converse: AgentV1Settings, send_settings, send_media, zdarzenia i wywoływanie funkcji, z pełnym dupleksem STT, LLM i TTS.
  • 100deepgram-go-text-to-speech
    Syntezuje w Go dźwięk przez Speak v1 REST lub Speak WebSocket w SDK Deepgram.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.