openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.2.0-beta.1

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Custom/Audio/AudioClient.cs

327lines · modeblame

9f9f2936Jose Arriaga Maldonado2 years ago1using System;
2using System.ClientModel;
3using System.ClientModel.Primitives;
4using System.IO;
19a65a0aKrzysztof Cwalina2 years ago5using System.Threading;
9f9f2936Jose Arriaga Maldonado2 years ago6using System.Threading.Tasks;
7
8namespace OpenAI.Audio;
9
13a9c686Jose Arriaga Maldonado1 years ago10// CUSTOM:
11// - Renamed.
12// - Suppressed constructor that takes endpoint parameter; endpoint is now a property in the options class.
13// - Suppressed methods that only take the options parameter.
9f9f2936Jose Arriaga Maldonado2 years ago14/// <summary> The service client for OpenAI audio operations. </summary>
15[CodeGenClient("Audio")]
16[CodeGenSuppress("AudioClient", typeof(ClientPipeline), typeof(ApiKeyCredential), typeof(Uri))]
e0fee603Jose Arriaga Maldonado1 years ago17[CodeGenSuppress("CreateSpeechAsync", typeof(SpeechGenerationOptions), typeof(CancellationToken))]
18[CodeGenSuppress("CreateSpeech", typeof(SpeechGenerationOptions), typeof(CancellationToken))]
9f9f2936Jose Arriaga Maldonado2 years ago19public partial class AudioClient
20{
21private readonly string _model;
22
2ab1a942Jose Arriaga Maldonado1 years ago23// CUSTOM: Added as a convenience.
e0fee603Jose Arriaga Maldonado1 years ago24/// <summary> Initializes a new instance of <see cref="AudioClient"/>. </summary>
2ab1a942Jose Arriaga Maldonado1 years ago25/// <param name="model"> The name of the model to use in requests sent to the service. To learn more about the available models, see <see href="https://platform.openai.com/docs/models"/>. </param>
26/// <param name="apiKey"> The API key to authenticate with the service. </param>
27/// <exception cref="ArgumentNullException"> <paramref name="model"/> or <paramref name="apiKey"/> is null. </exception>
28/// <exception cref="ArgumentException"> <paramref name="model"/> is an empty string, and was expected to be non-empty. </exception>
29public AudioClient(string model, string apiKey) : this(model, new ApiKeyCredential(apiKey), new OpenAIClientOptions())
30{
31}
32
9f9f2936Jose Arriaga Maldonado2 years ago33// CUSTOM:
34// - Added `model` parameter.
13a9c686Jose Arriaga Maldonado1 years ago35// - Used a custom pipeline.
36// - Demoted the endpoint parameter to be a property in the options class.
e0fee603Jose Arriaga Maldonado1 years ago37/// <summary> Initializes a new instance of <see cref="AudioClient"/>. </summary>
13a9c686Jose Arriaga Maldonado1 years ago38/// <param name="model"> The name of the model to use in requests sent to the service. To learn more about the available models, see <see href="https://platform.openai.com/docs/models"/>. </param>
39/// <param name="credential"> The API key to authenticate with the service. </param>
40/// <exception cref="ArgumentNullException"> <paramref name="model"/> or <paramref name="credential"/> is null. </exception>
41/// <exception cref="ArgumentException"> <paramref name="model"/> is an empty string, and was expected to be non-empty. </exception>
42public AudioClient(string model, ApiKeyCredential credential) : this(model, credential, new OpenAIClientOptions())
43{
44}
9f9f2936Jose Arriaga Maldonado2 years ago45
46// CUSTOM:
47// - Added `model` parameter.
13a9c686Jose Arriaga Maldonado1 years ago48// - Used a custom pipeline.
49// - Demoted the endpoint parameter to be a property in the options class.
e0fee603Jose Arriaga Maldonado1 years ago50/// <summary> Initializes a new instance of <see cref="AudioClient"/>. </summary>
13a9c686Jose Arriaga Maldonado1 years ago51/// <param name="model"> The name of the model to use in requests sent to the service. To learn more about the available models, see <see href="https://platform.openai.com/docs/models"/>. </param>
52/// <param name="credential"> The API key to authenticate with the service. </param>
53/// <param name="options"> The options to configure the client. </param>
54/// <exception cref="ArgumentNullException"> <paramref name="model"/> or <paramref name="credential"/> is null. </exception>
55/// <exception cref="ArgumentException"> <paramref name="model"/> is an empty string, and was expected to be non-empty. </exception>
56public AudioClient(string model, ApiKeyCredential credential, OpenAIClientOptions options)
57{
58Argument.AssertNotNullOrEmpty(model, nameof(model));
59Argument.AssertNotNull(credential, nameof(credential));
60options ??= new OpenAIClientOptions();
9f9f2936Jose Arriaga Maldonado2 years ago61
13a9c686Jose Arriaga Maldonado1 years ago62_model = model;
e0fee603Jose Arriaga Maldonado1 years ago63Pipeline = OpenAIClient.CreatePipeline(credential, options);
13a9c686Jose Arriaga Maldonado1 years ago64_endpoint = OpenAIClient.GetEndpoint(options);
65}
66
67// CUSTOM:
68// - Added `model` parameter.
69// - Used a custom pipeline.
70// - Demoted the endpoint parameter to be a property in the options class.
71// - Made protected.
e0fee603Jose Arriaga Maldonado1 years ago72/// <summary> Initializes a new instance of <see cref="AudioClient"/>. </summary>
13a9c686Jose Arriaga Maldonado1 years ago73/// <param name="pipeline"> The HTTP pipeline to send and receive REST requests and responses. </param>
74/// <param name="model"> The name of the model to use in requests sent to the service. To learn more about the available models, see <see href="https://platform.openai.com/docs/models"/>. </param>
75/// <param name="options"> The options to configure the client. </param>
76/// <exception cref="ArgumentNullException"> <paramref name="pipeline"/> or <paramref name="model"/> is null. </exception>
77/// <exception cref="ArgumentException"> <paramref name="model"/> is an empty string, and was expected to be non-empty. </exception>
78protected internal AudioClient(ClientPipeline pipeline, string model, OpenAIClientOptions options)
9f9f2936Jose Arriaga Maldonado2 years ago79{
13a9c686Jose Arriaga Maldonado1 years ago80Argument.AssertNotNull(pipeline, nameof(pipeline));
9f9f2936Jose Arriaga Maldonado2 years ago81Argument.AssertNotNullOrEmpty(model, nameof(model));
13a9c686Jose Arriaga Maldonado1 years ago82options ??= new OpenAIClientOptions();
9f9f2936Jose Arriaga Maldonado2 years ago83
84_model = model;
e0fee603Jose Arriaga Maldonado1 years ago85Pipeline = pipeline;
13a9c686Jose Arriaga Maldonado1 years ago86_endpoint = OpenAIClient.GetEndpoint(options);
9f9f2936Jose Arriaga Maldonado2 years ago87}
88
89#region GenerateSpeech
90
13a9c686Jose Arriaga Maldonado1 years ago91/// <summary> Generates a life-like, spoken audio recording of the input text. </summary>
9f9f2936Jose Arriaga Maldonado2 years ago92/// <remarks>
13a9c686Jose Arriaga Maldonado1 years ago93/// The default format of the generated audio is <see cref="GeneratedSpeechFormat.Mp3"/> unless otherwise specified
94/// via <see cref="SpeechGenerationOptions.ResponseFormat"/>.
9f9f2936Jose Arriaga Maldonado2 years ago95/// </remarks>
13a9c686Jose Arriaga Maldonado1 years ago96/// <param name="text"> The text to generate audio for. </param>
97/// <param name="voice"> The voice to use in the generated audio. </param>
98/// <param name="options"> The options to configure the audio generation. </param>
99/// <param name="cancellationToken"> A token that can be used to cancel this method call. </param>
100/// <exception cref="ArgumentNullException"> <paramref name="text"/> is null. </exception>
9f9f2936Jose Arriaga Maldonado2 years ago101/// <returns> The generated audio in the specified output format. </returns>
d84bf54dTravis Wilson1 years ago102public virtual async Task<ClientResult<BinaryData>> GenerateSpeechAsync(string text, GeneratedSpeechVoice voice, SpeechGenerationOptions options = null, CancellationToken cancellationToken = default)
9f9f2936Jose Arriaga Maldonado2 years ago103{
104Argument.AssertNotNull(text, nameof(text));
105
106options ??= new();
107CreateSpeechGenerationOptions(text, voice, ref options);
108
e0fee603Jose Arriaga Maldonado1 years ago109using BinaryContent content = options;
d84bf54dTravis Wilson1 years ago110ClientResult result = await GenerateSpeechAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false);
9f9f2936Jose Arriaga Maldonado2 years ago111return ClientResult.FromValue(result.GetRawResponse().Content, result.GetRawResponse());
112}
113
13a9c686Jose Arriaga Maldonado1 years ago114/// <summary> Generates a life-like, spoken audio recording of the input text. </summary>
9f9f2936Jose Arriaga Maldonado2 years ago115/// <remarks>
13a9c686Jose Arriaga Maldonado1 years ago116/// The default format of the generated audio is <see cref="GeneratedSpeechFormat.Mp3"/> unless otherwise specified
117/// via <see cref="SpeechGenerationOptions.ResponseFormat"/>.
9f9f2936Jose Arriaga Maldonado2 years ago118/// </remarks>
13a9c686Jose Arriaga Maldonado1 years ago119/// <param name="text"> The text to generate audio for. </param>
120/// <param name="voice"> The voice to use in the generated audio. </param>
121/// <param name="options"> The options to configure the audio generation. </param>
122/// <param name="cancellationToken"> A token that can be used to cancel this method call. </param>
123/// <exception cref="ArgumentNullException"> <paramref name="text"/> is null. </exception>
9f9f2936Jose Arriaga Maldonado2 years ago124/// <returns> The generated audio in the specified output format. </returns>
d84bf54dTravis Wilson1 years ago125public virtual ClientResult<BinaryData> GenerateSpeech(string text, GeneratedSpeechVoice voice, SpeechGenerationOptions options = null, CancellationToken cancellationToken = default)
9f9f2936Jose Arriaga Maldonado2 years ago126{
127Argument.AssertNotNull(text, nameof(text));
128
129options ??= new();
130CreateSpeechGenerationOptions(text, voice, ref options);
131
e0fee603Jose Arriaga Maldonado1 years ago132using BinaryContent content = options;
d84bf54dTravis Wilson1 years ago133ClientResult result = GenerateSpeech(content, cancellationToken.ToRequestOptions()); ;
9f9f2936Jose Arriaga Maldonado2 years ago134return ClientResult.FromValue(result.GetRawResponse().Content, result.GetRawResponse());
135}
136
137#endregion
138
139#region TranscribeAudio
140
13a9c686Jose Arriaga Maldonado1 years ago141/// <summary> Transcribes the input audio. </summary>
142/// <param name="audio"> The audio stream to transcribe. </param>
9f9f2936Jose Arriaga Maldonado2 years ago143/// <param name="audioFilename">
13a9c686Jose Arriaga Maldonado1 years ago144/// The filename associated with the audio stream. The filename's extension (for example: .mp3) will be used to
145/// validate the format of the input audio. The request may fail if the filename's extension and the actual
146/// format of the input audio do not match.
9f9f2936Jose Arriaga Maldonado2 years ago147/// </param>
13a9c686Jose Arriaga Maldonado1 years ago148/// <param name="options"> The options to configure the audio transcription. </param>
149/// <param name="cancellationToken"> A token that can be used to cancel this method call. </param>
9f9f2936Jose Arriaga Maldonado2 years ago150/// <exception cref="ArgumentNullException"> <paramref name="audio"/> or <paramref name="audioFilename"/> is null. </exception>
151/// <exception cref="ArgumentException"> <paramref name="audioFilename"/> is an empty string, and was expected to be non-empty. </exception>
19a65a0aKrzysztof Cwalina2 years ago152public virtual async Task<ClientResult<AudioTranscription>> TranscribeAudioAsync(Stream audio, string audioFilename, AudioTranscriptionOptions options = null, CancellationToken cancellationToken = default)
9f9f2936Jose Arriaga Maldonado2 years ago153{
154Argument.AssertNotNull(audio, nameof(audio));
155Argument.AssertNotNullOrEmpty(audioFilename, nameof(audioFilename));
156
157options ??= new();
158CreateAudioTranscriptionOptions(audio, audioFilename, ref options);
159
160using MultipartFormDataBinaryContent content = options.ToMultipartContent(audio, audioFilename);
19a65a0aKrzysztof Cwalina2 years ago161ClientResult result = await TranscribeAudioAsync(content, content.ContentType, cancellationToken.ToRequestOptions()).ConfigureAwait(false);
9f9f2936Jose Arriaga Maldonado2 years ago162return ClientResult.FromValue(AudioTranscription.FromResponse(result.GetRawResponse()), result.GetRawResponse());
163}
164
13a9c686Jose Arriaga Maldonado1 years ago165/// <summary> Transcribes the input audio. </summary>
166/// <param name="audio"> The audio stream to transcribe. </param>
9f9f2936Jose Arriaga Maldonado2 years ago167/// <param name="audioFilename">
13a9c686Jose Arriaga Maldonado1 years ago168/// The filename associated with the audio stream. The filename's extension (for example: .mp3) will be used to
169/// validate the format of the input audio. The request may fail if the filename's extension and the actual
170/// format of the input audio do not match.
9f9f2936Jose Arriaga Maldonado2 years ago171/// </param>
13a9c686Jose Arriaga Maldonado1 years ago172/// <param name="options"> The options to configure the audio transcription. </param>
173/// <param name="cancellationToken"> A token that can be used to cancel this method call. </param>
9f9f2936Jose Arriaga Maldonado2 years ago174/// <exception cref="ArgumentNullException"> <paramref name="audio"/> or <paramref name="audioFilename"/> is null. </exception>
175/// <exception cref="ArgumentException"> <paramref name="audioFilename"/> is an empty string, and was expected to be non-empty. </exception>
19a65a0aKrzysztof Cwalina2 years ago176public virtual ClientResult<AudioTranscription> TranscribeAudio(Stream audio, string audioFilename, AudioTranscriptionOptions options = null, CancellationToken cancellationToken = default)
9f9f2936Jose Arriaga Maldonado2 years ago177{
178Argument.AssertNotNull(audio, nameof(audio));
179Argument.AssertNotNullOrEmpty(audioFilename, nameof(audioFilename));
180
181options ??= new();
182CreateAudioTranscriptionOptions(audio, audioFilename, ref options);
183
184using MultipartFormDataBinaryContent content = options.ToMultipartContent(audio, audioFilename);
19a65a0aKrzysztof Cwalina2 years ago185ClientResult result = TranscribeAudio(content, content.ContentType, cancellationToken.ToRequestOptions());
9f9f2936Jose Arriaga Maldonado2 years ago186return ClientResult.FromValue(AudioTranscription.FromResponse(result.GetRawResponse()), result.GetRawResponse());
187}
188
13a9c686Jose Arriaga Maldonado1 years ago189/// <summary> Transcribes the input audio. </summary>
9f9f2936Jose Arriaga Maldonado2 years ago190/// <param name="audioFilePath">
13a9c686Jose Arriaga Maldonado1 years ago191/// The path of the audio file to transcribe. The provided file path's extension (for example: .mp3) will be
192/// used to validate the format of the input audio. The request may fail if the file path's extension and the
193/// actual format of the input audio do not match.
9f9f2936Jose Arriaga Maldonado2 years ago194/// </param>
13a9c686Jose Arriaga Maldonado1 years ago195/// <param name="options"> The options to configure the audio transcription. </param>
9f9f2936Jose Arriaga Maldonado2 years ago196/// <exception cref="ArgumentNullException"> <paramref name="audioFilePath"/> is null. </exception>
197/// <exception cref="ArgumentException"> <paramref name="audioFilePath"/> is an empty string, and was expected to be non-empty. </exception>
198public virtual async Task<ClientResult<AudioTranscription>> TranscribeAudioAsync(string audioFilePath, AudioTranscriptionOptions options = null)
199{
200Argument.AssertNotNullOrEmpty(audioFilePath, nameof(audioFilePath));
201
202using FileStream audioStream = File.OpenRead(audioFilePath);
203return await TranscribeAudioAsync(audioStream, audioFilePath, options).ConfigureAwait(false);
204}
205
13a9c686Jose Arriaga Maldonado1 years ago206/// <summary> Transcribes the input audio. </summary>
9f9f2936Jose Arriaga Maldonado2 years ago207/// <param name="audioFilePath">
13a9c686Jose Arriaga Maldonado1 years ago208/// The path of the audio file to transcribe. The provided file path's extension (for example: .mp3) will be
209/// used to validate the format of the input audio. The request may fail if the file path's extension and the
210/// actual format of the input audio do not match.
9f9f2936Jose Arriaga Maldonado2 years ago211/// </param>
13a9c686Jose Arriaga Maldonado1 years ago212/// <param name="options"> The options to configure the audio transcription. </param>
9f9f2936Jose Arriaga Maldonado2 years ago213/// <exception cref="ArgumentNullException"> <paramref name="audioFilePath"/> is null. </exception>
214/// <exception cref="ArgumentException"> <paramref name="audioFilePath"/> is an empty string, and was expected to be non-empty. </exception>
215public virtual ClientResult<AudioTranscription> TranscribeAudio(string audioFilePath, AudioTranscriptionOptions options = null)
216{
217Argument.AssertNotNullOrEmpty(audioFilePath, nameof(audioFilePath));
218
219using FileStream audioStream = File.OpenRead(audioFilePath);
220return TranscribeAudio(audioStream, audioFilePath, options);
221}
222
223#endregion
224
225#region TranslateAudio
226
13a9c686Jose Arriaga Maldonado1 years ago227/// <summary> Translates the input audio into English. </summary>
228/// <param name="audio"> The audio stream to translate. </param>
9f9f2936Jose Arriaga Maldonado2 years ago229/// <param name="audioFilename">
13a9c686Jose Arriaga Maldonado1 years ago230/// The filename associated with the audio stream. The filename's extension (for example: .mp3) will be used to
231/// validate the format of the input audio. The request may fail if the filename's extension and the actual
232/// format of the input audio do not match.
9f9f2936Jose Arriaga Maldonado2 years ago233/// </param>
13a9c686Jose Arriaga Maldonado1 years ago234/// <param name="options"> The options to configure the audio translation. </param>
235/// <param name="cancellationToken"> A token that can be used to cancel this method call. </param>
9f9f2936Jose Arriaga Maldonado2 years ago236/// <exception cref="ArgumentNullException"> <paramref name="audio"/> or <paramref name="audioFilename"/> is null. </exception>
237/// <exception cref="ArgumentException"> <paramref name="audioFilename"/> is an empty string, and was expected to be non-empty. </exception>
19a65a0aKrzysztof Cwalina2 years ago238public virtual async Task<ClientResult<AudioTranslation>> TranslateAudioAsync(Stream audio, string audioFilename, AudioTranslationOptions options = null, CancellationToken cancellationToken = default)
9f9f2936Jose Arriaga Maldonado2 years ago239{
240Argument.AssertNotNull(audio, nameof(audio));
241Argument.AssertNotNullOrEmpty(audioFilename, nameof(audioFilename));
242
243options ??= new();
244CreateAudioTranslationOptions(audio, audioFilename, ref options);
245
246using MultipartFormDataBinaryContent content = options.ToMultipartContent(audio, audioFilename);
19a65a0aKrzysztof Cwalina2 years ago247ClientResult result = await TranslateAudioAsync(content, content.ContentType, cancellationToken.ToRequestOptions()).ConfigureAwait(false);
9f9f2936Jose Arriaga Maldonado2 years ago248return ClientResult.FromValue(AudioTranslation.FromResponse(result.GetRawResponse()), result.GetRawResponse());
249}
250
13a9c686Jose Arriaga Maldonado1 years ago251/// <summary> Translates the input audio into English. </summary>
252/// <param name="audio"> The audio stream to translate. </param>
9f9f2936Jose Arriaga Maldonado2 years ago253/// <param name="audioFilename">
13a9c686Jose Arriaga Maldonado1 years ago254/// The filename associated with the audio stream. The filename's extension (for example: .mp3) will be used to
255/// validate the format of the input audio. The request may fail if the filename's extension and the actual
256/// format of the input audio do not match.
9f9f2936Jose Arriaga Maldonado2 years ago257/// </param>
13a9c686Jose Arriaga Maldonado1 years ago258/// <param name="options"> The options to configure the audio translation. </param>
259/// <param name="cancellationToken"> A token that can be used to cancel this method call. </param>
9f9f2936Jose Arriaga Maldonado2 years ago260/// <exception cref="ArgumentNullException"> <paramref name="audio"/> or <paramref name="audioFilename"/> is null. </exception>
261/// <exception cref="ArgumentException"> <paramref name="audioFilename"/> is an empty string, and was expected to be non-empty. </exception>
19a65a0aKrzysztof Cwalina2 years ago262public virtual ClientResult<AudioTranslation> TranslateAudio(Stream audio, string audioFilename, AudioTranslationOptions options = null, CancellationToken cancellationToken = default)
9f9f2936Jose Arriaga Maldonado2 years ago263{
264Argument.AssertNotNull(audio, nameof(audio));
265Argument.AssertNotNullOrEmpty(audioFilename, nameof(audioFilename));
266
267options ??= new();
268CreateAudioTranslationOptions(audio, audioFilename, ref options);
269
270using MultipartFormDataBinaryContent content = options.ToMultipartContent(audio, audioFilename);
19a65a0aKrzysztof Cwalina2 years ago271ClientResult result = TranslateAudio(content, content.ContentType, cancellationToken.ToRequestOptions());
9f9f2936Jose Arriaga Maldonado2 years ago272return ClientResult.FromValue(AudioTranslation.FromResponse(result.GetRawResponse()), result.GetRawResponse());
273}
274
13a9c686Jose Arriaga Maldonado1 years ago275/// <summary> Translates the input audio into English. </summary>
9f9f2936Jose Arriaga Maldonado2 years ago276/// <param name="audioFilePath">
13a9c686Jose Arriaga Maldonado1 years ago277/// The path of the audio file to translate. The provided file path's extension (for example: .mp3) will be
278/// used to validate the format of the input audio. The request may fail if the file path's extension and the
279/// actual format of the input audio do not match.
9f9f2936Jose Arriaga Maldonado2 years ago280/// </param>
13a9c686Jose Arriaga Maldonado1 years ago281/// <param name="options"> The options to configure the audio translation. </param>
9f9f2936Jose Arriaga Maldonado2 years ago282/// <exception cref="ArgumentNullException"> <paramref name="audioFilePath"/> was null. </exception>
283/// <exception cref="ArgumentException"> <paramref name="audioFilePath"/> is an empty string, and was expected to be non-empty. </exception>
284public virtual ClientResult<AudioTranslation> TranslateAudio(string audioFilePath, AudioTranslationOptions options = null)
285{
286Argument.AssertNotNullOrEmpty(audioFilePath, nameof(audioFilePath));
287
288using FileStream audioStream = File.OpenRead(audioFilePath);
289return TranslateAudio(audioStream, audioFilePath, options);
290}
291
13a9c686Jose Arriaga Maldonado1 years ago292/// <summary> Translates the input audio into English. </summary>
9f9f2936Jose Arriaga Maldonado2 years ago293/// <param name="audioFilePath">
13a9c686Jose Arriaga Maldonado1 years ago294/// The path of the audio file to translate. The provided file path's extension (for example: .mp3) will be
295/// used to validate the format of the input audio. The request may fail if the file path's extension and the
296/// actual format of the input audio do not match.
9f9f2936Jose Arriaga Maldonado2 years ago297/// </param>
13a9c686Jose Arriaga Maldonado1 years ago298/// <param name="options"> The options to configure the audio translation. </param>
9f9f2936Jose Arriaga Maldonado2 years ago299/// <exception cref="ArgumentNullException"> <paramref name="audioFilePath"/> was null. </exception>
300/// <exception cref="ArgumentException"> <paramref name="audioFilePath"/> is an empty string, and was expected to be non-empty. </exception>
301public virtual async Task<ClientResult<AudioTranslation>> TranslateAudioAsync(string audioFilePath, AudioTranslationOptions options = null)
302{
303Argument.AssertNotNull(audioFilePath, nameof(audioFilePath));
304
305using FileStream audioStream = File.OpenRead(audioFilePath);
306return await TranslateAudioAsync(audioStream, audioFilePath, options);
307}
308
309#endregion
79014abcShivangiReja1 years ago310
9f9f2936Jose Arriaga Maldonado2 years ago311private void CreateSpeechGenerationOptions(string text, GeneratedSpeechVoice voice, ref SpeechGenerationOptions options)
312{
313options.Input = text;
314options.Voice = voice;
315options.Model = _model;
316}
317
318private void CreateAudioTranscriptionOptions(Stream audio, string audioFilename, ref AudioTranscriptionOptions options)
319{
320options.Model = _model;
321}
322
323private void CreateAudioTranslationOptions(Stream audio, string audioFilename, ref AudioTranslationOptions options)
324{
325options.Model = _model;
326}
327}