Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support voice agent api #360

Merged
merged 5 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,6 @@ web.config
app.config
settings.json
project.lock.json

# Log
log.txt
16 changes: 16 additions & 0 deletions Deepgram.Dev.sln
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Streaming", "tests\edge_cas
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speak", "tests\edge_cases\tts_v1_client_example\Speak.csproj", "{AB053DDA-2487-476C-9793-A50C37F10CCA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "agent", "agent", "{B7C828E2-1CDB-4F78-9AB7-CA2180795DF4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "websocket", "websocket", "{B254E451-B210-4A01-8854-DA03AC2A1065}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "simple", "simple", "{FB6A2238-DD9A-4A47-B723-C173F2D2E31C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Agent", "examples\agent\websocket\simple\Agent.csproj", "{332347AC-E1D8-4B5D-A26F-50975AEF1F4F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -327,6 +335,10 @@ Global
{AB053DDA-2487-476C-9793-A50C37F10CCA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB053DDA-2487-476C-9793-A50C37F10CCA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB053DDA-2487-476C-9793-A50C37F10CCA}.Release|Any CPU.Build.0 = Release|Any CPU
{332347AC-E1D8-4B5D-A26F-50975AEF1F4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{332347AC-E1D8-4B5D-A26F-50975AEF1F4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{332347AC-E1D8-4B5D-A26F-50975AEF1F4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{332347AC-E1D8-4B5D-A26F-50975AEF1F4F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -412,6 +424,10 @@ Global
{5CEEB2F0-F284-4BB3-8999-6E91151C0C06} = {1280E66D-A375-422A-ACB4-48F17E9C190E}
{964A87B4-31F8-4D68-AE64-64E66C9959FD} = {0BF29CA2-1CD6-4FF0-BC7B-B33C6B41E9A1}
{AB053DDA-2487-476C-9793-A50C37F10CCA} = {5CEEB2F0-F284-4BB3-8999-6E91151C0C06}
{B7C828E2-1CDB-4F78-9AB7-CA2180795DF4} = {C673DFD1-528A-4BAE-94E6-02EF058AC363}
{B254E451-B210-4A01-8854-DA03AC2A1065} = {B7C828E2-1CDB-4F78-9AB7-CA2180795DF4}
{FB6A2238-DD9A-4A47-B723-C173F2D2E31C} = {B254E451-B210-4A01-8854-DA03AC2A1065}
{332347AC-E1D8-4B5D-A26F-50975AEF1F4F} = {FB6A2238-DD9A-4A47-B723-C173F2D2E31C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8D4ABC6D-7126-4EE2-9303-43A954616B2A}
Expand Down
18 changes: 18 additions & 0 deletions Deepgram/AgentWebSocketClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2021-2024 Deepgram .NET SDK contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

using Deepgram.Clients.Agent.v2.WebSocket;
using Deepgram.Models.Authenticate.v1;

namespace Deepgram;

/// <summary>
/// Implements the latest supported version of the Agent Client.
/// </summary>
public class AgentWebSocketClient : Client
{
public AgentWebSocketClient(string apiKey = "", DeepgramWsClientOptions? deepgramClientOptions = null) : base(apiKey, deepgramClientOptions)
{
}
}
20 changes: 20 additions & 0 deletions Deepgram/ClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@

public static class ClientFactory
{
/// <summary>
/// Create a new AgentWebSocketClient using the latest version
/// </summary>
/// <param name="apiKey"></param>
/// <param name="options"></param>
/// <returns></returns>
public static V2.IAgentWebSocketClient CreateAgentWebSocketClient(string apiKey = "", DeepgramWsClientOptions? options = null)
{
return new AgentWebSocketClient(apiKey, options);
}

/// <summary>
/// Create a new AnalyzeClient
/// </summary>
Expand Down Expand Up @@ -108,6 +119,15 @@
/// and the latest version will be renamed to v1.
///

/// <summary>
/// This method allows you to create an AgentClient with a specific version of the client.
/// TODO: this should be revisited at a later time. Opportunity to use reflection to get the type of the client
/// </summary>
public static object CreateAgentWebSocketClient(int version, string apiKey = "", DeepgramWsClientOptions? options = null)
{
return new AgentWebSocketClient(apiKey, options);
}

/// <summary>
/// This method allows you to create an AnalyzeClient with a specific version of the client.
/// TODO: this should be revisited at a later time. Opportunity to use reflection to get the type of the client
Expand Down Expand Up @@ -140,7 +160,7 @@
case 1:
Log.Information("ClientFactory", $"Version 1 of the ListenWebSocketClient is being deprecated in the next major version.");
Log.Information("ClientFactory", $"Transition to the latest version at your earliest convenience.");
return new ListenV1.Client(apiKey, options);

Check warning on line 163 in Deepgram/ClientFactory.cs

View workflow job for this annotation

GitHub Actions / test (8.0.x)

'Client' is obsolete: 'Please use Deepgram.Clients.Listen.v2.WebSocket instead'

Check warning on line 163 in Deepgram/ClientFactory.cs

View workflow job for this annotation

GitHub Actions / build

'Client' is obsolete: 'Please use Deepgram.Clients.Listen.v2.WebSocket instead'
case 2:
return new ListenV2.Client(apiKey, options);
default:
Expand Down Expand Up @@ -190,7 +210,7 @@
case 1:
Log.Information("ClientFactory", $"Version 1 of the ListenWebSocketClient is being deprecated in the next major version.");
Log.Information("ClientFactory", $"Transition to the latest version at your earliest convenience.");
return new SpeakV1.Client(apiKey, options);

Check warning on line 213 in Deepgram/ClientFactory.cs

View workflow job for this annotation

GitHub Actions / test (8.0.x)

'Client' is obsolete: 'Please use Deepgram.Clients.Speak.v2.WebSocket instead'

Check warning on line 213 in Deepgram/ClientFactory.cs

View workflow job for this annotation

GitHub Actions / build

'Client' is obsolete: 'Please use Deepgram.Clients.Speak.v2.WebSocket instead'
case 2:
return new SpeakV2.Client(apiKey, options);
default:
Expand Down
Loading
Loading