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 · modecode

1using System;
2using 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)]
30 public virtual async Task<ClientResult> GenerateSpeechAsync(BinaryContent content, RequestOptions options = null)
31 {
32 Argument.AssertNotNull(content, nameof(content));
33
34 using PipelineMessage message = CreateCreateSpeechRequest(content, options);
35 return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
36 }
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)]
51 public virtual ClientResult GenerateSpeech(BinaryContent content, RequestOptions options = null)
52 {
53 Argument.AssertNotNull(content, nameof(content));
54
55 using PipelineMessage message = CreateCreateSpeechRequest(content, options);
56 return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
57 }
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)]
75 public virtual async Task<ClientResult> TranscribeAudioAsync(BinaryContent content, string contentType, RequestOptions options = null)
76 {
77 Argument.AssertNotNull(content, nameof(content));
78 Argument.AssertNotNullOrEmpty(contentType, nameof(contentType));
79
80 using PipelineMessage message = CreateCreateTranscriptionRequest(content, contentType, options);
81 PipelineResponse protocolResponse = await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false);
82 return ClientResult.FromResponse(protocolResponse);
83 }
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)]
101 public virtual ClientResult TranscribeAudio(BinaryContent content, string contentType, RequestOptions options = null)
102 {
103 Argument.AssertNotNull(content, nameof(content));
104 Argument.AssertNotNullOrEmpty(contentType, nameof(contentType));
105
106 using PipelineMessage message = CreateCreateTranscriptionRequest(content, contentType, options);
107 return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
108 }
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>
125 public virtual async Task<ClientResult> TranslateAudioAsync(BinaryContent content, string contentType, RequestOptions options = null)
126 {
127 Argument.AssertNotNull(content, nameof(content));
128 Argument.AssertNotNullOrEmpty(contentType, nameof(contentType));
129
130 using PipelineMessage message = CreateCreateTranslationRequest(content, contentType, options);
131 return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
132 }
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>
149 public virtual ClientResult TranslateAudio(BinaryContent content, string contentType, RequestOptions options = null)
150 {
151 Argument.AssertNotNull(content, nameof(content));
152 Argument.AssertNotNullOrEmpty(contentType, nameof(contentType));
153
154 using PipelineMessage message = CreateCreateTranslationRequest(content, contentType, options);
155 return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
156 }
157}