Skip to content
Merged
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
5 changes: 5 additions & 0 deletions api/OpenAI.net8.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,8 @@ public class AudioTranscription : IJsonModel<AudioTranscription>, IPersistableMo
[Experimental("OPENAI001")]
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
[Experimental("OPENAI001")]
public static explicit operator AudioTranscription(ClientResult result);
[Experimental("OPENAI001")]
protected virtual AudioTranscription PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
[Experimental("OPENAI001")]
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
Expand Down Expand Up @@ -1213,6 +1215,8 @@ public class AudioTranslation : IJsonModel<AudioTranslation>, IPersistableModel<
[Experimental("OPENAI001")]
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
[Experimental("OPENAI001")]
public static explicit operator AudioTranslation(ClientResult result);
[Experimental("OPENAI001")]
protected virtual AudioTranslation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
[Experimental("OPENAI001")]
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
Expand Down Expand Up @@ -1342,6 +1346,7 @@ public class StreamingAudioTranscriptionTextDoneUpdate : StreamingAudioTranscrip
public class StreamingAudioTranscriptionUpdate : IJsonModel<StreamingAudioTranscriptionUpdate>, IPersistableModel<StreamingAudioTranscriptionUpdate> {
protected virtual StreamingAudioTranscriptionUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
public static explicit operator StreamingAudioTranscriptionUpdate(ClientResult result);
protected virtual StreamingAudioTranscriptionUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
Expand Down
3 changes: 3 additions & 0 deletions api/OpenAI.netstandard2.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,7 @@ public class AudioTranscription : IJsonModel<AudioTranscription>, IPersistableMo
public IReadOnlyList<TranscribedWord> Words { get; }
protected virtual AudioTranscription JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
public static explicit operator AudioTranscription(ClientResult result);
protected virtual AudioTranscription PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
Expand Down Expand Up @@ -1097,6 +1098,7 @@ public class AudioTranslation : IJsonModel<AudioTranslation>, IPersistableModel<
public string Text { get; }
protected virtual AudioTranslation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
public static explicit operator AudioTranslation(ClientResult result);
protected virtual AudioTranslation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
Expand Down Expand Up @@ -1207,6 +1209,7 @@ public class StreamingAudioTranscriptionTextDoneUpdate : StreamingAudioTranscrip
public class StreamingAudioTranscriptionUpdate : IJsonModel<StreamingAudioTranscriptionUpdate>, IPersistableModel<StreamingAudioTranscriptionUpdate> {
protected virtual StreamingAudioTranscriptionUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
public static explicit operator StreamingAudioTranscriptionUpdate(ClientResult result);
protected virtual StreamingAudioTranscriptionUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
Expand Down
6 changes: 0 additions & 6 deletions specification/base/typespec/audio/operations.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ interface Audio {
| CreateTranscriptionResponseVerboseJson
| CreateTranscriptionResponseJson
| SseResponseOf<CreateTranscriptionResponseStreamEvent>
| {
// TODO: This response is not defined in the OpenAPI spec.
@header contentType: "text/plain";

@body responseBody: string;
}
| ErrorResponse;

@route("translations")
Expand Down
10 changes: 10 additions & 0 deletions src/Custom/Audio/AudioTranscription.Serialization.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.ClientModel;
using System.ClientModel.Primitives;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;

namespace OpenAI.Audio;
Expand All @@ -27,4 +29,12 @@ internal static AudioTranscription FromResponse(PipelineResponse response)
using var document = JsonDocument.Parse(response.Content);
return DeserializeAudioTranscription(document.RootElement, null);
}

[Experimental("OPENAI001")]
public static explicit operator AudioTranscription(ClientResult result)
{
using PipelineResponse response = result.GetRawResponse();
using JsonDocument document = JsonDocument.Parse(response.Content);
return DeserializeAudioTranscription(document.RootElement, ModelSerializationExtensions.WireOptions);
}
}
34 changes: 17 additions & 17 deletions src/Generated/OpenAIModelFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,23 @@ public static ItemRetrievedUpdate ItemRetrievedUpdate(string eventId = default,
return new ItemRetrievedUpdate(RealtimeUpdateKind.ItemRetrieved, eventId, additionalBinaryDataProperties: null, item);
}

public static AudioTranscription AudioTranscription(string task = default, string language = default, TimeSpan? duration = default, string text = default, IEnumerable<TranscribedWord> words = default, IEnumerable<TranscribedSegment> segments = default, IEnumerable<AudioTokenLogProbabilityDetails> transcriptionTokenLogProbabilities = default)
{
words ??= new ChangeTrackingList<TranscribedWord>();
segments ??= new ChangeTrackingList<TranscribedSegment>();
transcriptionTokenLogProbabilities ??= new ChangeTrackingList<AudioTokenLogProbabilityDetails>();

return new AudioTranscription(
task,
language,
duration,
text,
words.ToList(),
segments.ToList(),
transcriptionTokenLogProbabilities.ToList(),
additionalBinaryDataProperties: null);
}

public static ChatFunctionChoice ChatFunctionChoice(string predefinedFunctionChoice = default)
{
return new ChatFunctionChoice(predefinedFunctionChoice);
Expand Down Expand Up @@ -1271,23 +1288,6 @@ public static RunStepCollectionOptions RunStepCollectionOptions(string afterId =
return new RunStepCollectionOptions(afterId, beforeId, pageSizeLimit, order, additionalBinaryDataProperties: null);
}

public static AudioTranscription AudioTranscription(string task = default, string language = default, TimeSpan? duration = default, string text = default, IEnumerable<TranscribedWord> words = default, IEnumerable<TranscribedSegment> segments = default, IEnumerable<AudioTokenLogProbabilityDetails> transcriptionTokenLogProbabilities = default)
{
words ??= new ChangeTrackingList<TranscribedWord>();
segments ??= new ChangeTrackingList<TranscribedSegment>();
transcriptionTokenLogProbabilities ??= new ChangeTrackingList<AudioTokenLogProbabilityDetails>();

return new AudioTranscription(
task,
language,
duration,
text,
words.ToList(),
segments.ToList(),
transcriptionTokenLogProbabilities.ToList(),
additionalBinaryDataProperties: null);
}

public static ChatCompletionCollectionOptions ChatCompletionCollectionOptions(string afterId = default, int? pageSizeLimit = default, ChatCompletionCollectionOrder? order = default, IDictionary<string, string> metadata = default, string model = default)
{
metadata ??= new ChangeTrackingDictionary<string, string>();
Expand Down
Loading