Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realtime specification: use raw int32 for millisecond duration #327

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ namespace OpenAI.RealtimeConversation;
[CodeGenSerialization(nameof(SilenceDurationMs), DeserializationValueHook = nameof(DeserializeMillisecondDuration), SerializationValueHook = nameof(SerializeSilenceDurationMs))]
internal partial class InternalRealtimeServerVadTurnDetection
{
// CUSTOM: Represent millisecond durations as timespans
[CodeGenMember("PrefixPaddingMs")]
public TimeSpan? PrefixPaddingMs { get; set; }
[CodeGenMember("SilenceDurationms")]
public TimeSpan? SilenceDurationMs { get; set; }

private static void DeserializeMillisecondDuration(JsonProperty property, ref TimeSpan? duration)
{
if (property.Value.ValueKind == JsonValueKind.Number)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@ internal InternalRealtimeServerVadTurnDetection(ConversationTurnDetectionKind ki
}

public float? Threshold { get; set; }
public TimeSpan? PrefixPaddingMs { get; set; }
public TimeSpan? SilenceDurationMs { get; set; }
}
}
10 changes: 6 additions & 4 deletions .openapi3/openapi3-openai.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10596,11 +10596,13 @@ components:
format: float
default: 0.5
prefix_padding_ms:
type: string
format: duration
type: integer
format: int32
default: 300
silence_duration_ms:
type: string
format: duration
type: integer
format: int32
default: 200
allOf:
- $ref: '#/components/schemas/RealtimeTurnDetection'
RealtimeTool:
Expand Down
8 changes: 2 additions & 6 deletions .typespec/realtime/custom.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,8 @@ model RealtimeTurnDetection {
model RealtimeServerVadTurnDetection extends RealtimeTurnDetection {
type: RealtimeTurnDetectionType.server_vad;
threshold?: float32 = 0.5;

// @encode("milliseconds", int32)
prefix_padding_ms?: duration; // = 300ms

// @encode("milliseconds", int32)
silence_duration_ms?: duration; // = 200,s
prefix_padding_ms?: int32 = 300;
silence_duration_ms?: int32 = 200;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading the spec correctly, the default value here is 500ms instead of 200ms.

}

union RealtimeResponseStatus {
Expand Down