-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #345 from dvonthenen/auto-flush-deadlock-plus-refa…
…ctor Fix Deadlock, Bumped Interface on WS Clients, Consolidated WS Code
Showing
106 changed files
with
7,222 additions
and
1,138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
1,564 changes: 782 additions & 782 deletions
1,564
Deepgram/Abstractions/AbstractRestClient.cs → ...ram/Abstractions/v1/AbstractRestClient.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Abstractions.v1; | ||
|
||
/// <summary> | ||
/// LocalFileWithMetadata is a class that represents a file with metadata. | ||
/// </summary> | ||
public class LocalFileWithMetadata | ||
{ | ||
/// <summary> | ||
/// Gets or sets the metadata associated with the file content. | ||
/// </summary> | ||
public Dictionary<string, string> Metadata { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the file content as a MemoryStream. | ||
/// The caller is responsible for disposing of this stream when no longer needed. | ||
/// </summary> | ||
/// <remarks> | ||
/// This property should be properly disposed of to prevent memory leaks. | ||
/// </remarks> | ||
public MemoryStream Content { get; set; } | ||
|
||
/// <summary> | ||
/// Releases the resources used by the Content stream. | ||
/// </summary> | ||
public void Dispose() | ||
{ | ||
Content?.Dispose(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Abstractions.v2; | ||
|
||
/// <summary> | ||
/// Defaults for the REST and WS AbstractClient | ||
/// </summary> | ||
public static class Constants | ||
{ | ||
// For REST | ||
public const int OneSecond = 1000; | ||
public const int OneMinute = 60 * OneSecond; | ||
public const int DefaultRESTTimeout = 30 * OneSecond; | ||
|
||
// For WS | ||
public const int BufferSize = 1024 * 16; | ||
public const int UseArrayLengthForSend = -1; | ||
|
||
public const int DefaultConnectTimeout = 5000; | ||
public const int DefaultDisconnectTimeout = 5000; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Abstractions.v2; | ||
|
||
/// <summary> | ||
/// LocalFileWithMetadata is a class that represents a file with metadata. | ||
/// </summary> | ||
public class LocalFileWithMetadata : IDisposable | ||
{ | ||
/// <summary> | ||
/// Gets or sets the metadata associated with the file content. | ||
/// </summary> | ||
public Dictionary<string, string> Metadata { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the file content as a MemoryStream. | ||
/// The caller is responsible for disposing of this stream when no longer needed. | ||
/// </summary> | ||
/// <remarks> | ||
/// This property should be properly disposed of to prevent memory leaks. | ||
/// </remarks> | ||
public MemoryStream Content { get; set; } | ||
|
||
/// <summary> | ||
/// Releases the resources used by the Content stream. | ||
/// </summary> | ||
public void Dispose() | ||
{ | ||
Content?.Dispose(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Abstractions.v2; | ||
|
||
/// <summary> | ||
/// Just a NoopSchema where you dont need to marshall JSON into a Async function. | ||
/// </summary> | ||
public class NoopSchema | ||
{ | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Abstractions.v2; | ||
|
||
/// <summary> | ||
/// Helper funcitons for HttpRequests | ||
/// </summary> | ||
internal static class HttpRequestUtil | ||
{ | ||
public const string DEFAULT_CONTENT_TYPE = "application/json"; | ||
|
||
static readonly JsonSerializerOptions _jsonSerializerOptions = new() | ||
{ | ||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, | ||
NumberHandling = JsonNumberHandling.AllowReadingFromString, | ||
}; | ||
|
||
/// <summary> | ||
/// Create the body payload of a HttpRequestMessage | ||
/// </summary> | ||
/// <typeparam name="T">Type of the body to be sent</typeparam> | ||
/// <param name="body">instance value for the body</param> | ||
/// <param name="contentType">What type of content is being sent default is : application/json</param> | ||
/// <returns></returns> | ||
internal static StringContent CreatePayload<T>(T body) | ||
{ | ||
var serialized = JsonSerializer.Serialize(body, _jsonSerializerOptions); | ||
return new(serialized, Encoding.UTF8, DEFAULT_CONTENT_TYPE); | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Create the stream payload of a HttpRequestMessage | ||
/// </summary> | ||
/// <param name="body">of type stream</param> | ||
/// <returns>HttpContent</returns> | ||
internal static HttpContent CreateStreamPayload(Stream body) | ||
{ | ||
body.Seek(0, SeekOrigin.Begin); | ||
HttpContent httpContent = new StreamContent(body); | ||
httpContent.Headers.Add("Content-Length", body.Length.ToString()); | ||
return httpContent; | ||
} | ||
|
||
|
||
/// <summary> | ||
/// method that deserializes DeepgramResponse and performs null checks on values | ||
/// </summary> | ||
/// <typeparam name="TResponse">Class Type of expected response</typeparam> | ||
/// <param name="httpResponseMessage">Http Response to be deserialized</param> | ||
/// <returns>instance of TResponse or a Exception</returns> | ||
internal static async Task<TResponse> DeserializeAsync<TResponse>(HttpResponseMessage httpResponseMessage) | ||
{ | ||
var content = await httpResponseMessage.Content.ReadAsStringAsync(); | ||
var deepgramResponse = JsonSerializer.Deserialize<TResponse>(content); | ||
return deepgramResponse; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Abstractions.v2; | ||
|
||
internal readonly struct WebSocketMessage | ||
{ | ||
public WebSocketMessage(byte[] message, WebSocketMessageType type) | ||
: this(message, type, Constants.UseArrayLengthForSend) | ||
{ | ||
} | ||
|
||
public WebSocketMessage(byte[] message, WebSocketMessageType type, int length) | ||
{ | ||
if (length != Constants.UseArrayLengthForSend && length <= message.Length && length > 0) | ||
{ | ||
Message = new ArraySegment<byte>(message, 0, length); | ||
} | ||
else | ||
{ | ||
Message = new ArraySegment<byte>(message, 0, message.Length); | ||
} | ||
MessageType = type; | ||
} | ||
|
||
public int Length => Message.Count; | ||
|
||
public ArraySegment<byte> Message { get; } | ||
|
||
public WebSocketMessageType MessageType { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Clients.Interfaces.v2; | ||
|
||
/// <summary> | ||
/// Headers of interest in the return values from the Deepgram Speak API. | ||
/// </summary> | ||
public static class Constants | ||
{ | ||
// WS buffer size | ||
public const int UseArrayLengthForSend = -1; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// 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.Models.Analyze.v1; | ||
|
||
namespace Deepgram.Clients.Interfaces.v2; | ||
|
||
/// <summary> | ||
/// Not currently being used | ||
/// </summary> | ||
public interface IAnalyzeClient | ||
{ | ||
#region NoneCallBacks | ||
/// <summary> | ||
/// Analyze a file by providing a url | ||
/// </summary> | ||
/// <param name="source">Url to the file that is to be analyzed <see cref="UrlSource"></param> | ||
/// <param name="analyzeSchema">Options for the transcription <see cref="AnalyzeSchema"/></param> | ||
/// <returns><see cref="SyncResponse"/></returns> | ||
public Task<SyncResponse> AnalyzeUrl(UrlSource source, AnalyzeSchema? analyzeSchema, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Analyze by providing text | ||
/// </summary> | ||
/// <param name="source">Text that is to be analyzed <see cref="TextSource"></param> | ||
/// <param name="analyzeSchema">Options for the transcription <see cref="AnalyzeSchema"/></param> | ||
/// <returns><see cref="SyncResponse"/></returns> | ||
public Task<SyncResponse> AnalyzeText(TextSource source, AnalyzeSchema? analyzeSchema, CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Analyzes a file using the provided byte array | ||
/// </summary> | ||
/// <param name="source">file is the form of a byte[]</param> | ||
/// <param name="analyzeSchema">Options for the transcription <see cref="AnalyzeSchema"/></param> | ||
/// <returns><see cref="SyncResponse"/></returns> | ||
public Task<SyncResponse> AnalyzeFile(byte[] source, AnalyzeSchema? analyzeSchema, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Analyzes a file using the provided stream | ||
/// </summary> | ||
/// <param name="source">file is the form of a stream <see cref="Stream"/></param> | ||
/// <param name="analyzeSchema">Options for the transcription <see cref="AnalyzeSchema"/></param> | ||
/// <returns><see cref="SyncResponse"/></returns> | ||
public Task<SyncResponse> AnalyzeFile(Stream source, AnalyzeSchema? analyzeSchema, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
#endregion | ||
|
||
#region CallBack Methods | ||
/// <summary> | ||
/// Analyzes a file using the provided byte array and providing a CallBack | ||
/// </summary> | ||
/// <param name="source">file is the form of a byte[]</param> | ||
/// <param name="callBack">CallBack url</param> | ||
/// <param name="analyzeSchema">Options for the transcription<see cref="AnalyzeSchema"></param> | ||
/// <returns><see cref="AsyncResponse"/></returns> | ||
public Task<AsyncResponse> AnalyzeFileCallBack(byte[] source, string? callBack, AnalyzeSchema? analyzeSchema, | ||
CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, | ||
Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Analyzes a file using the provided stream and providing a CallBack | ||
/// </summary> | ||
/// <param name="source">file is the form of a stream <see cref="Stream"></param> | ||
/// <param name="callBack">CallBack url</param> | ||
/// <param name="analyzeSchema">Options for the transcription<see cref="AnalyzeSchema"></param> | ||
/// <returns><see cref="AsyncResponse"/></returns> | ||
public Task<AsyncResponse> AnalyzeFileCallBack(Stream source, string? callBack, AnalyzeSchema? analyzeSchema, | ||
CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, | ||
Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Analyze a file by providing a url and a CallBack | ||
/// </summary> | ||
/// <param name="source">Url to the file that is to be analyzed <see cref="UrlSource"/></param> | ||
/// <param name="callBack">CallBack url</param> | ||
/// <param name="analyzeSchema">Options for the transcription<see cref="AnalyzeSchema"></param> | ||
/// <returns><see cref="AsyncResponse"/></returns> | ||
public Task<AsyncResponse> AnalyzeUrlCallBack(UrlSource source, string? callBack, AnalyzeSchema? analyzeSchema, | ||
CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, | ||
Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Analyze by providing text and a CallBack | ||
/// </summary> | ||
/// <param name="source">Text that is to be analyzed <see cref="TextSource"/></param> | ||
/// <param name="callBack">CallBack url</param> | ||
/// <param name="analyzeSchema">Options for the transcription<see cref="AnalyzeSchema"></param> | ||
/// <returns><see cref="AsyncResponse"/></returns> | ||
public Task<AsyncResponse> AnalyzeTextCallBack(TextSource source, string? callBack, AnalyzeSchema? analyzeSchema, CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
#endregion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// 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.Models.Listen.v1.REST; | ||
|
||
namespace Deepgram.Clients.Interfaces.v2; | ||
|
||
/// <summary> | ||
/// Not currently being used | ||
/// </summary> | ||
public interface IListenRESTClient | ||
|
||
{ | ||
#region NoneCallBacks | ||
/// <summary> | ||
/// Transcribe a file by providing a url | ||
/// </summary> | ||
/// <param name="source">Url to the file that is to be transcribed <see cref="UrlSource"></param> | ||
/// <param name="prerecordedSchema">Options for the transcription <see cref="PreRecordedSchema"/></param> | ||
/// <returns><see cref="SyncResponse"/></returns> | ||
public Task<SyncResponse> TranscribeUrl(UrlSource source, PreRecordedSchema? prerecordedSchema, | ||
CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Transcribes a file using the provided byte array | ||
/// </summary> | ||
/// <param name="source">file is the form of a byte[]</param> | ||
/// <param name="prerecordedSchema">Options for the transcription <see cref="PreRecordedSchema"/></param> | ||
/// <returns><see cref="SyncResponse"/></returns> | ||
public Task<SyncResponse> TranscribeFile(byte[] source, PreRecordedSchema? prerecordedSchema, | ||
CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Transcribes a file using the provided stream | ||
/// </summary> | ||
/// <param name="source">file is the form of a streasm <see cref="Stream"/></param> | ||
/// <param name="prerecordedSchema">Options for the transcription <see cref="PreRecordedSchema"/></param> | ||
/// <returns><see cref="SyncResponse"/></returns> | ||
public Task<SyncResponse> TranscribeFile(Stream source, PreRecordedSchema? prerecordedSchema, | ||
CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, | ||
Dictionary<string, string>? headers = null); | ||
#endregion | ||
|
||
#region CallBack Methods | ||
/// <summary> | ||
/// Transcribes a file using the provided byte array and providing a CallBack | ||
/// </summary> | ||
/// <param name="source">file is the form of a byte[]</param> | ||
/// <param name="callBack">CallBack url</param> | ||
/// <param name="prerecordedSchema">Options for the transcription<see cref="PreRecordedSchema"></param> | ||
/// <returns><see cref="AsyncResponse"/></returns> | ||
public Task<AsyncResponse> TranscribeFileCallBack(byte[] source, string? callBack, PreRecordedSchema? prerecordedSchema, | ||
CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, | ||
Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Transcribes a file using the provided stream and providing a CallBack | ||
/// </summary> | ||
/// <param name="source">file is the form of a stream <see cref="Stream"></param> | ||
/// <param name="callBack">CallBack url</param> | ||
/// <param name="prerecordedSchema">Options for the transcription<see cref="PreRecordedSchema"></param> | ||
/// <returns><see cref="AsyncResponse"/></returns> | ||
public Task<AsyncResponse> TranscribeFileCallBack(Stream source, string? callBack, PreRecordedSchema? prerecordedSchema, | ||
CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, | ||
Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Transcribe a file by providing a url and a CallBack | ||
/// </summary> | ||
/// <param name="source">Url to the file that is to be transcribed <see cref="UrlSource"/></param> | ||
/// <param name="callBack">CallBack url</param> | ||
/// <param name="prerecordedSchema">Options for the transcription<see cref="PreRecordedSchema"></param> | ||
/// <returns><see cref="AsyncResponse"/></returns> | ||
public Task<AsyncResponse> TranscribeUrlCallBack(UrlSource source, string? callBack, PreRecordedSchema? prerecordedSchema, | ||
CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, | ||
Dictionary<string, string>? headers = null); | ||
#endregion | ||
} |
137 changes: 137 additions & 0 deletions
137
Deepgram/Clients/Interfaces/v2/IListenWebSocketClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
// Copyright 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.Models.Listen.v2.WebSocket; | ||
|
||
namespace Deepgram.Clients.Interfaces.v2; | ||
|
||
/// <summary> | ||
/// Implements version 2 of the Live Client. | ||
/// </summary> | ||
public interface IListenWebSocketClient | ||
{ | ||
#region Connect and Disconnect | ||
public Task<bool> Connect(LiveSchema options, CancellationTokenSource? cancelToken = null, Dictionary<string, string>? addons = null, | ||
Dictionary<string, string>? headers = null); | ||
|
||
public Task<bool> Stop(CancellationTokenSource? cancelToken = null, bool nullByte = false); | ||
#endregion | ||
|
||
#region Subscribe Event | ||
/// <summary> | ||
/// Subscribe to an Open event from the Deepgram API | ||
/// </summary> | ||
/// <param name="eventHandler"></param> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<OpenResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to a Metadata event from the Deepgram API | ||
/// </summary> | ||
/// <param name="eventHandler"></param> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<MetadataResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to a Results event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<ResultResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to an UtteranceEnd event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<UtteranceEndResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to a SpeechStarted event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<SpeechStartedResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to a Close event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<CloseResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to an Unhandled event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<UnhandledResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to an Error event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<ErrorResponse> eventHandler); | ||
#endregion | ||
|
||
#region Send Functions | ||
/// <summary> | ||
/// Sends a KeepAlive message to Deepgram | ||
/// </summary> | ||
public Task SendKeepAlive(); | ||
|
||
/// <summary> | ||
/// Sends a Finalize message to Deepgram | ||
/// </summary> | ||
public Task SendFinalize(); | ||
|
||
/// <summary> | ||
/// Sends a Close message to Deepgram | ||
/// </summary> | ||
public Task SendClose(bool nullByte = false); | ||
|
||
/// <summary> | ||
/// Sends a binary message over the WebSocket connection. | ||
/// </summary> | ||
/// <param name="data">The data to be sent over the WebSocket.</param> | ||
public void Send(byte[] data, int length = Constants.UseArrayLengthForSend); | ||
|
||
/// <summary> | ||
/// This method sends a binary message over the WebSocket connection. | ||
/// </summary> | ||
/// <param name="data"></param> | ||
/// <param name="length">The number of bytes from the data to send. Use `Constants.UseArrayLengthForSend` to send the entire array.</param> | ||
public void SendBinary(byte[] data, int length = Constants.UseArrayLengthForSend); | ||
|
||
/// <summary> | ||
/// This method sends a text message over the WebSocket connection. | ||
/// </summary> | ||
/// <param name="data"></param> | ||
/// <param name="length">The number of bytes from the data to send. Use `Constants.UseArrayLengthForSend` to send the entire array.</param> | ||
public void SendMessage(byte[] data, int length = Constants.UseArrayLengthForSend); | ||
|
||
/// <summary> | ||
/// This method sends a binary message over the WebSocket connection immediately without queueing. | ||
/// </summary> | ||
/// <param name="data"></param> | ||
/// <param name="length">The number of bytes from the data to send. Use `Constants.UseArrayLengthForSend` to send the entire array.</param> | ||
public Task SendBinaryImmediately(byte[] data, int length = Constants.UseArrayLengthForSend); | ||
|
||
/// <summary> | ||
/// This method sends a text message over the WebSocket connection immediately without queueing. | ||
/// </summary> | ||
/// <param name="data"></param> | ||
/// <param name="length">The number of bytes from the data to send. Use `Constants.UseArrayLengthForSend` to send the entire array.</param> | ||
public Task SendMessageImmediately(byte[] data, int length = Constants.UseArrayLengthForSend); | ||
#endregion | ||
|
||
#region Helpers | ||
/// <summary> | ||
/// Retrieves the connection state of the WebSocket | ||
/// </summary> | ||
/// <returns>Returns the connection state of the WebSocket</returns> | ||
public WebSocketState State(); | ||
|
||
/// <summary> | ||
/// Indicates whether the WebSocket is connected | ||
/// </summary> | ||
/// <returns>Returns true if the WebSocket is connected</returns> | ||
public bool IsConnected(); | ||
#endregion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 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.Models.Live.v1; | ||
|
||
namespace Deepgram.Clients.Interfaces.v2; | ||
|
||
/// <summary> | ||
// *********** WARNING *********** | ||
// This is the ILiveClient interface | ||
// | ||
// Deprecated: This class is deprecated. Use the `IListenWebSocketClient` function instead. | ||
// This will be removed in a future release. | ||
// | ||
// This class is frozen and no new functionality will be added. | ||
// *********** WARNING *********** | ||
/// </summary> | ||
[Obsolete("Please use IListenWebSocketClient instead", false)] | ||
public interface ILiveClient : IListenWebSocketClient | ||
{ | ||
#region Subscribe Event | ||
/// <summary> | ||
/// Subscribe to an Open event from the Deepgram API | ||
/// </summary> | ||
/// <param name="eventHandler"></param> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<OpenResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to a Metadata event from the Deepgram API | ||
/// </summary> | ||
/// <param name="eventHandler"></param> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<MetadataResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to a Results event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<ResultResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to an UtteranceEnd event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<UtteranceEndResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to a SpeechStarted event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<SpeechStartedResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to a Close event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<CloseResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to an Unhandled event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<UnhandledResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to an Error event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<ErrorResponse> eventHandler); | ||
#endregion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,251 @@ | ||
// 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.Models.Manage.v1; | ||
|
||
namespace Deepgram.Clients.Interfaces.v2; | ||
|
||
/// <summary> | ||
/// Not currently being used | ||
/// </summary> | ||
public interface IManageClient | ||
{ | ||
#region Projects | ||
/// <summary> | ||
/// Gets projects associated to ApiKey | ||
/// </summary> | ||
/// <returns><see cref="ProjectsResponse"/></returns> | ||
public Task<ProjectsResponse> GetProjects(CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Gets project associated with project Id | ||
/// </summary> | ||
/// <param name="projectId">Id of Project</param> | ||
/// <returns><see cref="ProjectResponse"/></returns> | ||
public Task<ProjectResponse> GetProject(string projectId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Update a project associated with the projectID | ||
/// </summary> | ||
/// <param name="projectId">ID of project</param> | ||
/// <param name="updateProjectSchema"><see cref="ProjectSchema"/> for project</param> | ||
/// <returns><see cref="MessageResponse"/></returns> | ||
// USES PATCH | ||
public Task<MessageResponse> UpdateProject(string projectId, ProjectSchema updateProjectSchema, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Deletes a project, no response will be returned | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
// No response expected | ||
public Task<MessageResponse> DeleteProject(string projectId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// leave project associated with the project Id | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <returns><see cref="MessageResponse"/></returns> | ||
public Task<MessageResponse> LeaveProject(string projectId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Get all models associated with the project Id | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <returns><see cref="ModelsResponse"/></returns> | ||
public Task<ModelsResponse> GetProjectModels(string projectId, ModelSchema? modelSchema = null, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Get a specific model associated with the project Id | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="modelId">Id of model</param> | ||
/// <returns><see cref="ModelResponse"/></returns> | ||
public Task<ModelResponse> GetProjectModel(string projectId, string modelId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
#endregion | ||
|
||
#region Models | ||
/// <summary> | ||
/// Gets models available in Deepgram | ||
/// </summary> | ||
/// <returns><see cref="ModelsResponse"/></returns> | ||
public Task<ModelsResponse> GetModels(ModelSchema? modelSchema = null, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Gets a specific model within Deepgram | ||
/// </summary> | ||
/// <param name="modelId">ID of model</param> | ||
/// <returns><see cref="ModelResponse"/></returns> | ||
public Task<ModelResponse> GetModel(string modelId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
#endregion | ||
|
||
#region ProjectKeys | ||
/// <summary> | ||
/// Get the keys associated with the project | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <returns><see cref="KeysResponse"/></returns> | ||
public Task<KeysResponse> GetKeys(string projectId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Get details of key associated with the key ID | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="keyId">Id of key</param> | ||
/// <returns><see cref="KeyScopeResponse"/></returns> | ||
public Task<KeyScopeResponse> GetKey(string projectId, string keyId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Create a key in the associated project | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="keySchema"><see cref="KeySchema"/> for the key to be created</param> | ||
/// <returns><see cref="KeyResponse"/></returns> | ||
public Task<KeyResponse> CreateKey(string projectId, KeySchema keySchema, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Remove key from project, No response returned | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="keyId">Id of key</param> | ||
// Nothing being returned | ||
public Task<MessageResponse> DeleteKey(string projectId, string keyId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
#endregion | ||
|
||
#region ProjectInvites | ||
/// <summary> | ||
/// Get any invites that are associated with project | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <returns><see cref="InvitesResponse"/></returns> | ||
public Task<InvitesResponse> GetInvites(string projectId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Delete a project invite that has been sent | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="email">email of the invite to be removed</param> | ||
//no response expected | ||
public Task<MessageResponse> DeleteInvite(string projectId, string email, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Send a invite to the associated project | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="inviteSchema"><see cref="InviteSchema"/> for a invite to project</param> | ||
/// <returns><see cref="MessageResponse"/></returns> | ||
public Task<MessageResponse> SendInvite(string projectId, InviteSchema inviteSchema, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
#endregion | ||
|
||
#region Members | ||
/// <summary> | ||
/// Get the members associated with the project | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <returns><see cref="MembersResponse"/></returns> | ||
public Task<MembersResponse> GetMembers(string projectId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Get the scopes associated with member | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="memberId">Id of member</param> | ||
/// <returns><see cref="MemberScopesResponse"/></returns> | ||
public Task<MemberScopesResponse> GetMemberScopes(string projectId, string memberId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Update the scopes fot the member | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="memberId">Id of member</param> | ||
/// <param name="scopeSchema">Updates scope options for member<see cref="MemberScopeSchema"/></param> | ||
/// <returns><see cref="MessageResponse"/></returns> | ||
public Task<MessageResponse> UpdateMemberScope(string projectId, string memberId, MemberScopeSchema scopeSchema, | ||
CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, | ||
Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Remove member from project, there is no response | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="memberId">Id of member</param> | ||
//No response expected | ||
public Task<MessageResponse> RemoveMember(string projectId, string memberId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
#endregion | ||
|
||
#region Usage | ||
/// <summary> | ||
/// Get usage request associated with the project | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="UsageRequestsSchema">Project usage request options<see cref="UsageRequestsSchema"/> </param> | ||
/// <returns><see cref="UsageRequestsResponse"/></returns> | ||
public Task<UsageRequestsResponse> GetUsageRequests(string projectId, UsageRequestsSchema usageRequestsSchema, | ||
CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Get the details associated with the requestID | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="requestId">Id of request</param> | ||
/// <returns><see cref="UsageRequestResponse"/></returns> | ||
public Task<UsageRequestResponse> GetUsageRequest(string projectId, string requestId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Gets a summary of usage | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="getUsageSummarySchema">Usage summary options<see cref="UsageSummarySchema"/> </param> | ||
/// <returns><see cref="UsageSummaryResponse"/></returns> | ||
public Task<UsageSummaryResponse> GetUsageSummary(string projectId, UsageSummarySchema summarySchema, | ||
CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Get usage fields | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="fieldsSchema">Project usage request field options<see cref="UsageFieldsSchema"/></param> | ||
/// <returns><see cref="UsageFieldsResponse"/></returns> | ||
public Task<UsageFieldsResponse> GetUsageFields(string projectId, UsageFieldsSchema fieldsSchema, | ||
CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
#endregion | ||
|
||
#region Balances | ||
/// <summary> | ||
/// Gets a list of balances | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <returns><see cref="BalancesResponse"/></returns> | ||
public Task<BalancesResponse> GetBalances(string projectId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Get the balance details associated with the balance id | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="balanceId">Id of balance</param> | ||
/// <returns><see cref="BalanceResponse"/></returns> | ||
public Task<BalanceResponse> GetBalance(string projectId, string balanceId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
#endregion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Clients.Interfaces.v2; | ||
|
||
/// <summary> | ||
// *********** WARNING *********** | ||
// This class provides the IOnPremClient implementation | ||
// | ||
// Deprecated: This class is deprecated. Use ISelfHostedClient instead. | ||
// This will be removed in a future release. | ||
// | ||
// This package is frozen and no new functionality will be added. | ||
// *********** WARNING *********** | ||
/// </summary> | ||
[Obsolete("Please use ISelfHostedClient instead", false)] | ||
public interface IOnPremClient : ISelfHostedClient | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Clients.Interfaces.v2; | ||
|
||
/// <summary> | ||
// *********** WARNING *********** | ||
// This is the IPreRecordedClient interface | ||
// | ||
// Deprecated: This class is deprecated. Use the `IListenRESTClient` function instead. | ||
// This will be removed in a future release. | ||
// | ||
// This class is frozen and no new functionality will be added. | ||
// *********** WARNING *********** | ||
/// </summary> | ||
[Obsolete("Please use IListenRESTClient instead", false)] | ||
public interface IPreRecordedClient : IListenRESTClient | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// 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.Models.SelfHosted.v1; | ||
|
||
namespace Deepgram.Clients.Interfaces.v2; | ||
|
||
/// <summary> | ||
/// Not currently being used | ||
/// </summary> | ||
public interface ISelfHostedClient | ||
{ | ||
/// <summary> | ||
/// get a list of credentials associated with project | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <returns><see cref="CredentialsResponse"/></returns> | ||
public Task<CredentialsResponse> ListCredentials(string projectId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Get credentials for the project that is associated with credential ID | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="credentialsId">Id of credentials</param> | ||
/// <returns><see cref="CredentialResponse"/></returns> | ||
public Task<CredentialResponse> GetCredentials(string projectId, string credentialsId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Remove credentials in the project associated with the credentials ID | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="credentialsId">Id of credentials</param> | ||
/// <returns><see cref="MessageResponse"/></returns> | ||
public Task<MessageResponse> DeleteCredentials(string projectId, string credentialsId, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
/// <summary> | ||
/// Create credentials for the associated projects | ||
/// </summary> | ||
/// <param name="projectId">Id of project</param> | ||
/// <param name="createOnPremCredentialsSchema"><see cref="CredentialsSchema"/> for credentials to be created</param> | ||
/// <returns><see cref="CredentialResponse"/></returns> | ||
public Task<CredentialResponse> CreateCredentials(string projectId, CredentialsSchema credentialsSchema, | ||
CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Clients.Interfaces.v2; | ||
|
||
/// <summary> | ||
/// *********** WARNING *********** | ||
/// This class provides the ISpeakClient implementation for the Deepgram API | ||
/// | ||
/// Deprecated: This class is deprecated. Use the ISpeakRESTClient interface instead. | ||
/// This will be removed in a future release. | ||
/// | ||
/// This package is frozen and no new functionality will be added. | ||
/// *********** WARNING *********** | ||
/// </summary> | ||
[Obsolete("Please use ISpeakRESTClient instead", false)] | ||
public interface ISpeakClient : ISpeakRESTClient | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 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.Models.Speak.v1.REST; | ||
|
||
namespace Deepgram.Clients.Interfaces.v2; | ||
|
||
/// <summary> | ||
/// Not currently being used | ||
/// </summary> | ||
public interface ISpeakRESTClient | ||
{ | ||
#region NoneCallBacks | ||
/// <summary> | ||
/// Speaks a file using the provided stream | ||
/// </summary> | ||
/// <param name="source">file is the form of a stream <see cref="Stream"/></param> | ||
/// <param name="speakSchema">Options for the transcription <see cref="SpeakSchema"/></param> | ||
/// <returns><see cref="SyncResponse"/></returns> | ||
public Task<SyncResponse> ToStream(TextSource source, SpeakSchema? speakSchema, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
|
||
public Task<SyncResponse> ToFile(TextSource source, string filename, SpeakSchema? speakSchema, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
#endregion | ||
|
||
#region CallBack Methods | ||
/// <summary> | ||
/// Speaks a file using the provided byte array and providing a CallBack | ||
/// </summary> | ||
/// <param name="source">file is the form of a byte[]</param> | ||
/// <param name="callBack">CallBack url</param> | ||
/// <param name="speakSchema">Options for the transcription<see cref="SpeakSchema"></param> | ||
/// <returns><see cref="AsyncResponse"/></returns> | ||
public Task<AsyncResponse> StreamCallBack(TextSource source, string? callBack, SpeakSchema? speakSchema, CancellationTokenSource? cancellationToken = default, | ||
Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null); | ||
#endregion | ||
} |
159 changes: 159 additions & 0 deletions
159
Deepgram/Clients/Interfaces/v2/ISpeakWebSocketClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
// Copyright 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.Models.Speak.v2.WebSocket; | ||
|
||
namespace Deepgram.Clients.Interfaces.v2; | ||
|
||
/// <summary> | ||
/// Implements version 2 of the Live Client. | ||
/// </summary> | ||
public interface ISpeakWebSocketClient | ||
{ | ||
#region Connect and Disconnect | ||
public Task<bool> Connect(SpeakSchema options, CancellationTokenSource? cancelToken = null, Dictionary<string, string>? addons = null, | ||
Dictionary<string, string>? headers = null); | ||
|
||
public Task<bool> Stop(CancellationTokenSource? cancelToken = null, bool nullByte = false); | ||
#endregion | ||
|
||
#region Subscribe Event | ||
/// <summary> | ||
/// Subscribe to an Open event from the Deepgram API | ||
/// </summary> | ||
/// <param name="eventHandler"></param> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<OpenResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to a Metadata event from the Deepgram API | ||
/// </summary> | ||
/// <param name="eventHandler"></param> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<MetadataResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to a Flushed event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<FlushedResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to a Cleared event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<ClearedResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to a Audio buffer/event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<AudioResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to a Close event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<CloseResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to an Warning event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<WarningResponse> eventHandler); | ||
|
||
|
||
/// <summary> | ||
/// Subscribe to an Error event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<ErrorResponse> eventHandler); | ||
|
||
/// <summary> | ||
/// Subscribe to an Unhandled event from the Deepgram API | ||
/// </summary> | ||
/// <returns>True if successful</returns> | ||
public Task<bool> Subscribe(EventHandler<UnhandledResponse> eventHandler); | ||
#endregion | ||
|
||
#region Send Functions | ||
/// <summary> | ||
/// Sends text data over the WebSocket connection. | ||
/// </summary> | ||
/// <param name="data"></param> | ||
public void SpeakWithText(string data); | ||
|
||
///// <summary> | ||
///// This method Flushes the text buffer on Deepgram to be converted to audio | ||
///// </summary> | ||
public void Flush(); | ||
|
||
///// <summary> | ||
///// This method Resets the text buffer on Deepgram to be converted to audio | ||
///// </summary> | ||
public void Clear(); | ||
|
||
///// <summary> | ||
///// This method tells Deepgram to initiate the close server-side. | ||
///// </summary> | ||
public void Close(bool nullByte = false); | ||
|
||
///// <summary> | ||
///// This method sends a binary message over the WebSocket connection. | ||
///// </summary> | ||
///// <param name="data"></param> | ||
//public void SpeakWithStream(byte[] data); | ||
|
||
/// <summary> | ||
/// Sends a Close message to Deepgram | ||
/// </summary> | ||
public Task SendClose(bool nullByte = false); | ||
|
||
/// <summary> | ||
/// Sends a binary message over the WebSocket connection. | ||
/// </summary> | ||
/// <param name="data"></param> | ||
/// <param name="length">The number of bytes from the data to send. Use `Constants.UseArrayLengthForSend` to send the entire array.</param> | ||
public void Send(byte[] data, int length = Constants.UseArrayLengthForSend); | ||
|
||
///// <summary> | ||
///// This method sends a binary message over the WebSocket connection. | ||
///// </summary> | ||
///// <param name="data"></param> | ||
//public void SendBinary(byte[] data, int length = Constants.UseArrayLengthForSend); | ||
|
||
/// <summary> | ||
/// This method sends a text message over the WebSocket connection. | ||
/// </summary> | ||
/// <param name="data"></param> | ||
/// <param name="length">The number of bytes from the data to send. Use `Constants.UseArrayLengthForSend` to send the entire array.</param> | ||
public void SendMessage(byte[] data, int length = Constants.UseArrayLengthForSend); | ||
|
||
///// <summary> | ||
///// This method sends a binary message over the WebSocket connection immediately without queueing. | ||
///// </summary> | ||
//public Task SendBinaryImmediately(byte[] data, int length = Constants.UseArrayLengthForSend); | ||
|
||
/// <summary> | ||
/// This method sends a text message over the WebSocket connection immediately without queueing. | ||
/// </summary> | ||
/// <param name="data"></param> | ||
/// <param name="length">The number of bytes from the data to send. Use `Constants.UseArrayLengthForSend` to send the entire array.</param> | ||
public Task SendMessageImmediately(byte[] data, int length = Constants.UseArrayLengthForSend); | ||
#endregion | ||
|
||
#region Helpers | ||
/// <summary> | ||
/// Retrieves the connection state of the WebSocket | ||
/// </summary> | ||
/// <returns>Returns the connection state of the WebSocket</returns> | ||
public WebSocketState State(); | ||
|
||
/// <summary> | ||
/// Indicates whether the WebSocket is connected | ||
/// </summary> | ||
/// <returns>Returns true if the WebSocket is connected</returns> | ||
public bool IsConnected(); | ||
#endregion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Clients.Interfaces.v2; | ||
|
||
public class ResponseEvent<T> | ||
{ | ||
public T? Response { get; } | ||
|
||
public ResponseEvent(T? response) | ||
{ | ||
Response = response; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Clients.Listen.v2.WebSocket; | ||
|
||
/// <summary> | ||
/// Headers of interest in the return values from the Deepgram Speak API. | ||
/// </summary> | ||
public static class Constants | ||
{ | ||
// Default flush period | ||
public const int DefaultFlushPeriodInMs = 500; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Clients.Listen.v2.WebSocket; | ||
|
||
public class ResponseEvent<T>(T? response) : EventArgs | ||
{ | ||
public T? Response { get; set; } = response; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Clients.Listen.v2.WebSocket; | ||
|
||
public static class UriSegments | ||
{ | ||
//using constants instead of inline value(magic strings) make consistence | ||
//across SDK And Test Projects Simpler and Easier to change | ||
public const string LISTEN = "listen"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Clients.Speak.v2.WebSocket; | ||
|
||
/// <summary> | ||
/// Headers of interest in the return values from the Deepgram Speak API. | ||
/// </summary> | ||
public static class Constants | ||
{ | ||
// WS buffer size | ||
public const int BufferSize = 1024 * 16; | ||
public const int UseArrayLengthForSend = -1; | ||
|
||
// Default timeout for connect/disconnect | ||
public const int DefaultConnectTimeout = 5000; | ||
public const int DefaultDisconnectTimeout = 5000; | ||
|
||
public const int DefaultFlushPeriodInMs = 500; | ||
|
||
// user message types | ||
public const string Speak = "Speak"; | ||
public const string Flush = "Flush"; | ||
public const string Clear = "Clear"; | ||
public const string Close = "Close"; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Clients.Speak.v2.WebSocket; | ||
|
||
public class ResponseEvent<T> : EventArgs | ||
{ | ||
public T? Response { get; } | ||
|
||
public ResponseEvent(T? response) | ||
{ | ||
Response = response; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Clients.Speak.v2.WebSocket; | ||
|
||
public static class UriSegments | ||
{ | ||
//using constants instead of inline value(magic strings) make consistence | ||
//across SDK And Test Projects Simpler and Easier to change | ||
public const string SPEAK = "speak"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Models.Common.v2.WebSocket; | ||
|
||
public record CloseResponse | ||
{ | ||
/// <summary> | ||
/// Close event type. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("type")] | ||
[JsonConverter(typeof(JsonStringEnumConverter))] | ||
public WebSocketType? Type { get; set; } = WebSocketType.Close; | ||
|
||
/// <summary> | ||
/// Copy method to copy the object | ||
/// </summary> | ||
public void Copy(CloseResponse other) | ||
{ | ||
if (other is null) | ||
{ | ||
return; | ||
} | ||
|
||
Type = other.Type; | ||
} | ||
|
||
/// <summary> | ||
/// Override ToString method to serialize the object | ||
/// </summary> | ||
public override string ToString() | ||
{ | ||
return Regex.Unescape(JsonSerializer.Serialize(this, JsonSerializeOptions.DefaultOptions)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Models.Common.v2.WebSocket; | ||
|
||
public record ErrorResponse | ||
{ | ||
/// <summary> | ||
/// Error Description | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("description")] | ||
public string? Description { get; set; } = ""; | ||
|
||
/// <summary> | ||
/// Error Message | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("message")] | ||
public string? Message { get; set; } = ""; | ||
|
||
/// <summary> | ||
/// Error Variant | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("variant")] | ||
public string? Variant { get; set; } = ""; | ||
|
||
/// <summary> | ||
/// Error event type. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("type")] | ||
[JsonConverter(typeof(JsonStringEnumConverter))] | ||
public WebSocketType? Type { get; set; } = WebSocketType.Error; | ||
|
||
/// <summary> | ||
/// Copy method to copy the object | ||
/// </summary> | ||
public void Copy(ErrorResponse other) | ||
{ | ||
if (other is null) | ||
{ | ||
return; | ||
} | ||
|
||
Description = other.Description; | ||
Message = other.Message; | ||
Variant = other.Variant; | ||
Type = other.Type; | ||
} | ||
|
||
/// <summary> | ||
/// Override ToString method to serialize the object | ||
/// </summary> | ||
public override string ToString() | ||
{ | ||
return Regex.Unescape(JsonSerializer.Serialize(this, JsonSerializeOptions.DefaultOptions)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Models.Common.v2.WebSocket; | ||
|
||
public record OpenResponse | ||
{ | ||
/// <summary> | ||
/// Open event type. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("type")] | ||
[JsonConverter(typeof(JsonStringEnumConverter))] | ||
public WebSocketType? Type { get; set; } = WebSocketType.Open; | ||
|
||
/// <summary> | ||
/// Copy method to copy the object | ||
/// </summary> | ||
public void Copy(OpenResponse other) | ||
{ | ||
if (other is null) | ||
{ | ||
return; | ||
} | ||
|
||
Type = other.Type; | ||
} | ||
|
||
/// <summary> | ||
/// Override ToString method to serialize the object | ||
/// </summary> | ||
public override string ToString() | ||
{ | ||
return Regex.Unescape(JsonSerializer.Serialize(this, JsonSerializeOptions.DefaultOptions)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Models.Common.v2.WebSocket; | ||
|
||
public record UnhandledResponse | ||
{ | ||
/// <summary> | ||
/// Raw JSON | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("raw")] | ||
public string? Raw { get; set; } = ""; | ||
|
||
/// <summary> | ||
/// Unhandled event type. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("type")] | ||
[JsonConverter(typeof(JsonStringEnumConverter))] | ||
public WebSocketType? Type { get; set; } = WebSocketType.Unhandled; | ||
|
||
/// <summary> | ||
/// Copy method to copy the object | ||
/// </summary> | ||
public void Copy(UnhandledResponse other) | ||
{ | ||
if (other == null) | ||
{ | ||
return; | ||
} | ||
|
||
Raw = other.Raw; | ||
Type = other.Type; | ||
} | ||
|
||
/// <summary> | ||
/// Override ToString method to serialize the object | ||
/// </summary> | ||
public override string ToString() | ||
{ | ||
return Regex.Unescape(JsonSerializer.Serialize(this, JsonSerializeOptions.DefaultOptions)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Models.Common.v2.WebSocket; | ||
|
||
public enum WebSocketType | ||
{ | ||
Open, | ||
Close, | ||
Unhandled, | ||
Error, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Models.Listen.v2.WebSocket; | ||
|
||
public record Alternative | ||
{ | ||
/// <summary> | ||
/// Single-string transcript containing what the model hears in this channel of audio. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("transcript")] | ||
public string? Transcript { get; set; } | ||
/// <summary> | ||
/// Value between 0 and 1 indicating the model's relative confidence in this transcript. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("confidence")] | ||
public double? Confidence { get; set; } | ||
|
||
/// <summary> | ||
/// ReadOnly List of <see cref="Word"/> objects. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("words")] | ||
public IReadOnlyList<Word>? Words { get; set; } | ||
|
||
/// <summary> | ||
/// ReadOnlyList of Languages Detected | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("languages")] | ||
public IReadOnlyList<string>? Languages { get; set; } | ||
|
||
/// <summary> | ||
/// Override ToString method to serialize the object | ||
/// </summary> | ||
public override string ToString() | ||
{ | ||
return Regex.Unescape(JsonSerializer.Serialize(this, JsonSerializeOptions.DefaultOptions)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Models.Listen.v2.WebSocket; | ||
|
||
public record Average | ||
{ | ||
/// <summary> | ||
/// Sentiment: Positive, Negative, or Neutral. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("sentiment")] | ||
public string? Sentiment { get; set; } | ||
|
||
/// <summary> | ||
/// Sentiment score. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("sentiment_score")] | ||
public double? SentimentScore { get; set; } | ||
|
||
/// <summary> | ||
/// Override ToString method to serialize the object | ||
/// </summary> | ||
public override string ToString() | ||
{ | ||
return Regex.Unescape(JsonSerializer.Serialize(this, JsonSerializeOptions.DefaultOptions)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Models.Listen.v2.WebSocket; | ||
|
||
public record Channel | ||
{ | ||
/// <summary> | ||
/// ReadOnlyList of <see cref="Alternative"/> objects. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("alternatives")] | ||
public IReadOnlyList<Alternative>? Alternatives { get; set; } | ||
|
||
/// <summary> | ||
/// ReadOnlyList of Search objects. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("search")] | ||
public IReadOnlyList<Search>? Search { get; set; } | ||
|
||
/// <summary> | ||
/// Override ToString method to serialize the object | ||
/// </summary> | ||
public override string ToString() | ||
{ | ||
return Regex.Unescape(JsonSerializer.Serialize(this, JsonSerializeOptions.DefaultOptions)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Models.Listen.v2.WebSocket; | ||
|
||
using Common = Deepgram.Models.Common.v2.WebSocket; | ||
|
||
public record CloseResponse : Common.CloseResponse | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Models.Listen.v2.WebSocket; | ||
|
||
using Common = Deepgram.Models.Common.v2.WebSocket; | ||
|
||
public record ErrorResponse : Common.ErrorResponse | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Models.Listen.v2.WebSocket; | ||
|
||
public record Hit | ||
{ | ||
/// <summary> | ||
/// Value between 0 and 1 that indicates the model's relative confidence in this hit. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("confidence")] | ||
public double? Confidence { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Offset in seconds from the start of the audio to where the hit ends. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("end")] | ||
public decimal? End { get; set; } | ||
|
||
/// <summary> | ||
/// Transcript that corresponds to the time between start and end. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("snippet")] | ||
public string? Snippet { get; set; } | ||
|
||
/// <summary> | ||
/// Offset in seconds from the start of the audio to where the hit occurs. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("start")] | ||
public decimal? Start { get; set; } | ||
|
||
/// <summary> | ||
/// Override ToString method to serialize the object | ||
/// </summary> | ||
public override string ToString() | ||
{ | ||
return Regex.Unescape(JsonSerializer.Serialize(this, JsonSerializeOptions.DefaultOptions)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Models.Listen.v2.WebSocket; | ||
|
||
using Deepgram.Models.Common.v2.WebSocket; | ||
|
||
public enum ListenType | ||
{ | ||
Open = WebSocketType.Open, | ||
Close = WebSocketType.Close, | ||
Unhandled = WebSocketType.Unhandled, | ||
Error = WebSocketType.Error, | ||
Metadata, | ||
Results, | ||
UtteranceEnd, | ||
SpeechStarted, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,262 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Models.Listen.v2.WebSocket; | ||
|
||
public class LiveSchema | ||
{ | ||
|
||
/// <summary> | ||
/// Number of transcripts to return per request | ||
/// <see href="https://developers.deepgram.com/reference/pre-recorded"/> | ||
/// Default is 1 | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("alternatives")] | ||
public int? Alternatives { get; set; } | ||
|
||
/// <summary> | ||
/// CallBack allows you to have your submitted audio processed asynchronously. | ||
/// <see href="https://developers.deepgram.com/docs/callback"> | ||
/// default is null | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("callback")] | ||
public string? CallBack { get; set; } | ||
|
||
/// <summary> | ||
/// Enables callback method | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("callback_method")] | ||
public bool? CallbackMethod { get; set; } | ||
|
||
/// <summary> | ||
/// Channels allows you to specify the number of independent audio channels your submitted audio contains. | ||
/// Used when the Encoding feature is also being used to submit streaming raw audio | ||
/// <see href="https://developers.deepgram.com/docs/channels"> | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("channels")] | ||
public int? Channels { get; set; } | ||
|
||
/// <summary> | ||
/// Diarize recognizes speaker changes and assigns a speaker to each word in the transcript. | ||
/// <see href="https://developers.deepgram.com/docs/diarization"> | ||
/// default is false | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("diarize")] | ||
public bool? Diarize { get; set; } | ||
|
||
// <summary> | ||
/// <see href="https://developers.deepgram.com/docs/diarization"> | ||
/// default is null, only applies if Diarize is set to true | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("diarize_version")] | ||
public string? DiarizeVersion { get; set; } | ||
|
||
/// <summary> | ||
/// Dictation is a feature of Deepgram’s Speech-to-Text API that converts spoken dictation commands into their corresponding punctuation marks. | ||
/// <see href="https://developers.deepgram.com/docs/dictation"> | ||
/// default is false | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("dictation")] | ||
public bool? Dictation { get; set; } | ||
|
||
/// <summary> | ||
/// Encoding allows you to specify the expected encoding of your submitted audio. | ||
/// <see href="https://developers.deepgram.com/docs/encoding"> | ||
/// supported encodings <see cref="AudioEncoding"/> | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("encoding")] | ||
public string? Encoding { get; set; } | ||
|
||
/// <summary> | ||
/// Endpointing returns transcripts when pauses in speech are detected. | ||
/// <see href="https://developers.deepgram.com/docs/endpointing"> | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("endpointing")] | ||
public string? EndPointing { get; set; } | ||
|
||
/// <summary> | ||
/// Deepgram’s Extra Metadata feature allows you to attach arbitrary key-value pairs to your API requests that are attached to the API response for usage in downstream processing. | ||
/// Extra metadata is limited to 2048 characters per key-value pair. | ||
/// <see href="https://developers.deepgram.com/docs/extra-metadata"/> | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("extra")] | ||
public Dictionary<string, string>? Extra { get; set; } | ||
|
||
/// <summary> | ||
/// Whether to include words like "uh" and "um" in transcription output. | ||
///<see href="https://developers.deepgram.com/reference/pre-recorded"/> | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("filler_words")] | ||
public bool? FillerWords { get; set; } | ||
|
||
/// <summary> | ||
/// Interim Results provides preliminary results for streaming audio to solve the need for immediate results combined with high levels of accuracy. | ||
/// <see href="https://developers.deepgram.com/docs/interim-results"> | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("interim_results")] | ||
public bool? InterimResults { get; set; } | ||
|
||
/// <summary> | ||
/// Keywords can boost or suppress specialized terminology. | ||
/// <see href="https://developers.deepgram.com/docs/keywords"> | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("keywords")] | ||
public List<string>? Keywords { get; set; } | ||
|
||
/// <summary> | ||
/// Primary spoken language of submitted audio | ||
/// <see href="https://developers.deepgram.com/docs/language"> | ||
/// default value is 'en' | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("language")] | ||
public string? Language { get; set; } | ||
|
||
/// <summary> | ||
/// AI model used to process submitted audio | ||
/// <see href="https://developers.deepgram.com/docs/model"> | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("model")] | ||
public string? Model { get; set; } | ||
|
||
/// <summary> | ||
/// Multichannel transcribes each channel in submitted audio independently. | ||
/// <see href="https://developers.deepgram.com/docs/multichannel"> | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("multichannel")] | ||
public bool? MultiChannel { get; set; } | ||
|
||
/// <summary> | ||
/// Enables No Delay | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("no_delay")] | ||
public bool? NoDelay { get; set; } | ||
|
||
/// <summary> | ||
/// Numerals converts numbers from written format to numerical format. | ||
/// <see href="https://developers.deepgram.com/docs/numerals"> | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("numerals")] | ||
public bool? Numerals { get; set; } | ||
|
||
/// <summary> | ||
/// Profanity Filter looks for recognized profanity and converts it to the nearest recognized | ||
/// non-profane word or removes it from the transcript completely. | ||
/// <see href="https://developers.deepgram.com/docs/profanity-filter"> | ||
/// for use with base model tier only | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("profanity_filter")] | ||
public bool? ProfanityFilter { get; set; } | ||
|
||
/// <summary> | ||
/// Adds punctuation and capitalization to transcript | ||
/// <see href="https://developers.deepgram.com/docs/punctuation"> | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("punctuate")] | ||
public bool? Punctuate { get; set; } | ||
|
||
/// <summary> | ||
/// Indicates whether to redact sensitive information, replacing redacted content with asterisks (*). Can send multiple instances in query string (for example, redact=pci&redact=numbers). | ||
/// <see href="https://developers.deepgram.com/docs/redaction"> | ||
/// default is List<string>("false") | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("redact")] | ||
public List<string>? Redact { get; set; } | ||
|
||
/// <summary> | ||
/// Find and Replace searches for terms or phrases in submitted audio and replaces them. | ||
/// <see href="https://developers.deepgram.com/docs/find-and-replace"> | ||
/// default is null | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("replace")] | ||
public List<string>? Replace { get; set; } | ||
|
||
/// <summary> | ||
/// Sample Rate allows you to specify the sample rate of your submitted audio. | ||
/// <see href="https://developers.deepgram.com/docs/sample-rate"> | ||
/// only applies when Encoding has a value | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("sample_rate")] | ||
public int? SampleRate { get; set; } | ||
|
||
/// <summary> | ||
/// Search searches for terms or phrases in submitted audio. | ||
/// <see href="https://developers.deepgram.com/docs/search"> | ||
/// default is null | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("search")] | ||
public List<string>? Search { get; set; } | ||
|
||
/// <summary> | ||
/// Smart Format formats transcripts to improve readability. | ||
/// <see href="https://developers.deepgram.com/docs/smart-format"> | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("smart_format")] | ||
public bool? SmartFormat { get; set; } | ||
|
||
/// <summary> | ||
/// Tagging allows you to label your requests with one or more tags in a list,for the purpose of identification during usage reporting. | ||
/// <see href="https://developers.deepgram.com/docs/tagging"> | ||
/// Default is a null | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("tag")] | ||
public List<string>? Tag { get; set; } | ||
|
||
/// <summary> | ||
/// Indicates how long Deepgram will wait to send a {"type": "UtteranceEnd"} message after a word has been transcribed | ||
/// <see href="https://developers.deepgram.com/docs/understanding-end-of-speech-detection-while-streaming"/> | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("utterance_end_ms")] | ||
public string? UtteranceEnd { get; set; } | ||
|
||
/// <summary> | ||
/// Enables voice activity detection (VAD) events | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("vad_events")] | ||
public bool? VadEvents { get; set; } | ||
|
||
/// <summary> | ||
/// Version of the model to use. | ||
/// <see href="https://developers.deepgram.com/docs/version"> | ||
/// default value is "latest" | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("version")] | ||
public string? Version { get; set; } | ||
|
||
/// <summary> | ||
/// Override ToString method to serialize the object | ||
/// </summary> | ||
public override string ToString() | ||
{ | ||
return Regex.Unescape(JsonSerializer.Serialize(this, JsonSerializeOptions.DefaultOptions)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Models.Listen.v2.WebSocket; | ||
|
||
public record MetaData | ||
{ | ||
/// <summary> | ||
/// The request ID is a unique identifier for the request. It is useful for troubleshooting and support. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("request_id")] | ||
public string? RequestId { get; set; } | ||
|
||
/// <summary> | ||
/// Model UUID | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("model_uuid")] | ||
public string? ModelUUID { get; set; } | ||
|
||
/// <summary> | ||
/// IReadonlyDictionary of <see cref="ModelInfo"/> | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("model_info")] | ||
public ModelInfo? ModelInfo { get; set; } | ||
|
||
/// <summary> | ||
/// Deepgram’s Extra Metadata feature allows you to attach arbitrary key-value pairs to your API requests that are attached to the API response for usage in downstream processing. | ||
/// Extra metadata is limited to 2048 characters per key-value pair. | ||
/// <see href="https://developers.deepgram.com/docs/extra-metadata"/> | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("extra")] | ||
public Dictionary<string, string>? Extra { get; set; } | ||
|
||
/// <summary> | ||
/// Override ToString method to serialize the object | ||
/// </summary> | ||
public override string ToString() | ||
{ | ||
return Regex.Unescape(JsonSerializer.Serialize(this, JsonSerializeOptions.DefaultOptions)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Models.Listen.v2.WebSocket; | ||
|
||
public record MetadataResponse | ||
{ | ||
/// <summary> | ||
/// Channel count | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("channels")] | ||
public int? Channels { get; set; } | ||
|
||
/// <summary> | ||
/// Created date/time | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("created")] | ||
public DateTime? Created { get; set; } | ||
|
||
/// <summary> | ||
/// Duration of the audio | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("duration")] | ||
public double? Duration { get; set; } | ||
|
||
/// <summary> | ||
/// Model Information | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("model_info")] | ||
public IReadOnlyDictionary<string, ModelInfo>? ModelInfo { get; set; } | ||
|
||
/// <summary> | ||
/// Models used containing UUIDs | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("models")] | ||
public IReadOnlyList<string>? Models { get; set; } | ||
|
||
/// <summary> | ||
/// Request ID is a unique identifier for the request. It is useful for troubleshooting and support. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("request_id")] | ||
public string? RequestId { get; set; } | ||
|
||
/// <summary> | ||
/// Sha256 information | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("sha256")] | ||
public string? Sha256 { get; set; } | ||
|
||
/// <summary> | ||
/// (Obsolete?) his field is only present if the request was made with a transaction key. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("transaction_key")] | ||
public string? TransactionKey { get; set; } | ||
|
||
/// <summary> | ||
/// Metadata event type. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("type")] | ||
[JsonConverter(typeof(JsonStringEnumConverter))] | ||
public ListenType? Type { get; set; } = ListenType.Metadata; | ||
|
||
/// <summary> | ||
/// Deepgram’s Extra Metadata feature allows you to attach arbitrary key-value pairs to your API requests that are attached to the API response for usage in downstream processing. | ||
/// Extra metadata is limited to 2048 characters per key-value pair. | ||
/// <see href="https://developers.deepgram.com/docs/extra-metadata"/> | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("extra")] | ||
public Dictionary<string, string>? Extra { get; set; } | ||
|
||
/// <summary> | ||
/// Override ToString method to serialize the object | ||
/// </summary> | ||
public override string ToString() | ||
{ | ||
return Regex.Unescape(JsonSerializer.Serialize(this, JsonSerializeOptions.DefaultOptions)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// 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 | ||
|
||
namespace Deepgram.Models.Listen.v2.WebSocket; | ||
|
||
public record ModelInfo | ||
{ | ||
/// <summary> | ||
/// Architecture of the model | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("arch")] | ||
public string? Arch { get; set; } | ||
|
||
/// <summary> | ||
/// Name of the model | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("name")] | ||
public string? Name { get; set; } | ||
|
||
/// <summary> | ||
/// Version of the model | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonPropertyName("version")] | ||
public string? Version { get; set; } | ||
|
||
/// <summary> | ||
/// Override ToString method to serialize the object | ||
/// </summary> | ||
public override string ToString() | ||
{ | ||
return Regex.Unescape(JsonSerializer.Serialize(this, JsonSerializeOptions.DefaultOptions)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 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 | ||
|
||
namespace Deepgram.Models.Listen.v2.WebSocket; | ||
|
||
using Common = Deepgram.Models.Common.v2.WebSocket; | ||
|
||
public record OpenResponse : Common.OpenResponse | ||
{ | ||
} |
Oops, something went wrong.