From 4689fcea9f989fac803b05a0e74d43eeff837a1a Mon Sep 17 00:00:00 2001 From: ellioteserin Date: Mon, 5 Aug 2024 17:59:46 +0100 Subject: [PATCH] Add Search to Listen.V1.WebSocket.Channel model --- .../Models/Listen/v1/WebSocket/Channel.cs | 7 +++ Deepgram/Models/Listen/v1/WebSocket/Hit.cs | 45 +++++++++++++++++++ Deepgram/Models/Listen/v1/WebSocket/Search.cs | 31 +++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 Deepgram/Models/Listen/v1/WebSocket/Hit.cs create mode 100644 Deepgram/Models/Listen/v1/WebSocket/Search.cs diff --git a/Deepgram/Models/Listen/v1/WebSocket/Channel.cs b/Deepgram/Models/Listen/v1/WebSocket/Channel.cs index 8572b7c0..01744c1d 100644 --- a/Deepgram/Models/Listen/v1/WebSocket/Channel.cs +++ b/Deepgram/Models/Listen/v1/WebSocket/Channel.cs @@ -13,6 +13,13 @@ public record Channel [JsonPropertyName("alternatives")] public IReadOnlyList? Alternatives { get; set; } + /// + /// ReadOnlyList of Search objects. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("search")] + public IReadOnlyList? Search { get; set; } + /// /// Override ToString method to serialize the object /// diff --git a/Deepgram/Models/Listen/v1/WebSocket/Hit.cs b/Deepgram/Models/Listen/v1/WebSocket/Hit.cs new file mode 100644 index 00000000..bb5b3679 --- /dev/null +++ b/Deepgram/Models/Listen/v1/WebSocket/Hit.cs @@ -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.v1.WebSocket; + +public record Hit +{ + /// + /// Value between 0 and 1 that indicates the model's relative confidence in this hit. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("confidence")] + public double? Confidence { get; set; } + + + /// + /// Offset in seconds from the start of the audio to where the hit ends. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("end")] + public decimal? End { get; set; } + + /// + /// Transcript that corresponds to the time between start and end. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("snippet")] + public string? Snippet { get; set; } + + /// + /// Offset in seconds from the start of the audio to where the hit occurs. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("start")] + public decimal? Start { get; set; } + + /// + /// Override ToString method to serialize the object + /// + public override string ToString() + { + return Regex.Unescape(JsonSerializer.Serialize(this, JsonSerializeOptions.DefaultOptions)); + } +} diff --git a/Deepgram/Models/Listen/v1/WebSocket/Search.cs b/Deepgram/Models/Listen/v1/WebSocket/Search.cs new file mode 100644 index 00000000..f880119f --- /dev/null +++ b/Deepgram/Models/Listen/v1/WebSocket/Search.cs @@ -0,0 +1,31 @@ +// 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.v1.WebSocket; + +public record Search +{ + /// + /// Term for which Deepgram is searching. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("query")] + public string? Query { get; set; } + + /// + /// ReadonlyList of + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("hits")] + public IReadOnlyList? Hits { get; set; } + + /// + /// Override ToString method to serialize the object + /// + public override string ToString() + { + return Regex.Unescape(JsonSerializer.Serialize(this, JsonSerializeOptions.DefaultOptions)); + } +} +