Skip to content

Commit 4c9ac9e

Browse files
authored
Merge pull request #412 from deepgram/feat/diarize-model-v2
feat: add diarize_model option to pre-recorded transcription
2 parents 835644e + 326eced commit 4c9ac9e

4 files changed

Lines changed: 45 additions & 1 deletion

File tree

.agents/skills/deepgram-dotnet-audio-intelligence/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ await liveClient.Connect(new LiveSchema()
9696

9797
## Key params
9898

99-
REST (`PreRecordedSchema`): `Summarize`, `Topics`, `Intents`, `Sentiment`, `DetectLanguage`, `DetectEntities`, `CustomTopic`, `CustomTopicMode`, `CustomIntent`, `CustomIntentMode`, `Diarize`, `DiarizeVersion`, `Redact`, `Utterances`, plus the regular STT knobs.
99+
REST (`PreRecordedSchema`): `Summarize`, `Topics`, `Intents`, `Sentiment`, `DetectLanguage`, `DetectEntities`, `CustomTopic`, `CustomTopicMode`, `CustomIntent`, `CustomIntentMode`, `Diarize`, `DiarizeVersion`, `DiarizeModel`, `Redact`, `Utterances`, plus the regular STT knobs.
100100

101101
Live (`LiveSchema`): `Diarize`, `Redact`, `UtteranceEnd`, `VadEvents`, `Punctuate`, `SmartFormat`, plus normal streaming STT settings.
102102

Deepgram.Tests/UnitTests/UtilitiesTests/QueryParameterUtilTests.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,36 @@ public void GetParameters_Should_Return_Empty_String_When_Parameter_Has_No_Value
182182
result.Should().Be($"https://{Defaults.DEFAULT_URI}");
183183
}
184184

185+
// DiarizeModel surfaces Batch Diarization v2; the API spec enum is latest, v1, v2.
186+
[TestCase("v2")]
187+
[TestCase("v1")]
188+
[TestCase("latest")]
189+
public void GetParameters_Should_Return_String_When_Passing_DiarizeModel_Parameter(string diarizeModel)
190+
{
191+
// Input and Output
192+
var obj = new Deepgram.Models.Listen.v1.REST.PreRecordedSchema() { DiarizeModel = diarizeModel };
193+
var expected = $"diarize_model={diarizeModel}";
194+
195+
//Act
196+
var result = QueryParameterUtil.FormatURL(Defaults.DEFAULT_URI, obj);
197+
198+
//Assert
199+
result.Should().NotBeNull();
200+
result.Should().Contain(expected);
201+
}
202+
203+
[Test]
204+
public void GetParameters_Should_Omit_DiarizeModel_When_Not_Set()
205+
{
206+
// Input and Output - additive/non-breaking: absent unless explicitly set
207+
var obj = new Deepgram.Models.Listen.v1.REST.PreRecordedSchema() { Model = "nova-2" };
208+
209+
//Act
210+
var result = QueryParameterUtil.FormatURL(Defaults.DEFAULT_URI, obj);
211+
212+
//Assert
213+
result.Should().NotBeNull();
214+
result.Should().NotContain("diarize_model");
215+
}
216+
185217
}

Deepgram/Models/Listen/v1/REST/PreRecordedSchema.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ public class PreRecordedSchema
9191
[JsonPropertyName("diarize")]
9292
public bool? Diarize { get; set; }
9393

94+
/// <summary>
95+
/// Select and enable a specific batch diarization model version, e.g. "latest", "v1", or "v2".
96+
/// Supersedes the deprecated <see cref="Diarize"/> boolean; if set, do not also set Diarize.
97+
/// Batch/pre-recorded only - not accepted on streaming requests.
98+
/// <see href="https://developers.deepgram.com/docs/diarization">
99+
/// default is null
100+
/// </summary>
101+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
102+
[JsonPropertyName("diarize_model")]
103+
public string? DiarizeModel { get; set; }
104+
94105
// <summary>
95106
/// <see href="https://developers.deepgram.com/docs/diarization">
96107
/// default is null, only applies if Diarize is set to true

Deepgram/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ also see [TranscribeSchema] which LiveSchema is derived from for more options
293293
| Callback | string? | Callback URL to provide if you would like your submitted audio to be processed asynchronously |
294294
| Diarize | bool? | Indicates whether to recognize speaker changes |
295295
| DiarizeVersion | string? | |
296+
| DiarizeModel | string? | Batch diarization model version to use (latest, v1, v2). Supersedes the deprecated Diarize boolean |
296297
| Extra | Dictonary<string,string>? | additonal values you want echoing bac | |
297298
| FillerWords | int? | Whether to include words like "uh" and "um" in transcription output. |
298299
| Keywords | List<string>? | Keywords to which the model should pay particular attention to boosting or suppressing to help it understand context |

0 commit comments

Comments
 (0)