openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.2.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Custom/Audio/AudioClient.Protocol.cs

157lines · 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);
5dce104aJose Arriaga Maldonado1 years ago81PipelineResponse protocolResponse = await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false);
82return ClientResult.FromResponse(protocolResponse);
9f9f2936Jose Arriaga Maldonado2 years ago83}
84
85// CUSTOM:
86// - Renamed.
87// - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
88// - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
89// - Added "contentType" parameter.
90/// <summary>
91/// [Protocol Method] Transcribes audio.
92/// </summary>
93/// <param name="content"> The content to send as the body of the request. </param>
94/// <param name="contentType"> The content type of the request. </param>
95/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
96/// <exception cref="ArgumentNullException"> <paramref name="content"/> or <paramref name="contentType"/> is null. </exception>
97/// <exception cref="ArgumentException"> <paramref name="contentType"/> is an empty string, and was expected to be non-empty. </exception>
98/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
99/// <returns> The response returned from the service. </returns>
100[EditorBrowsable(EditorBrowsableState.Never)]
101public virtual ClientResult TranscribeAudio(BinaryContent content, string contentType, RequestOptions options = null)
102{
103Argument.AssertNotNull(content, nameof(content));
104Argument.AssertNotNullOrEmpty(contentType, nameof(contentType));
105
106using PipelineMessage message = CreateCreateTranscriptionRequest(content, contentType, options);
e0fee603Jose Arriaga Maldonado1 years ago107return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
9f9f2936Jose Arriaga Maldonado2 years ago108}
109
110// CUSTOM:
111// - Renamed.
112// - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
113// - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
114// - Added "contentType" parameter.
115/// <summary>
116/// [Protocol Method] Translates audio into English.
117/// </summary>
118/// <param name="content"> The content to send as the body of the request. </param>
119/// <param name="contentType"> The content type of the request. </param>
120/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
121/// <exception cref="ArgumentNullException"> <paramref name="content"/> or <paramref name="contentType"/> is null. </exception>
122/// <exception cref="ArgumentException"> <paramref name="contentType"/> is an empty string, and was expected to be non-empty. </exception>
123/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
124/// <returns> The response returned from the service. </returns>
125public virtual async Task<ClientResult> TranslateAudioAsync(BinaryContent content, string contentType, RequestOptions options = null)
126{
127Argument.AssertNotNull(content, nameof(content));
128Argument.AssertNotNullOrEmpty(contentType, nameof(contentType));
129
130using PipelineMessage message = CreateCreateTranslationRequest(content, contentType, options);
e0fee603Jose Arriaga Maldonado1 years ago131return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
9f9f2936Jose Arriaga Maldonado2 years ago132}
133
134// CUSTOM:
135// - Renamed.
136// - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
137// - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
138// - Added "contentType" parameter.
139/// <summary>
140/// [Protocol Method] Translates audio into English.
141/// </summary>
142/// <param name="content"> The content to send as the body of the request. </param>
143/// <param name="contentType"> The content type of the request. </param>
144/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
145/// <exception cref="ArgumentNullException"> <paramref name="content"/> or <paramref name="contentType"/> is null. </exception>
146/// <exception cref="ArgumentException"> <paramref name="contentType"/> is an empty string, and was expected to be non-empty. </exception>
147/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
148/// <returns> The response returned from the service. </returns>
149public virtual ClientResult TranslateAudio(BinaryContent content, string contentType, RequestOptions options = null)
150{
151Argument.AssertNotNull(content, nameof(content));
152Argument.AssertNotNullOrEmpty(contentType, nameof(contentType));
153
154using PipelineMessage message = CreateCreateTranslationRequest(content, contentType, options);
e0fee603Jose Arriaga Maldonado1 years ago155return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
9f9f2936Jose Arriaga Maldonado2 years ago156}
157}