feat: add diarize_model option to pre-recorded transcription#412
Merged
Conversation
Add `DiarizeModel` as a typed, optional string property on the canonical PreRecordedSchema (Deepgram.Models.Listen.v1.REST), serialized to the `diarize_model` query param on POST /v1/listen via [JsonPropertyName]. Accepts the API spec's values (latest, v1, v2), surfacing Batch Diarization v2 to callers. Mirrors the existing `diarize`/`diarize_version`/`model` property pattern (JsonPropertyName + JsonIgnore WhenWritingNull). The deprecated PreRecorded.v1.PreRecordedSchema subclass inherits it automatically. Additive and non-breaking; the deprecated `diarize` boolean is left intact. Batch-only: not added to the streaming LiveSchema, matching the API constraint that diarize_model is rejected on streaming requests. Adds unit tests asserting diarize_model=v2 appears in the outgoing batch request query string, and is omitted when unset.
dg-coreylweathers
approved these changes
Jun 5, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
string? DiarizeModelto the canonicalPreRecordedSchema(Deepgram/Models/Listen/v1/REST/PreRecordedSchema.cs), with[JsonPropertyName("diarize_model")]+[JsonIgnore(WhenWritingNull)], so it serializes to thediarize_modelquery param onPOST /v1/listen. Acceptslatest/v1/v2(typed asstringto mirror existingmodel/diarize_versionproperties and stay forward-compatible). The deprecatedPreRecorded.v1.PreRecordedSchemasubclass inherits it automatically.diarize_model=v2appears in the outgoing query string and is omitted when unset.dotnet build0 errors; full unit suite 165/165 on .NET 8.Why
The playground needs to surface Diarization v2, and .NET is a playground-supported SDK whose spec-driven regen isn't ready yet. This hand-written change bridges the gap; the regenerated SDK will pick up
diarize_modelnatively later.Non-breaking
Additive only. The deprecated
diarizeboolean is untouched and the property is omitted when null. Batch-only: intentionally not added to the streamingLiveSchema, since the API rejectsdiarize_modelon streaming requests.