Skip to content

Commit

Permalink
Merge pull request #324 from ElliotEserin/ws-listen-search-property
Browse files Browse the repository at this point in the history
Add Search to Listen.V1.WebSocket.Channel model
  • Loading branch information
davidvonthenen authored Aug 5, 2024
2 parents 24fb0e3 + 4689fce commit 15d6783
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Deepgram/Models/Listen/v1/WebSocket/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ public record Channel
[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>
Expand Down
45 changes: 45 additions & 0 deletions Deepgram/Models/Listen/v1/WebSocket/Hit.cs
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.v1.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));
}
}
31 changes: 31 additions & 0 deletions Deepgram/Models/Listen/v1/WebSocket/Search.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Term for which Deepgram is searching.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("query")]
public string? Query { get; set; }

/// <summary>
/// ReadonlyList of <see cref="Hit"/>
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("hits")]
public IReadOnlyList<Hit>? Hits { get; set; }

/// <summary>
/// Override ToString method to serialize the object
/// </summary>
public override string ToString()
{
return Regex.Unescape(JsonSerializer.Serialize(this, JsonSerializeOptions.DefaultOptions));
}
}

0 comments on commit 15d6783

Please sign in to comment.