openai/openai-dotnet

Public

mirrored from https://github.com/openai/openai-dotnetAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.2.0-beta.2

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/Custom/Audio/AudioClient.Protocol.cs

156lines · modeblame

58f93c8dShivangiReja2 years ago1using System;
9f9f2936Jose Arriaga Maldonado2 years ago2using System.ClientModel;
3using System.ClientModel.Primitives;
4using System.ComponentModel;
5using System.Threading.Tasks;
6
7namespace OpenAI.Audio;
8
9[CodeGenSuppress("CreateSpeechAsync", typeof(BinaryContent), typeof(RequestOptions))]
10[CodeGenSuppress("CreateSpeech", typeof(BinaryContent), typeof(RequestOptions))]
11[CodeGenSuppress("CreateTranscriptionAsync", typeof(BinaryContent), typeof(string), typeof(RequestOptions))]
12[CodeGenSuppress("CreateTranscription", typeof(BinaryContent), typeof(string), typeof(RequestOptions))]
13[CodeGenSuppress("CreateTranslationAsync", typeof(BinaryContent), typeof(string), typeof(RequestOptions))]
14[CodeGenSuppress("CreateTranslation", typeof(BinaryContent), typeof(string), typeof(RequestOptions))]
15public partial class AudioClient
16{
17// CUSTOM:
18// - Renamed.
19// - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
20// - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
21/// <summary>
22/// [Protocol Method] Generates text-to-speech audio using the specified voice speaking the provided input text.
23/// </summary>
24/// <param name="content"> The content to send as the body of the request. </param>
25/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
26/// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
27/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
28/// <returns> The response returned from the service. </returns>
29[EditorBrowsable(EditorBrowsableState.Never)]
d84bf54dTravis Wilson1 years ago30public virtual async Task<ClientResult> GenerateSpeechAsync(BinaryContent content, RequestOptions options = null)
9f9f2936Jose Arriaga Maldonado2 years ago31{
32Argument.AssertNotNull(content, nameof(content));
33
34using PipelineMessage message = CreateCreateSpeechRequest(content, options);
e0fee603Jose Arriaga Maldonado1 years ago35return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
9f9f2936Jose Arriaga Maldonado2 years ago36}
37
38// CUSTOM:
39// - Renamed.
40// - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
41// - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
42/// <summary>
43/// [Protocol Method] Generates text-to-speech audio using the specified voice speaking the provided input text.
44/// </summary>
45/// <param name="content"> The content to send as the body of the request. </param>
46/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
47/// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
48/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
49/// <returns> The response returned from the service. </returns>
50[EditorBrowsable(EditorBrowsableState.Never)]
d84bf54dTravis Wilson1 years ago51public virtual ClientResult GenerateSpeech(BinaryContent content, RequestOptions options = null)
9f9f2936Jose Arriaga Maldonado2 years ago52{
53Argument.AssertNotNull(content, nameof(content));
54
55using PipelineMessage message = CreateCreateSpeechRequest(content, options);
e0fee603Jose Arriaga Maldonado1 years ago56return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
9f9f2936Jose Arriaga Maldonado2 years ago57}
58
59// CUSTOM:
60// - Renamed.
61// - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
62// - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
63// - Added "contentType" parameter.
64/// <summary>
65/// [Protocol Method] Transcribes audio.
66/// </summary>
67/// <param name="content"> The content to send as the body of the request. </param>
68/// <param name="contentType"> The content type of the request. </param>
69/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
70/// <exception cref="ArgumentNullException"> <paramref name="content"/> or <paramref name="contentType"/> is null. </exception>
71/// <exception cref="ArgumentException"> <paramref name="contentType"/> is an empty string, and was expected to be non-empty. </exception>
72/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
73/// <returns> The response returned from the service. </returns>
74[EditorBrowsable(EditorBrowsableState.Never)]
75public virtual async Task<ClientResult> TranscribeAudioAsync(BinaryContent content, string contentType, RequestOptions options = null)
76{
77Argument.AssertNotNull(content, nameof(content));
78Argument.AssertNotNullOrEmpty(contentType, nameof(contentType));
79
80using PipelineMessage message = CreateCreateTranscriptionRequest(content, contentType, options);
e0fee603Jose Arriaga Maldonado1 years ago81return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
9f9f2936Jose Arriaga Maldonado2 years ago82}
83
84// CUSTOM:
85// - Renamed.
86// - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
87// - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
88// - Added "contentType" parameter.
89/// <summary>
90/// [Protocol Method] Transcribes audio.
91/// </summary>
92/// <param name="content"> The content to send as the body of the request. </param>
93/// <param name="contentType"> The content type of the request. </param>
94/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
95/// <exception cref="ArgumentNullException"> <paramref name="content"/> or <paramref name="contentType"/> is null. </exception>
96/// <exception cref="ArgumentException"> <paramref name="contentType"/> is an empty string, and was expected to be non-empty. </exception>
97/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
98/// <returns> The response returned from the service. </returns>
99[EditorBrowsable(EditorBrowsableState.Never)]
100public virtual ClientResult TranscribeAudio(BinaryContent content, string contentType, RequestOptions options = null)
101{
102Argument.AssertNotNull(content, nameof(content));
103Argument.AssertNotNullOrEmpty(contentType, nameof(contentType));
104
105using PipelineMessage message = CreateCreateTranscriptionRequest(content, contentType, options);
e0fee603Jose Arriaga Maldonado1 years ago106return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
9f9f2936Jose Arriaga Maldonado2 years ago107}
108
109// CUSTOM:
110// - Renamed.
111// - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
112// - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
113// - Added "contentType" parameter.
114/// <summary>
115/// [Protocol Method] Translates audio into English.
116/// </summary>
117/// <param name="content"> The content to send as the body of the request. </param>
118/// <param name="contentType"> The content type of the request. </param>
119/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
120/// <exception cref="ArgumentNullException"> <paramref name="content"/> or <paramref name="contentType"/> is null. </exception>
121/// <exception cref="ArgumentException"> <paramref name="contentType"/> is an empty string, and was expected to be non-empty. </exception>
122/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
123/// <returns> The response returned from the service. </returns>
124public virtual async Task<ClientResult> TranslateAudioAsync(BinaryContent content, string contentType, RequestOptions options = null)
125{
126Argument.AssertNotNull(content, nameof(content));
127Argument.AssertNotNullOrEmpty(contentType, nameof(contentType));
128
129using PipelineMessage message = CreateCreateTranslationRequest(content, contentType, options);
e0fee603Jose Arriaga Maldonado1 years ago130return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
9f9f2936Jose Arriaga Maldonado2 years ago131}
132
133// CUSTOM:
134// - Renamed.
135// - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
136// - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
137// - Added "contentType" parameter.
138/// <summary>
139/// [Protocol Method] Translates audio into English.
140/// </summary>
141/// <param name="content"> The content to send as the body of the request. </param>
142/// <param name="contentType"> The content type of the request. </param>
143/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
144/// <exception cref="ArgumentNullException"> <paramref name="content"/> or <paramref name="contentType"/> is null. </exception>
145/// <exception cref="ArgumentException"> <paramref name="contentType"/> is an empty string, and was expected to be non-empty. </exception>
146/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
147/// <returns> The response returned from the service. </returns>
148public virtual ClientResult TranslateAudio(BinaryContent content, string contentType, RequestOptions options = null)
149{
150Argument.AssertNotNull(content, nameof(content));
151Argument.AssertNotNullOrEmpty(contentType, nameof(contentType));
152
153using PipelineMessage message = CreateCreateTranslationRequest(content, contentType, options);
e0fee603Jose Arriaga Maldonado1 years ago154return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
9f9f2936Jose Arriaga Maldonado2 years ago155}
156}