openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Custom/Audio/AudioClient.Protocol.cs
156lines · modecode
| 1 | using System; |
| 2 | using System.ClientModel; |
| 3 | using System.ClientModel.Primitives; |
| 4 | using System.ComponentModel; |
| 5 | using System.Threading.Tasks; |
| 6 | |
| 7 | namespace 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))] |
| 15 | public 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> GenerateSpeechFromTextAsync(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 GenerateSpeechFromText(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 | return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); |
| 82 | } |
| 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)] |
| 100 | public virtual ClientResult TranscribeAudio(BinaryContent content, string contentType, RequestOptions options = null) |
| 101 | { |
| 102 | Argument.AssertNotNull(content, nameof(content)); |
| 103 | Argument.AssertNotNullOrEmpty(contentType, nameof(contentType)); |
| 104 | |
| 105 | using PipelineMessage message = CreateCreateTranscriptionRequest(content, contentType, options); |
| 106 | return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); |
| 107 | } |
| 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> |
| 124 | public virtual async Task<ClientResult> TranslateAudioAsync(BinaryContent content, string contentType, RequestOptions options = null) |
| 125 | { |
| 126 | Argument.AssertNotNull(content, nameof(content)); |
| 127 | Argument.AssertNotNullOrEmpty(contentType, nameof(contentType)); |
| 128 | |
| 129 | using PipelineMessage message = CreateCreateTranslationRequest(content, contentType, options); |
| 130 | return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); |
| 131 | } |
| 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> |
| 148 | public virtual ClientResult TranslateAudio(BinaryContent content, string contentType, RequestOptions options = null) |
| 149 | { |
| 150 | Argument.AssertNotNull(content, nameof(content)); |
| 151 | Argument.AssertNotNullOrEmpty(contentType, nameof(contentType)); |
| 152 | |
| 153 | using PipelineMessage message = CreateCreateTranslationRequest(content, contentType, options); |
| 154 | return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); |
| 155 | } |
| 156 | } |